Skip to content

Commit a282b29

Browse files
author
matthooks
committed
Updated Vimeo::Simple to API v2 and added FakeWeb tests.
1 parent e6d161d commit a282b29

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+456
-83
lines changed

CHANGELOG.rdoc

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2+
13
== 0.2.2, released 2009-04-21
24

35
* Removed CGI escapes. Vimeo should be handling them on their end.

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2008 Matt Hooks
1+
Copyright (c) 2009 Matt Hooks
22

33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the

README.rdoc

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ The wrapper for the Simple API consists of the following classes and methods:
3232
=== Vimeo::Simple::User
3333

3434
Vimeo::Simple::User.info(username)
35-
Vimeo::Simple::User.clips(username)
35+
Vimeo::Simple::User.videos(username)
3636
Vimeo::Simple::User.likes(username)
3737
Vimeo::Simple::User.appears_in(username)
38-
Vimeo::Simple::User.all_clips(username)
38+
Vimeo::Simple::User.all_videos(username)
3939
Vimeo::Simple::User.subscriptions(username)
4040
Vimeo::Simple::User.albums(username)
4141
Vimeo::Simple::User.channels(username)
4242
Vimeo::Simple::User.groups(username)
43-
Vimeo::Simple::User.contacts_clips(username)
43+
Vimeo::Simple::User.contacts_videos(username)
4444
Vimeo::Simple::User.contacts_like(username)
4545

4646
=== Vimeo::Simple::Clip
@@ -57,18 +57,18 @@ The wrapper for the Simple API consists of the following classes and methods:
5757

5858
=== Vimeo::Simple::Group
5959

60-
Vimeo::Simple::Group.clips(groupname)
60+
Vimeo::Simple::Group.videos(groupname)
6161
Vimeo::Simple::Group.users(groupname)
6262
Vimeo::Simple::Group.info(groupname)
6363

6464
=== Vimeo::Simple::Channel
6565

66-
Vimeo::Simple::Channel.clips(channelname)
66+
Vimeo::Simple::Channel.videos(channelname)
6767
Vimeo::Simple::Channel.info(channelname)
6868

6969
=== Vimeo::Simple::Album
7070

71-
Vimeo::Simple::Album.clips(album_id)
71+
Vimeo::Simple::Album.videos(album_id)
7272
Vimeo::Simple::Album.info(album_id)
7373

7474
== Advanced API

Rakefile

+54-33
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,70 @@
1+
require 'rubygems'
12
require 'rake'
2-
require 'rake/testtask'
3-
require 'rake/rdoctask'
4-
require 'rcov/rcovtask'
53

64
begin
75
require 'jeweler'
8-
Jeweler::Tasks.new do |s|
9-
s.name = "vimeo"
10-
s.summary = "A full featured Ruby implementation of the Vimeo API."
11-
s.email = "[email protected]"
12-
s.homepage = "http://github.com/matthooks/vimeo"
13-
s.description = "A full featured Ruby implementation of the Vimeo API."
14-
s.authors = ["Matt Hooks"]
15-
16-
s.files = FileList["[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"]
17-
18-
s.has_rdoc = true
19-
s.rdoc_options = ['--main', 'README.rdoc']
20-
s.rdoc_options << '--inline-source' << '--charset=UTF-8'
21-
s.extra_rdoc_files = ['README.rdoc', 'LICENSE', 'CHANGELOG.rdoc']
6+
Jeweler::Tasks.new do |gem|
7+
gem.name = "vimeo"
8+
gem.summary = %Q{A full featured Ruby implementation of the Vimeo API.}
9+
gem.description = %Q{A full featured Ruby implementation of the Vimeo API.}
10+
gem.email = "[email protected]"
11+
gem.homepage = "http://github.com/matthooks/vimeo"
12+
gem.authors = ["Matt Hooks"]
13+
gem.rubyforge_project = "vimeo"
14+
gem.add_development_dependency "thoughtbot-shoulda"
15+
gem.add_development_dependency "fakeweb"
16+
17+
# s.files = FileList["[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"]
18+
#
19+
# s.has_rdoc = true
20+
# s.rdoc_options = ['--main', 'README.rdoc']
21+
# s.rdoc_options << '--inline-source' << '--charset=UTF-8'
22+
# s.extra_rdoc_files = ['README.rdoc', 'LICENSE', 'CHANGELOG.rdoc']
2223

23-
s.add_dependency(%q<jnunemaker-httparty>, [">= 0.2.6"])
24+
gem.add_dependency "httparty", ">= 0.4.5"
25+
end
26+
Jeweler::GemcutterTasks.new
27+
Jeweler::RubyforgeTasks.new do |rubyforge|
28+
rubyforge.doc_task = "rdoc"
2429
end
2530
rescue LoadError
26-
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
31+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
2732
end
2833

29-
Rake::TestTask.new do |t|
30-
t.libs << 'lib'
31-
t.pattern = 'test/**/*_test.rb'
32-
t.verbose = false
34+
require 'rake/testtask'
35+
Rake::TestTask.new(:test) do |test|
36+
test.libs << 'lib' << 'test'
37+
test.pattern = 'test/**/*_test.rb'
38+
test.verbose = true
3339
end
3440

41+
begin
42+
require 'rcov/rcovtask'
43+
Rcov::RcovTask.new do |test|
44+
test.libs << 'test'
45+
test.pattern = 'test/**/*_test.rb'
46+
test.verbose = true
47+
end
48+
rescue LoadError
49+
task :rcov do
50+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
51+
end
52+
end
53+
54+
task :test => :check_dependencies
55+
56+
task :default => :test
57+
58+
require 'rake/rdoctask'
3559
Rake::RDocTask.new do |rdoc|
60+
if File.exist?('VERSION')
61+
version = File.read('VERSION')
62+
else
63+
version = ""
64+
end
65+
3666
rdoc.rdoc_dir = 'rdoc'
37-
rdoc.title = 'vimeo'
38-
rdoc.options << '--line-numbers' << '--inline-source'
67+
rdoc.title = "vimeo #{version}"
3968
rdoc.rdoc_files.include('README*')
4069
rdoc.rdoc_files.include('lib/**/*.rb')
4170
end
42-
43-
Rcov::RcovTask.new do |t|
44-
t.libs << 'test'
45-
t.test_files = FileList['test/**/*_test.rb']
46-
t.verbose = true
47-
end
48-
49-
task :default => :rcov

lib/vimeo/simple.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require 'simple/activity'
44
require 'simple/album'
55
require 'simple/channel'
6-
require 'simple/clip'
6+
require 'simple/video'
77
require 'simple/group'
88
require 'simple/user'
99

lib/vimeo/simple/album.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ module Vimeo
22
module Simple
33

44
class Album < Vimeo::Simple::Base
5-
# Returns this album's clips.
6-
def self.clips(album_id)
7-
get("/album/#{album_id}/clips.json")
5+
# Returns this album's videos.
6+
def self.videos(album_id)
7+
get("/album/#{album_id}/videos.json")
88
end
99

1010
# Returns this album's information.

lib/vimeo/simple/base.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Simple
33

44
class Base
55
include HTTParty
6-
base_uri 'vimeo.com/api'
6+
base_uri 'vimeo.com/api/v2'
77

88
# TODO: Format options
99
end

lib/vimeo/simple/channel.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ module Vimeo
22
module Simple
33

44
class Channel < Vimeo::Simple::Base
5-
# Returns this channel's clips.
6-
def self.clips(channelname)
7-
get("/channel/#{channelname}/clips.json")
5+
# Returns this channel's videos.
6+
def self.videos(channelname)
7+
get("/channel/#{channelname}/videos.json")
88
end
99

1010
# Returns this channel's information.

lib/vimeo/simple/clip.rb

-12
This file was deleted.

lib/vimeo/simple/group.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ module Vimeo
22
module Simple
33

44
class Group < Vimeo::Simple::Base
5-
# Returns this group's clips.
6-
def self.clips(groupname)
7-
get("/group/#{groupname}/clips.json")
5+
# Returns this group's videos.
6+
def self.videos(groupname)
7+
get("/group/#{groupname}/videos.json")
88
end
99

1010
# Returns this group's users.

lib/vimeo/simple/user.rb

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ def self.info(username)
77
get("/#{username}/info.json")
88
end
99

10-
# Returns this user's clips.
11-
def self.clips(username)
12-
get("/#{username}/clips.json")
10+
# Returns this user's videos.
11+
def self.videos(username)
12+
get("/#{username}/videos.json")
1313
end
1414

15-
# Returns this user's liked clips.
15+
# Returns this user's liked videos.
1616
def self.likes(username)
1717
get("/#{username}/likes.json")
1818
end
1919

20-
# Returns the clips this user appears in.
20+
# Returns the videos this user appears in.
2121
def self.appears_in(username)
2222
get("/#{username}/appears_in.json")
2323
end
2424

25-
# Returns all clips related to this user.
26-
def self.all_clips(username)
27-
get("/#{username}/all_clips.json")
25+
# Returns all videos related to this user.
26+
def self.all_videos(username)
27+
get("/#{username}/all_videos.json")
2828
end
2929

3030
# Returns this user's subscriptions.
@@ -47,12 +47,12 @@ def self.groups(username)
4747
get("/#{username}/groups.json")
4848
end
4949

50-
# Returns this user's contact's clips.
51-
def self.contacts_clips(username)
52-
get("/#{username}/contacts_clips.json")
50+
# Returns this user's contact's videos.
51+
def self.contacts_videos(username)
52+
get("/#{username}/contacts_videos.json")
5353
end
5454

55-
# Returns the clips that this user's contact's liked.
55+
# Returns the videos that this user's contact's liked.
5656
def self.contacts_like(username)
5757
get("/#{username}/contacts_like.json")
5858
end

lib/vimeo/simple/video.rb

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module Vimeo
2+
module Simple
3+
4+
class Video < Vimeo::Simple::Base
5+
# Returns this video's information.
6+
def self.info(video_id)
7+
get("/video/#{video_id}.json")
8+
end
9+
end
10+
11+
end # End Simple
12+
end # End Vimeo

test/fixtures/simple/activity/contacts_did.json

+1
Large diffs are not rendered by default.

test/fixtures/simple/activity/everyone_did.json

+1
Large diffs are not rendered by default.

test/fixtures/simple/activity/happened_to_contacts.json

+1
Large diffs are not rendered by default.

test/fixtures/simple/activity/happened_to_user.json

+1
Large diffs are not rendered by default.

test/fixtures/simple/activity/user_did.json

+1
Large diffs are not rendered by default.

test/fixtures/simple/album/info.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"id":"129077","created_on":"2009-09-22 18:32:20","last_modified":"2009-09-23 16:31:55","title":"Vimeo Offline: HD","description":"","url":"http:\/\/vimeo.com\/album\/129077","thumbnail_small":"http:\/\/ts.vimeo.com.s3.amazonaws.com\/250\/567\/25056767_100.jpg","thumbnail_medium":"http:\/\/ts.vimeo.com.s3.amazonaws.com\/250\/567\/25056767_200.jpg","thumbnail_large":"http:\/\/ts.vimeo.com.s3.amazonaws.com\/250\/567\/25056767_640.jpg","total_videos":38,"user_id":"151382","user_display_name":"Blake Whitman","user_url":"http:\/\/vimeo.com\/blakewhitman"}

test/fixtures/simple/album/videos.json

+1
Large diffs are not rendered by default.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"id":"58337","name":"Canon EOS 7D Channel","description":"This channel shows footage, short films and test shots done with the Canon EOS 7D.","logo":"http:\/\/channelheader.vimeo.com.s3.amazonaws.com\/313\/3135_980.jpg","badge":"","url":"http:\/\/vimeo.com\/channels\/canon7d","rss":"http:\/\/vimeo.com\/channels\/canon7d\/videos\/rss","created_on":"2009-09-03 03:10:07","creator_id":"668648","creator_display_name":"Nigel","creator_url":"http:\/\/vimeo.com\/patko","total_videos":38,"total_subscribers":98}

test/fixtures/simple/channel/videos.json

+1
Large diffs are not rendered by default.

test/fixtures/simple/group/info.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"id":"20067","name":"Vimeo World Tour '09","description":"We're coming to Europe! For 11 days, Karen and I will be gallivanting across the European lands to meet and greet all you fine Vimeo members and hold Vimeo Offline parties. This Group will be a place for everyone to share videos of the events and the video blog of the trip that Karen and I will be shooting.<br \/>\r\n<br \/>\r\nVimeo Offline: Europe<br \/>\r\nBerlin - August 19<br \/>\r\nParis - August 22<br \/>\r\nLondon - August 25","url":"http:\/\/vimeo.com\/groups\/worldtour","logo":"http:\/\/images.vimeo.com\/grouplogo-32068.jpg","thumbnail":"http:\/\/ts.vimeo.com.s3.amazonaws.com\/264\/108\/26410872_100.jpg","created_on":"2009-07-20 18:13:20","creator_id":"151382","creator_display_name":"Blake Whitman","creator_url":"http:\/\/vimeo.com\/blakewhitman","total_members":"430","total_videos":"10","total_files":6,"total_forum_topics":13,"total_events":3,"total_upcoming_events":0}

test/fixtures/simple/group/users.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"display_name":"cris","created_on":"2009-09-22 04:56:27","location":"","url":"","bio":"","profile_url":"http:\/\/vimeo.com\/user2338154","videos_url":"http:\/\/vimeo.com\/user2338154\/videos","is_mod":"no","is_creator":"no","total_videos_uploaded":0,"total_videos_appears_in":0,"total_videos_liked":2,"total_contacts":0,"total_albums":0,"total_channels":0,"portrait_small":"http:\/\/bitcast.vimeo.com\/vimeo\/portraits\/defaults\/d.30.jpg","portrait_medium":"http:\/\/bitcast.vimeo.com\/vimeo\/portraits\/defaults\/d.75.jpg","portrait_large":"http:\/\/bitcast.vimeo.com\/vimeo\/portraits\/defaults\/d.100.jpg","portrait_huge":"http:\/\/bitcast.vimeo.com\/vimeo\/portraits\/defaults\/d.300.jpg"}]

0 commit comments

Comments
 (0)