vimeo 1.2.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,9 +11,10 @@ begin
11
11
  gem.homepage = "http://github.com/matthooks/vimeo"
12
12
  gem.authors = ["Matt Hooks"]
13
13
  gem.rubyforge_project = "vimeo"
14
- gem.add_development_dependency "shoulda", ">= 2.11.1"
14
+ gem.add_development_dependency "shoulda", ">= 2.11.3"
15
15
  gem.add_development_dependency "fakeweb", ">= 1.2.6"
16
16
  gem.add_development_dependency "crack", ">= 0.1.4"
17
+ gem.add_development_dependency "ruby-prof", ">= 0.9.2"
17
18
 
18
19
  gem.has_rdoc = true
19
20
 
@@ -23,6 +24,7 @@ begin
23
24
  gem.add_dependency "httparty", ">= 0.4.5"
24
25
  gem.add_dependency "json", ">= 1.1.9"
25
26
  gem.add_dependency "oauth", ">= 0.3.6"
27
+ gem.add_dependency "httpclient", ">= 2.1.5.2"
26
28
  end
27
29
  Jeweler::GemcutterTasks.new
28
30
  rescue LoadError
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 0
3
- :major: 1
4
- :build:
5
2
  :minor: 2
3
+ :build:
4
+ :patch: 2
5
+ :major: 1
data/lib/vimeo.rb CHANGED
@@ -3,7 +3,6 @@ require 'httparty'
3
3
  require 'digest/md5'
4
4
 
5
5
  $:.unshift(File.dirname(__FILE__))
6
- require 'oauth_client'
7
6
  require 'vimeo/simple'
8
7
  require 'vimeo/advanced'
9
8
 
@@ -1,3 +1,5 @@
1
+ require 'oauth'
2
+
1
3
  module CreateApiMethod
2
4
 
3
5
  # Creates a method that calls a Vimeo Method through the Advanced API.
@@ -18,6 +20,7 @@ module CreateApiMethod
18
20
 
19
21
  required = options[:required].map { |r| r.to_s }.join(",")
20
22
  optional = options[:optional].map { |o| ":#{o} => nil" }.join(",")
23
+ authorized = options.fetch(:authorized, true)
21
24
 
22
25
  parameters = "(#{required unless required.blank?}#{',' unless required.blank?}options={#{optional}})"
23
26
 
@@ -34,7 +37,7 @@ module CreateApiMethod
34
37
  #{ options[:required].map { |r| "sig_options.merge! :#{r} => #{r}"}.join("\n") }
35
38
  #{ options[:optional].map { |o| "sig_options.merge! :#{o} => options[:#{o}] unless options[:#{o}].nil?" }.join("\n") }
36
39
 
37
- make_request sig_options
40
+ make_request sig_options, #{authorized ? "true" : "false"}
38
41
  end
39
42
 
40
43
  alias #{camelized_method} #{method}
@@ -65,7 +68,7 @@ module Vimeo
65
68
  extend CreateApiMethod
66
69
 
67
70
  def initialize(consumer_key, consumer_secret, options = {})
68
- @oauth_consumer = OAuth::Consumer.new(consumer_key, consumer_secret, :site => 'http://vimeo.com', :http_method => :get, :scheme => :query_string)
71
+ @oauth_consumer = OAuth::Consumer.new(consumer_key, consumer_secret, :site => 'http://vimeo.com', :http_method => :get, :scheme => :header)
69
72
  unless options[:token].nil? && options[:secret].nil?
70
73
  @access_token = OAuth::AccessToken.new(@oauth_consumer, options[:token], options[:secret])
71
74
  end
@@ -76,7 +79,7 @@ module Vimeo
76
79
  end
77
80
 
78
81
  def get_request_token
79
- @request_token ||= @oauth_consumer.get_request_token :scheme => :query_string
82
+ @request_token ||= @oauth_consumer.get_request_token :scheme => :header
80
83
  end
81
84
 
82
85
  def get_access_token(oauth_token=nil, oauth_secret=nil, oauth_verifier=nil)
@@ -89,8 +92,14 @@ module Vimeo
89
92
 
90
93
  private
91
94
 
92
- def make_request(options)
93
- response = Crack::JSON.parse @oauth_consumer.request(:post, "http://vimeo.com/api/rest/v2", get_access_token, {}, options).body
95
+ def make_request(options, authorized)
96
+ if authorized
97
+ raw_response = @oauth_consumer.request(:post, "http://vimeo.com/api/rest/v2", get_access_token, {}, options).body
98
+ else
99
+ raw_response = @oauth_consumer.request(:post, "http://vimeo.com/api/rest/v2", nil, {}, options).body
100
+ end
101
+
102
+ response = Crack::JSON.parse(raw_response)
94
103
  validate_response! response
95
104
  response
96
105
  end
@@ -45,7 +45,7 @@ module Vimeo
45
45
  # Verifies a file manifest.
46
46
  create_api_method :verify_manifest,
47
47
  "vimeo.videos.upload.verifyManifest",
48
- :required => [:auth_token, :ticket_id]
48
+ :required => [:ticket_id]
49
49
 
50
50
  # TODO: Make this more flexible for split uploads?
51
51
  def self.create_json_manifest(md5s)
@@ -87,7 +87,8 @@ module Vimeo
87
87
  create_api_method :search,
88
88
  "vimeo.videos.search",
89
89
  :required => [:query],
90
- :optional => [:page, :per_page, :full_response, :sort, :user_id]
90
+ :optional => [:page, :per_page, :full_response, :sort, :user_id],
91
+ :authorized => false
91
92
 
92
93
  create_api_method :set_description,
93
94
  "vimeo.videos.setDescription",
@@ -5,7 +5,6 @@ module Vimeo
5
5
  # Returns a list of presets for a video embed.
6
6
  create_api_method :get_presets,
7
7
  "vimeo.video.embed.getPresets",
8
- :required => [:auth_token],
9
8
  :optional => [:page, :per_page]
10
9
 
11
10
  # Sets a preset for a video embed.
@@ -0,0 +1 @@
1
+ oauth_token=12345&oauth_token_secret=secret
data/test/test_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
3
 
4
- gem 'shoulda', ">= 2.11.1"
4
+ gem 'thoughtbot-shoulda', ">= 2.10.2"
5
5
  gem 'fakeweb', ">= 1.2.6"
6
6
  gem 'crack', ">= 0.1.4"
7
7
  gem 'mocha', ">= 0.9.8"
@@ -19,6 +19,9 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
19
19
  require 'vimeo'
20
20
 
21
21
  class Test::Unit::TestCase
22
+ def setup
23
+ FakeWeb.clean_registry
24
+ end
22
25
  end
23
26
 
24
27
  def fixture_file(filename)
@@ -9,7 +9,7 @@ class AlbumTest < Test::Unit::TestCase
9
9
  end
10
10
 
11
11
  should "be able to add a video to an album" do
12
- stub_custom_post("?oauth_nonce=3MFt5up5QljUQKJS8u9bOPzX9DXn3Xll1vdLLV2bwo&oauth_signature_method=HMAC-SHA1&oauth_token=token&oauth_timestamp=1261345197&oauth_consumer_key=12345&oauth_version=1.0&oauth_signature=SgRuPWsG%2BSHGOdw6HVbfHtqSXsY%3D", "advanced/album/add_video.json")
12
+ stub_post("?oauth_nonce=3MFt5up5QljUQKJS8u9bOPzX9DXn3Xll1vdLLV2bwo&oauth_signature_method=HMAC-SHA1&oauth_token=token&oauth_timestamp=1261345197&oauth_consumer_key=12345&oauth_version=1.0&oauth_signature=SgRuPWsG%2BSHGOdw6HVbfHtqSXsY%3D", "advanced/album/add_video.json")
13
13
  response = @album.add_video("album_id", "video_id")
14
14
 
15
15
  assert_equal "ok", response["stat"]
@@ -12,13 +12,14 @@ class AuthTest < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  should "recieve a valid OAuth url" do
15
- stub_custom_post("/oauth/request_token", "advanced/auth/request_token.txt")
16
- token = @auth.request_token
15
+ stub_custom_get("/oauth/request_token", "advanced/auth/request_token.txt")
16
+ token = @auth.get_request_token
17
17
  assert_equal true, token.callback_confirmed?
18
18
  assert_equal "http://vimeo.com/oauth/authorize?oauth_token=#{TOKEN}", token.authorize_url
19
19
  end
20
20
 
21
21
  should "receive the user's credentials after checking the OAuth token" do
22
+ stub_custom_get("/oauth/access_token", "advanced/auth/access_token.txt")
22
23
  stub_post("", "advanced/auth/check_access_token.json")
23
24
  auth = @auth.check_access_token
24
25
  assert_equal "token", auth["token"]
@@ -7,12 +7,11 @@ class BaseTest < Test::Unit::TestCase
7
7
  setup do
8
8
  @base = Vimeo::Advanced::Base.new("12345", "secret")
9
9
  end
10
-
11
- should "test something" do
12
- # TODO: add tests for authorization_url
13
- end
14
10
 
15
11
  should "allow camel-cased methods" do
12
+ stub_custom_get("/oauth/access_token", "advanced/auth/access_token.txt")
13
+ stub_post("", "advanced/auth/check_access_token.json")
14
+
16
15
  [:check_access_token, :checkAccessToken].each do |method|
17
16
  @base.send method
18
17
  end
data/vimeo.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{vimeo}
8
- s.version = "1.2.0"
8
+ s.version = "1.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Hooks"]
12
- s.date = %q{2010-07-20}
12
+ s.date = %q{2010-09-18}
13
13
  s.description = %q{A full featured Ruby implementation of the Vimeo API.}
14
14
  s.email = %q{matthooks@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -55,6 +55,7 @@ Gem::Specification.new do |s|
55
55
  "test/fixtures/advanced/album/set_description.json",
56
56
  "test/fixtures/advanced/album/set_password.json",
57
57
  "test/fixtures/advanced/album/set_title.json",
58
+ "test/fixtures/advanced/auth/access_token.txt",
58
59
  "test/fixtures/advanced/auth/check_access_token.json",
59
60
  "test/fixtures/advanced/auth/check_token.json",
60
61
  "test/fixtures/advanced/auth/get_frob.json",
@@ -220,27 +221,33 @@ Gem::Specification.new do |s|
220
221
  s.specification_version = 3
221
222
 
222
223
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
223
- s.add_development_dependency(%q<shoulda>, [">= 2.11.1"])
224
+ s.add_development_dependency(%q<shoulda>, [">= 2.11.3"])
224
225
  s.add_development_dependency(%q<fakeweb>, [">= 1.2.6"])
225
226
  s.add_development_dependency(%q<crack>, [">= 0.1.4"])
227
+ s.add_development_dependency(%q<ruby-prof>, [">= 0.9.2"])
226
228
  s.add_runtime_dependency(%q<httparty>, [">= 0.4.5"])
227
229
  s.add_runtime_dependency(%q<json>, [">= 1.1.9"])
228
230
  s.add_runtime_dependency(%q<oauth>, [">= 0.3.6"])
231
+ s.add_runtime_dependency(%q<httpclient>, [">= 2.1.5.2"])
229
232
  else
230
- s.add_dependency(%q<shoulda>, [">= 2.11.1"])
233
+ s.add_dependency(%q<shoulda>, [">= 2.11.3"])
231
234
  s.add_dependency(%q<fakeweb>, [">= 1.2.6"])
232
235
  s.add_dependency(%q<crack>, [">= 0.1.4"])
236
+ s.add_dependency(%q<ruby-prof>, [">= 0.9.2"])
233
237
  s.add_dependency(%q<httparty>, [">= 0.4.5"])
234
238
  s.add_dependency(%q<json>, [">= 1.1.9"])
235
239
  s.add_dependency(%q<oauth>, [">= 0.3.6"])
240
+ s.add_dependency(%q<httpclient>, [">= 2.1.5.2"])
236
241
  end
237
242
  else
238
- s.add_dependency(%q<shoulda>, [">= 2.11.1"])
243
+ s.add_dependency(%q<shoulda>, [">= 2.11.3"])
239
244
  s.add_dependency(%q<fakeweb>, [">= 1.2.6"])
240
245
  s.add_dependency(%q<crack>, [">= 0.1.4"])
246
+ s.add_dependency(%q<ruby-prof>, [">= 0.9.2"])
241
247
  s.add_dependency(%q<httparty>, [">= 0.4.5"])
242
248
  s.add_dependency(%q<json>, [">= 1.1.9"])
243
249
  s.add_dependency(%q<oauth>, [">= 0.3.6"])
250
+ s.add_dependency(%q<httpclient>, [">= 2.1.5.2"])
244
251
  end
245
252
  end
246
253
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimeo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 0
10
- version: 1.2.0
9
+ - 2
10
+ version: 1.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Hooks
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-20 00:00:00 -05:00
18
+ date: 2010-09-18 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 33
29
+ hash: 37
30
30
  segments:
31
31
  - 2
32
32
  - 11
33
- - 1
34
- version: 2.11.1
33
+ - 3
34
+ version: 2.11.3
35
35
  type: :development
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -67,9 +67,25 @@ dependencies:
67
67
  type: :development
68
68
  version_requirements: *id003
69
69
  - !ruby/object:Gem::Dependency
70
- name: httparty
70
+ name: ruby-prof
71
71
  prerelease: false
72
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 63
78
+ segments:
79
+ - 0
80
+ - 9
81
+ - 2
82
+ version: 0.9.2
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: httparty
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
73
89
  none: false
74
90
  requirements:
75
91
  - - ">="
@@ -81,11 +97,11 @@ dependencies:
81
97
  - 5
82
98
  version: 0.4.5
83
99
  type: :runtime
84
- version_requirements: *id004
100
+ version_requirements: *id005
85
101
  - !ruby/object:Gem::Dependency
86
102
  name: json
87
103
  prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
104
+ requirement: &id006 !ruby/object:Gem::Requirement
89
105
  none: false
90
106
  requirements:
91
107
  - - ">="
@@ -97,11 +113,11 @@ dependencies:
97
113
  - 9
98
114
  version: 1.1.9
99
115
  type: :runtime
100
- version_requirements: *id005
116
+ version_requirements: *id006
101
117
  - !ruby/object:Gem::Dependency
102
118
  name: oauth
103
119
  prerelease: false
104
- requirement: &id006 !ruby/object:Gem::Requirement
120
+ requirement: &id007 !ruby/object:Gem::Requirement
105
121
  none: false
106
122
  requirements:
107
123
  - - ">="
@@ -113,7 +129,24 @@ dependencies:
113
129
  - 6
114
130
  version: 0.3.6
115
131
  type: :runtime
116
- version_requirements: *id006
132
+ version_requirements: *id007
133
+ - !ruby/object:Gem::Dependency
134
+ name: httpclient
135
+ prerelease: false
136
+ requirement: &id008 !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ hash: 119
142
+ segments:
143
+ - 2
144
+ - 1
145
+ - 5
146
+ - 2
147
+ version: 2.1.5.2
148
+ type: :runtime
149
+ version_requirements: *id008
117
150
  description: A full featured Ruby implementation of the Vimeo API.
118
151
  email: matthooks@gmail.com
119
152
  executables: []
@@ -162,6 +195,7 @@ files:
162
195
  - test/fixtures/advanced/album/set_description.json
163
196
  - test/fixtures/advanced/album/set_password.json
164
197
  - test/fixtures/advanced/album/set_title.json
198
+ - test/fixtures/advanced/auth/access_token.txt
165
199
  - test/fixtures/advanced/auth/check_access_token.json
166
200
  - test/fixtures/advanced/auth/check_token.json
167
201
  - test/fixtures/advanced/auth/get_frob.json