guitsaru


rbVimeo release
April 11, 2008, 11:35 pm
Filed under: Programming | Tags: , ,

Today I have released the first version of the rbVimeo gem. This is a ruby wrapper for the Vimeo API. To install the gem, run the following command:

sudo gem install rbvimeo

To demonstrate this library, I have created a simple rails app that takes a video’s id and displays that video on the page.

index.html.erb:


 <%- form_remote_tag :url => { :action => 'search' },
 	:update => 'video',
 	:before => %(Element.show(spinner)),
 	:success => %(Element.hide(spinner)) do -%>
 <%= image_tag 'spinner.gif', :id => 'spinner',
 	:style => 'display: none'%>

	<label for="video_id">Video ID:</label>
 <%= text_field_tag 'video_id' %>
 <%= submit_tag 'Search' %>
 <% end %>
 <div id="video"></div>

The index takes the Vimeo video’s id and pushes it to the controller action for search.

vimeo_controller.rb:


class VimeoController < ApplicationController
  def search
    vimeo = RBVIMEO::Vimeo.new("api_key", "api_secret")
    render :partial => "video.html.erb",
 	  :locals => {:video => vimeo.video(params[:video_id])}
  end
end

This then sends the video object into the video partial which embeds it into the video div from the index.

_video.html.erb:


<%= video.embed(video.width, video.height) %>

Here is a video that shows the final application

rbVimeo Documentation
Github project