rbvimeo 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbvimeo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Pruitt
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-13 00:00:00 -05:00
12
+ date: 2009-04-16 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,53 +20,39 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: "0"
23
+ version: "0.6"
24
24
  version:
25
- description: A ruby wrapper for the Vimeo API
25
+ description:
26
26
  email: guitsaru@gmail.com
27
- executables:
28
- - rbVimeo
27
+ executables: []
28
+
29
29
  extensions: []
30
30
 
31
31
  extra_rdoc_files:
32
- - History.txt
33
- - README.txt
34
- - bin/rbVimeo
32
+ - LICENSE
33
+ - README.textile
35
34
  files:
36
- - History.txt
37
- - Manifest.txt
38
- - README.txt
35
+ - LICENSE
36
+ - README.textile
39
37
  - Rakefile
40
- - bin/rbVimeo
41
- - lib/rbVimeo.rb
42
- - lib/Comment.rb
43
- - lib/Thumbnail.rb
44
- - lib/User.rb
45
- - lib/Video.rb
46
- - spec/rbVimeo_spec.rb
47
- - spec/sample_test_settings.yml
48
- - spec/Video_spec.rb
49
- - spec/XML/339189.comments.xml
50
- - spec/XML/339189.xml
51
- - spec/XML/not_found.xml
52
- - spec/spec_helper.rb
53
- - tasks/ann.rake
54
- - tasks/annotations.rake
55
- - tasks/bones.rake
56
- - tasks/doc.rake
57
- - tasks/gem.rake
58
- - tasks/manifest.rake
59
- - tasks/post_load.rake
60
- - tasks/rubyforge.rake
61
- - tasks/setup.rb
62
- - tasks/spec.rake
63
- - tasks/svn.rake
38
+ - VERSION.yml
39
+ - lib/rbvimeo.rb
40
+ - lib/rbvimeo/comment.rb
41
+ - lib/rbvimeo/thumbnail.rb
42
+ - lib/rbvimeo/user.rb
43
+ - lib/rbvimeo/video.rb
44
+ - lib/rbvimeo/vimeo.rb
45
+ - test/XML/339189.comments.xml
46
+ - test/XML/339189.xml
47
+ - test/XML/not_found.xml
48
+ - test/rbvimeo_test.rb
49
+ - test/test_helper.rb
50
+ - test/video_test.rb
64
51
  has_rdoc: true
65
- homepage: www.guitsaru.com
52
+ homepage: http://github.com/guitsaru/rbvimeo
66
53
  post_install_message:
67
54
  rdoc_options:
68
- - --main
69
- - README.txt
55
+ - --charset=UTF-8
70
56
  require_paths:
71
57
  - lib
72
58
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -84,9 +70,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
70
  requirements: []
85
71
 
86
72
  rubyforge_project: rbvimeo
87
- rubygems_version: 1.3.0
73
+ rubygems_version: 1.3.1
88
74
  signing_key:
89
75
  specification_version: 2
90
- summary: A ruby wrapper for the Vimeo API
91
- test_files: []
92
-
76
+ summary: A ruby wrapper for the vimeo api.
77
+ test_files:
78
+ - test/rbvimeo_test.rb
79
+ - test/test_helper.rb
80
+ - test/video_test.rb
data/History.txt DELETED
@@ -1,7 +0,0 @@
1
- == 0.2.1 / 2008-10-13
2
- * Lowered flog store
3
- == 0.2.0 / 2008-08-26
4
- * Switched to Hpricot for XML parsing.
5
- * Comments are now lazily loaded and include memoization.
6
- == 0.1.0 / 2008-04-04
7
- * Initial Release.
data/Manifest.txt DELETED
@@ -1,28 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- Rakefile
5
- bin/rbVimeo
6
- lib/rbVimeo.rb
7
- lib/Comment.rb
8
- lib/Thumbnail.rb
9
- lib/User.rb
10
- lib/Video.rb
11
- spec/rbVimeo_spec.rb
12
- spec/sample_test_settings.yml
13
- spec/Video_spec.rb
14
- spec/XML/339189.comments.xml
15
- spec/XML/339189.xml
16
- spec/XML/not_found.xml
17
- spec/spec_helper.rb
18
- tasks/ann.rake
19
- tasks/annotations.rake
20
- tasks/bones.rake
21
- tasks/doc.rake
22
- tasks/gem.rake
23
- tasks/manifest.rake
24
- tasks/post_load.rake
25
- tasks/rubyforge.rake
26
- tasks/setup.rb
27
- tasks/spec.rake
28
- tasks/svn.rake
data/bin/rbVimeo DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require '../lib/rbVimeo'
4
-
5
- # EOF
data/lib/Comment.rb DELETED
@@ -1,14 +0,0 @@
1
- module RBVIMEO
2
- class Comment
3
- attr_accessor :id, :author, :authorname, :date, :url, :text, :portraits
4
- def initialize(id, author, authorname, date, url, text, portraits)
5
- @id = id
6
- @author = author
7
- @authorname = authorname
8
- @date = date
9
- @url = url
10
- @text = text.chomp.strip
11
- @portraits = portraits
12
- end
13
- end
14
- end
data/lib/Video.rb DELETED
@@ -1,128 +0,0 @@
1
- require 'rubygems'
2
- require 'hpricot'
3
- require 'open-uri'
4
-
5
- module RBVIMEO
6
- class Video
7
- attr_reader :id, :title, :caption, :upload_date, :likes, :plays
8
- attr_reader :num_comments, :width, :height, :owner, :tags, :url
9
- attr_reader :thumbs
10
-
11
- # Fetches data about a video from the Vimeo site
12
- # id is the id of the the Vimeo video
13
- # vimeo is an instance of RBVIMEO::Vimeo
14
- #
15
- # To load a movie with vimeo id 339189:
16
- # @vimeo = RBVIMEO::Vimeo.new api_key, api_secret
17
- # video = RBVIMEO::Video.new 339189, @vimeo
18
- def initialize id, vimeo, xml=nil
19
- @thumbs = []
20
- @comments = []
21
- @id = id
22
- @vimeo = vimeo
23
-
24
- url = vimeo.generate_url({"method" => "vimeo.videos.getInfo",
25
- "video_id" => id, "api_key" => vimeo.api_key}, "read")
26
- unless xml
27
- #does not get covered by specs because we get an internal xml file
28
- xml_doc = Hpricot(open(url))
29
- else
30
- xml_doc = open(xml) {|file| Hpricot(file)}
31
- end
32
-
33
- return @id = -1 if parse_xml(xml_doc).nil?
34
- end
35
-
36
- # Parses data using the xml recieved from the Vimeo REST API
37
- # Should not need to be called by anything other than the initialize method
38
- def parse_xml xml_doc
39
- if xml_doc.at("title").nil?
40
- return nil
41
- else
42
- @id = id
43
- @title = xml_doc.at("title").inner_html
44
- @caption = xml_doc.at("caption").inner_html
45
- @upload_date = xml_doc.at("upload_date").inner_html
46
- @likes = xml_doc.at("number_of_likes").inner_html.to_i
47
- @plays = xml_doc.at("number_of_plays").inner_html.to_i
48
- @width = xml_doc.at("width").inner_html.to_i
49
- @height = xml_doc.at("height").inner_html.to_i
50
- @num_comments = xml_doc.at("number_of_comments").inner_html.to_i
51
-
52
- @owner = User.new
53
- @owner.id = xml_doc.at("owner").attributes["id"].to_i
54
- @owner.username = xml_doc.at("owner").attributes["username"]
55
- @owner.fullname = xml_doc.at("owner").attributes["fullname"]
56
-
57
- @url = xml_doc.at("url").inner_html
58
-
59
- (xml_doc/:thumbnail).each do |thumbnail|
60
- url = thumbnail.inner_html
61
- w = thumbnail.attributes['width'].to_i
62
- h = thumbnail.attributes['height'].to_i
63
- thumbnail = Thumbnail.new(url, w, h)
64
- @thumbs << thumbnail
65
- end
66
- end
67
- end
68
-
69
- # Fetches the comments for the specified Video
70
- # id is the id of the Vimeo video
71
- # vimeo is an instance of RBVIMEO::Vimeo
72
- # returns an Array of comments
73
- #
74
- # To load a movie with vimeo id 339189:
75
- #
76
- # comments = video.comments 339189, @vimeo
77
- def get_comments xml=nil
78
- comments = []
79
- url = @vimeo.generate_url({"method" => "vimeo.videos.comments.getList",
80
- "video_id" => @id, "api_key" => @vimeo.api_key}, "read")
81
-
82
- unless xml
83
- # Does not get covered by specs because we get an internal xml file
84
- xml_doc = Hpricot.XML(open(url))
85
- else
86
- xml_doc = open(xml) {|file| Hpricot.XML(file)}
87
- end
88
-
89
- (xml_doc/:comment).each do |comment|
90
- text = comment.children.select{|e| e.text?}.join
91
- id = comment.attributes['id'].to_i
92
- author = comment.attributes['author']
93
- authorname = comment.attributes['authorname']
94
- date = comment.attributes['datecreate']
95
- url = comment.attributes['permalink']
96
-
97
- @portraits = []
98
- (comment/'portraits'/'portrait').each do |thumb|
99
- portrait_url = thumb.inner_html
100
- w = thumb.attributes['width'].to_i
101
- h = thumb.attributes['height'].to_i
102
- thumbnail = Thumbnail.new(portrait_url, w, h)
103
- @portraits << thumbnail
104
- end
105
- com = Comment.new(id, author, authorname, date, url, text, @portraits)
106
- @comments << com
107
- end
108
- return self
109
- end
110
-
111
- # Returns the code to embed the video
112
- def embed width, height
113
- string = <<EOF
114
- <object type="application/x-shockwave-flash" width=#{width} height=#{height} data="http://www.vimeo.com/moogaloop.swf?clip_id=#{@id}&server=www.vimeo.com&fullscreen=0&show_title=0'&show_byline=0&showportrait=0&color=00ADEF">
115
- <param name="quality" value="best" />
116
- <param name="allowfullscreen" value="false" />
117
- <param name="scale" value="showAll" />
118
- <param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=#{@id}&server=www.vimeo.com&fullscreen=0&show_title=0&show_byline=0&showportrait=0&color=00ADEF" /></object>
119
- EOF
120
- string.gsub("\n", "")
121
- end
122
-
123
- def comments xml=nil
124
- get_comments(xml) if @comments.empty?
125
- return @comments
126
- end
127
- end
128
- end
data/spec/Video_spec.rb DELETED
@@ -1,82 +0,0 @@
1
- require File.join(File.dirname(__FILE__), %w[spec_helper])
2
- require File.join(File.dirname(__FILE__), "../lib/rbVimeo.rb")
3
- require File.join(File.dirname(__FILE__), "../lib/Video.rb")
4
- require "yaml"
5
-
6
- include RBVIMEO
7
-
8
- describe Video, "initialization" do
9
- before(:all) do
10
- test_settings_file = File.join(File.dirname(__FILE__), %w[test_settings.yml])
11
- test_video_xml_file = File.join(File.dirname(__FILE__), %w[XML/339189.xml])
12
- test_settings = YAML.load_file(test_settings_file)
13
- @api_key = test_settings['api_key']
14
- @api_secret = test_settings['api_secret']
15
- @vimeo = RBVIMEO::Vimeo.new(@api_key, @api_secret)
16
- @vid = @vimeo.video(339189, test_video_xml_file)
17
- end
18
-
19
- it "should have title" do
20
- @vid.title.should eql("Upload Tutorial")
21
- end
22
-
23
- it "should have caption" do
24
- @vid.caption.should eql("This is a tutorial about our new Uploader. Enjoy!")
25
- end
26
-
27
- it "should have upload date" do
28
- @vid.upload_date.should eql("2007-10-12 16:30:32")
29
- end
30
-
31
- it "should have likes" do
32
- @vid.likes.should eql(174)
33
- end
34
-
35
- it "should have plays" do
36
- @vid.plays.should eql(515407)
37
- end
38
-
39
- it "should have dimensions" do
40
- @vid.width.should eql(506)
41
- @vid.height.should eql(380)
42
- end
43
-
44
- it "should have comments" do
45
- @vid.num_comments.should eql(34)
46
- @vid.comments[0].id.should eql(265313)
47
- @vid.comments[0].author.should eql("ctd3")
48
- @vid.comments[0].authorname.should eql("CTD3")
49
- @vid.comments[0].date.should eql("2007-10-12 17:47:13")
50
- @vid.comments[0].url.should eql("http://vimeo.com/339189#comment_265313")
51
- @vid.comments[0].text.should eql("Sure is! Great changes!")
52
- @vid.comments[0].portraits[0].url.should eql("http://80.media.vimeo.com/d1/5/35/44/42/portrait-35444268.jpg")
53
- @vid.comments[0].portraits[0].width.should eql(24)
54
- @vid.comments[0].portraits[0].height.should eql(24)
55
- end
56
-
57
- it "should have owner" do
58
- @vid.owner.id.should eql(152184)
59
- @vid.owner.username.should eql("staff")
60
- @vid.owner.fullname.should eql("Vimeo Staff")
61
- end
62
-
63
- it "should have url" do
64
- @vid.url.should eql("http://www.vimeo.com/339189/l:app-230")
65
- end
66
-
67
- it "should have thumbnails" do
68
- @vid.thumbs[0].url.should eql("http://40.media.vimeo.com/d1/5/36/63/98/thumbnail-36639824.jpg")
69
- @vid.thumbs[0].width.should eql(96)
70
- @vid.thumbs[0].height.should eql(72)
71
- end
72
-
73
- it "should return nil on nonexistent video" do
74
- not_found_xml_file = File.join(File.dirname(__FILE__), %w[XML/not_found.xml])
75
- video = @vimeo.video(99999999999, not_found_xml_file)
76
- video.should be_nil
77
- end
78
-
79
- it "should give an embed link" do
80
- @vid.embed(240, 480).should_not be_nil
81
- end
82
- end
data/spec/rbVimeo_spec.rb DELETED
@@ -1,38 +0,0 @@
1
- require File.join(File.dirname(__FILE__), %w[spec_helper])
2
- require File.join(File.dirname(__FILE__), "../lib/rbVimeo.rb")
3
- require "yaml"
4
-
5
- include RBVIMEO
6
-
7
- describe Vimeo do
8
- before(:all) do
9
- test_settings_file = File.join(File.dirname(__FILE__), %w[test_settings.yml])
10
- test_settings = YAML.load_file(test_settings_file)
11
- @api_key = test_settings['api_key']
12
- @api_secret = test_settings['api_secret']
13
- @vimeo = RBVIMEO::Vimeo.new(@api_key, @api_secret)
14
- @params = {"method" => "vimeo.videos.getInfo", "video_id" => "339189", "api_key" => @api_key}
15
- end
16
-
17
- it "should initialize" do
18
- @api_key.should_not be_nil
19
- @api_secret.should_not be_nil
20
- end
21
-
22
- it "should generate a signature" do
23
- @vimeo.generate_signature(@params).should eql("09cc6d8b963c73caf647e436b2147810")
24
- end
25
-
26
- it "should generate a url" do
27
- @vimeo.generate_url(@params, "read").should eql("http://www.vimeo.com/api/rest?api_key=" + @api_key + "&method=vimeo.videos.getInfo&video_id=339189&api_sig=09cc6d8b963c73caf647e436b2147810")
28
- end
29
-
30
- it "should generate a video" do
31
- test_video_xml_file = File.join(File.dirname(__FILE__), %w[XML/339189.xml])
32
- @vid = @vimeo.video(339189, test_video_xml_file)
33
- end
34
-
35
- it "should generate a user" do
36
- @vimeo.user.should_not be_nil
37
- end
38
- end
@@ -1,2 +0,0 @@
1
- api_key: api_key
2
- api_secret: api_secret
data/spec/spec_helper.rb DELETED
@@ -1,17 +0,0 @@
1
- # $Id$
2
-
3
- require File.expand_path(
4
- File.join(File.dirname(__FILE__), %w[.. lib rbVimeo]))
5
-
6
- Spec::Runner.configure do |config|
7
- # == Mock Framework
8
- #
9
- # RSpec uses it's own mocking framework by default. If you prefer to
10
- # use mocha, flexmock or RR, uncomment the appropriate line:
11
- #
12
- # config.mock_with :mocha
13
- # config.mock_with :flexmock
14
- # config.mock_with :rr
15
- end
16
-
17
- # EOF
data/tasks/ann.rake DELETED
@@ -1,81 +0,0 @@
1
- # $Id$
2
-
3
- begin
4
- require 'bones/smtp_tls'
5
- rescue LoadError
6
- require 'net/smtp'
7
- end
8
- require 'time'
9
-
10
- namespace :ann do
11
-
12
- # A prerequisites task that all other tasks depend upon
13
- task :prereqs
14
-
15
- file PROJ.ann.file do
16
- ann = PROJ.ann
17
- puts "Generating #{ann.file}"
18
- File.open(ann.file,'w') do |fd|
19
- fd.puts("#{PROJ.name} version #{PROJ.version}")
20
- fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
21
- fd.puts(" #{PROJ.url}") if PROJ.url.valid?
22
- fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
23
- fd.puts
24
- fd.puts("== DESCRIPTION")
25
- fd.puts
26
- fd.puts(PROJ.description)
27
- fd.puts
28
- fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
29
- fd.puts
30
- ann.paragraphs.each do |p|
31
- fd.puts "== #{p.upcase}"
32
- fd.puts
33
- fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
34
- fd.puts
35
- end
36
- fd.puts ann.text if ann.text
37
- end
38
- end
39
-
40
- desc "Create an announcement file"
41
- task :announcement => ['ann:prereqs', PROJ.ann.file]
42
-
43
- desc "Send an email announcement"
44
- task :email => ['ann:prereqs', PROJ.ann.file] do
45
- ann = PROJ.ann
46
- from = ann.email[:from] || PROJ.email
47
- to = Array(ann.email[:to])
48
-
49
- ### build a mail header for RFC 822
50
- rfc822msg = "From: #{from}\n"
51
- rfc822msg << "To: #{to.join(',')}\n"
52
- rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
53
- rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
54
- rfc822msg << "\n"
55
- rfc822msg << "Date: #{Time.new.rfc822}\n"
56
- rfc822msg << "Message-Id: "
57
- rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{ann.email[:domain]}>\n\n"
58
- rfc822msg << File.read(ann.file)
59
-
60
- params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
61
- ann.email[key]
62
- end
63
-
64
- params[3] = PROJ.email if params[3].nil?
65
-
66
- if params[4].nil?
67
- STDOUT.write "Please enter your e-mail password (#{params[3]}): "
68
- params[4] = STDIN.gets.chomp
69
- end
70
-
71
- ### send email
72
- Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
73
- end
74
- end # namespace :ann
75
-
76
- desc 'Alias to ann:announcement'
77
- task :ann => 'ann:announcement'
78
-
79
- CLOBBER << PROJ.ann.file
80
-
81
- # EOF
@@ -1,22 +0,0 @@
1
- # $Id$
2
-
3
- if HAVE_BONES
4
-
5
- desc "Enumerate all annotations"
6
- task :notes do
7
- Bones::AnnotationExtractor.enumerate(
8
- PROJ, PROJ.annotation_tags.join('|'), :tag => true)
9
- end
10
-
11
- namespace :notes do
12
- PROJ.notes.tags.each do |tag|
13
- desc "Enumerate all #{tag} annotations"
14
- task tag.downcase.to_sym do
15
- Bones::AnnotationExtractor.enumerate(PROJ, tag)
16
- end
17
- end
18
- end
19
-
20
- end # if HAVE_BONES
21
-
22
- # EOF
data/tasks/bones.rake DELETED
@@ -1,21 +0,0 @@
1
- # $Id$
2
-
3
- if HAVE_BONES
4
-
5
- namespace :bones do
6
-
7
- desc 'Show the PROJ open struct'
8
- task :debug do |t|
9
- atr = if t.application.top_level_tasks.length == 2
10
- t.application.top_level_tasks.pop
11
- end
12
-
13
- if atr then Bones::Debug.show_attr(PROJ, atr)
14
- else Bones::Debug.show PROJ end
15
- end
16
-
17
- end # namespace :bones
18
-
19
- end # HAVE_BONES
20
-
21
- # EOF
data/tasks/doc.rake DELETED
@@ -1,48 +0,0 @@
1
- # $Id$
2
-
3
- require 'rake/rdoctask'
4
-
5
- namespace :doc do
6
-
7
- desc 'Generate RDoc documentation'
8
- Rake::RDocTask.new do |rd|
9
- rd.main = PROJ.rdoc.main
10
- rd.rdoc_dir = PROJ.rdoc.dir
11
-
12
- incl = Regexp.new(PROJ.rdoc.include.join('|'))
13
- excl = Regexp.new(PROJ.rdoc.exclude.join('|'))
14
- files = PROJ.gem.files.find_all do |fn|
15
- case fn
16
- when excl; false
17
- when incl; true
18
- else false end
19
- end
20
- rd.rdoc_files.push(*files)
21
-
22
- title = "#{PROJ.name}-#{PROJ.version} Documentation"
23
- title = "#{PROJ.rubyforge.name}'s " + title if PROJ.rubyforge.name != title
24
-
25
- rd.options << "-t #{title}"
26
- rd.options.concat(PROJ.rdoc.opts)
27
- end
28
-
29
- desc 'Generate ri locally for testing'
30
- task :ri => :clobber_ri do
31
- sh "#{RDOC} --ri -o ri ."
32
- end
33
-
34
- task :clobber_ri do
35
- rm_r 'ri' rescue nil
36
- end
37
-
38
- end # namespace :doc
39
-
40
- desc 'Alias to doc:rdoc'
41
- task :doc => 'doc:rdoc'
42
-
43
- desc 'Remove all build products'
44
- task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
45
-
46
- remove_desc_for_task %w(doc:clobber_rdoc)
47
-
48
- # EOF