flickr_oauth 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/README.md +14 -0
  2. data/flickr_oauth.gemspec +3 -1
  3. data/lib/flickr.rb +188 -1
  4. data/lib/flickr/client.rb +17 -46
  5. data/lib/flickr/client/authentication.rb +17 -0
  6. data/lib/flickr/client/connection.rb +44 -0
  7. data/lib/flickr/client/requests.rb +69 -0
  8. data/lib/flickr/client/upload.rb +22 -0
  9. data/lib/flickr/node.rb +2 -28
  10. data/lib/flickr_oauth/version.rb +1 -1
  11. data/spec/.DS_Store +0 -0
  12. data/spec/fixtures/.DS_Store +0 -0
  13. data/spec/fixtures/cassettes/.DS_Store +0 -0
  14. data/spec/fixtures/cassettes/flickr_reflection_getMethodInfo/_format_json.yml +133 -0
  15. data/spec/fixtures/cassettes/flickr_reflection_getMethodInfo/_format_rest.yml +133 -0
  16. data/spec/fixtures/cassettes/flickr_reflection_getMethods/.yml +65 -0
  17. data/spec/fixtures/cassettes/flickr_reflection_getMethods/_format_json.yml +65 -0
  18. data/spec/fixtures/cassettes/flickr_reflection_getMethods/_format_rest.yml +64 -0
  19. data/spec/fixtures/cassettes/{JSON_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/with_oauth_token.yml → flickr_test_echo/_format_json.yml} +12 -12
  20. data/spec/fixtures/cassettes/{REST_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/with_oauth_token.yml → flickr_test_echo/_format_rest.yml} +13 -13
  21. data/spec/fixtures/cassettes/flickr_upload.yml +1798 -0
  22. data/spec/fixtures/test.jpg +0 -0
  23. data/spec/fixtures/test_2.jpg +0 -0
  24. data/spec/flickr/reflection/getMethodInfo_spec.rb +73 -0
  25. data/spec/flickr/reflection/getMethods_spec.rb +53 -0
  26. data/spec/flickr/test/echo_spec.rb +51 -0
  27. data/spec/flickr/upload_spec.rb +33 -0
  28. data/spec/spec_helper.rb +4 -5
  29. metadata +70 -25
  30. data/spec/fixtures/cassettes/JSON_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/no_oauth_token.yml +0 -40
  31. data/spec/fixtures/cassettes/REST_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/no_oauth_token.yml +0 -39
  32. data/spec/json/flickr_spec.rb +0 -6
  33. data/spec/rest/flickr_spec.rb +0 -6
  34. data/spec/shared_examples.rb +0 -65
Binary file
Binary file
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe flickr.reflection.getMethodInfo do
4
+ let(:method_name) { 'flickr.photos.search' }
5
+
6
+ context ':format => :json' do
7
+ use_vcr_cassette
8
+
9
+ context ':normalize => false' do
10
+ let(:result) { flickr.reflection.getMethodInfo({:method_name => method_name, :format => 'json'}.merge(oauth_options)) }
11
+
12
+ it 'returns raw method information' do
13
+ result['method']['name'].should be_a(String)
14
+ result['method']['description']['_content'].should be_a(String)
15
+ end
16
+
17
+ it 'returns raw method arguments information' do
18
+ result['arguments']['argument'].should be_an(Array)
19
+ result['arguments']['argument'].each do |argument|
20
+ argument['name'].should be_a(String)
21
+ argument['_content'].should be_a(String)
22
+ end
23
+ end
24
+
25
+ it 'returns raw method errors information' do
26
+ result['errors']['error'].should be_an(Array)
27
+ result['errors']['error'].each do |error|
28
+ error['message'].should be_a(String)
29
+ error['_content'].should be_a(String)
30
+ end
31
+ end
32
+ end
33
+
34
+ context ':normalize => true' do
35
+ let(:result) { flickr.reflection.getMethodInfo({:method_name => method_name, :format => 'json', :normalize => true}.merge(oauth_options)) }
36
+
37
+ it 'returns normalized method information' do
38
+ result['method']['name'].should be_a(String)
39
+ result['method']['description'].should be_a(String)
40
+ end
41
+ end
42
+ end
43
+
44
+ context ':format => :rest' do
45
+ use_vcr_cassette
46
+
47
+ context ':normalize => false' do
48
+ let(:result) { flickr.reflection.getMethodInfo({:method_name => method_name, :format => 'rest'}.merge(oauth_options)) }
49
+
50
+ it 'returns raw method information' do
51
+ result['rsp']['method']['name'].should be_a(String)
52
+ result['rsp']['method']['description'].should be_a(String)
53
+ end
54
+
55
+ it 'returns raw method arguments information' do
56
+ result['rsp']['arguments']['argument'].should be_an(Array)
57
+ end
58
+
59
+ it 'returns raw method errors information' do
60
+ result['rsp']['errors']['error'].should be_an(Array)
61
+ end
62
+ end
63
+
64
+ context ':normalize => true' do
65
+ let(:result) { flickr.reflection.getMethodInfo({:method_name => method_name, :format => 'rest', :normalize => true}.merge(oauth_options)) }
66
+
67
+ it 'returns normalized method information' do
68
+ result['method']['name'].should be_a(String)
69
+ result['method']['description'].should be_a(String)
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ describe flickr.reflection.getMethods do
5
+ context ':format => :json' do
6
+ use_vcr_cassette
7
+
8
+ context ':normalize => false' do
9
+ let(:result) { flickr.reflection.getMethods({:format => 'json'}.merge(oauth_options)) }
10
+
11
+ it 'returns all Flickr API methods in raw Flickr JSON format' do
12
+ result['methods']['method'].each do |method|
13
+ Flickr::METHODS.should include(method['_content'])
14
+ end
15
+ end
16
+ end
17
+
18
+ context ':normalize => true' do
19
+ let(:result) { flickr.reflection.getMethods({:format => 'json', :normalize => true}.merge(oauth_options)) }
20
+
21
+ it 'returns all Flickr API methods in normalized JSON format' do
22
+ result['methods']['method'].each do |method|
23
+ Flickr::METHODS.should include(method)
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ context ':format => :rest' do
30
+ use_vcr_cassette
31
+
32
+ context ':normalize => false' do
33
+ let(:result) { flickr.reflection.getMethods({:format => 'rest'}.merge(oauth_options)) }
34
+
35
+ it 'returns all Flickr API methods in raw Flickr REST format' do
36
+ result['rsp']['methods']['method'].each do |method|
37
+ Flickr::METHODS.should include(method)
38
+ end
39
+ end
40
+ end
41
+
42
+ context ':normalize => true' do
43
+ let(:result) { flickr.reflection.getMethods({:format => 'rest', :normalize => true}.merge(oauth_options)) }
44
+
45
+ it 'returns all Flickr API methods in normalized REST format' do
46
+ result['methods']['method'].each do |method|
47
+ Flickr::METHODS.should include(method)
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe flickr.test.echo do
4
+ context ':format => :json' do
5
+ use_vcr_cassette
6
+
7
+ context ':normalize => false' do
8
+ let(:result) { flickr.test.echo({:foo => 'bar', :format => 'json'}.merge(oauth_options)) }
9
+
10
+ it 'responds with the original request parameters' do
11
+ result['method']['_content'].should == 'flickr.test.echo'
12
+ result['foo']['_content'].should == 'bar'
13
+ result['format']['_content'].should == 'json'
14
+ end
15
+ end
16
+
17
+ context ':normalize => true' do
18
+ let(:result) { flickr.test.echo({:foo => 'bar', :format => 'json', :normalize => true}.merge(oauth_options)) }
19
+
20
+ it 'responds with the original request parameters' do
21
+ result['method'].should == 'flickr.test.echo'
22
+ result['foo'].should == 'bar'
23
+ result['format'].should == 'json'
24
+ end
25
+ end
26
+ end
27
+
28
+ context ':format => :rest' do
29
+ use_vcr_cassette
30
+
31
+ context ':normalize => false' do
32
+ let(:result) { flickr.test.echo({:foo => 'bar', :format => 'rest'}.merge(oauth_options)) }
33
+
34
+ it 'responds with the original request parameters' do
35
+ result['rsp']['method'].should == 'flickr.test.echo'
36
+ result['rsp']['foo'].should == 'bar'
37
+ result['rsp']['format'].should == 'rest'
38
+ end
39
+ end
40
+
41
+ context ':normalize => true' do
42
+ let(:result) { flickr.test.echo({:foo => 'bar', :format => 'rest', :normalize => true}.merge(oauth_options)) }
43
+
44
+ it 'responds with the original request parameters' do
45
+ result['method'].should == 'flickr.test.echo'
46
+ result['foo'].should == 'bar'
47
+ result['format'].should == 'rest'
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'flickr.upload' do
4
+ let(:image_path) { File.expand_path('../../fixtures/test.jpg', __FILE__) }
5
+ let(:image_info) { { :title => 'test upload', :description => 'this is an image for testing flickr uploads', :tags => 'test upload' } }
6
+
7
+ use_vcr_cassette
8
+
9
+ context ':normalize => true' do
10
+ let(:result) { flickr.upload(image_path, {:normalize => true}.merge(image_info).merge(oauth_options)) }
11
+
12
+ it 'returns the uploaded image\'s Flickr photo ID' do
13
+ result['photoid'].should =~ %r(\d)
14
+ end
15
+
16
+ describe 'photo' do
17
+ let(:photo) { flickr.photos.getInfo({ :photo_id => result['photoid'], :normalize => true }.merge(oauth_options)) }
18
+
19
+ it 'has a title' do
20
+ photo['photo']['title'].should == image_info[:title]
21
+ end
22
+
23
+ it 'has a description' do
24
+ photo['photo']['description'].should == image_info[:description]
25
+ end
26
+
27
+ it 'has tags' do
28
+ photo['photo']['tags']['tag'].join(" ").should == image_info[:tags]
29
+ end
30
+ end
31
+ end
32
+
33
+ end
data/spec/spec_helper.rb CHANGED
@@ -20,15 +20,14 @@ RSpec.configure do |config|
20
20
  config.mock_with :rspec
21
21
  end
22
22
 
23
- require 'shared_examples'
24
-
25
23
  def oauth_options
26
24
  {
27
- :consumer_key => '',
25
+ :consumer_key => '',
28
26
  :consumer_secret => '',
29
- :token => '',
30
- :token_secret => '',
27
+ :token => '',
28
+ :token_secret => ''
31
29
  }
32
30
  end
33
31
 
32
+ # require 'oauth_keys'
34
33
  # flickr.enable_logging = true # watch the magic come alive!
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: flickr_oauth
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Evan Sagge
@@ -10,7 +10,7 @@ autorequire: flickr
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-30 00:00:00 Z
13
+ date: 2011-07-06 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -35,7 +35,7 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id002
37
37
  - !ruby/object:Gem::Dependency
38
- name: multi_xml
38
+ name: mime-types
39
39
  prerelease: false
40
40
  requirement: &id003 !ruby/object:Gem::Requirement
41
41
  none: false
@@ -46,7 +46,7 @@ dependencies:
46
46
  type: :runtime
47
47
  version_requirements: *id003
48
48
  - !ruby/object:Gem::Dependency
49
- name: multi_json
49
+ name: multipart-post
50
50
  prerelease: false
51
51
  requirement: &id004 !ruby/object:Gem::Requirement
52
52
  none: false
@@ -57,7 +57,7 @@ dependencies:
57
57
  type: :runtime
58
58
  version_requirements: *id004
59
59
  - !ruby/object:Gem::Dependency
60
- name: simple_oauth
60
+ name: multi_json
61
61
  prerelease: false
62
62
  requirement: &id005 !ruby/object:Gem::Requirement
63
63
  none: false
@@ -68,38 +68,60 @@ dependencies:
68
68
  type: :runtime
69
69
  version_requirements: *id005
70
70
  - !ruby/object:Gem::Dependency
71
- name: rspec
71
+ name: multi_xml
72
72
  prerelease: false
73
73
  requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :runtime
80
+ version_requirements: *id006
81
+ - !ruby/object:Gem::Dependency
82
+ name: simple_oauth
83
+ prerelease: false
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ type: :runtime
91
+ version_requirements: *id007
92
+ - !ruby/object:Gem::Dependency
93
+ name: rspec
94
+ prerelease: false
95
+ requirement: &id008 !ruby/object:Gem::Requirement
74
96
  none: false
75
97
  requirements:
76
98
  - - ">="
77
99
  - !ruby/object:Gem::Version
78
100
  version: "2.6"
79
101
  type: :development
80
- version_requirements: *id006
102
+ version_requirements: *id008
81
103
  - !ruby/object:Gem::Dependency
82
104
  name: webmock
83
105
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
106
+ requirement: &id009 !ruby/object:Gem::Requirement
85
107
  none: false
86
108
  requirements:
87
109
  - - ">="
88
110
  - !ruby/object:Gem::Version
89
111
  version: "1.6"
90
112
  type: :development
91
- version_requirements: *id007
113
+ version_requirements: *id009
92
114
  - !ruby/object:Gem::Dependency
93
115
  name: vcr
94
116
  prerelease: false
95
- requirement: &id008 !ruby/object:Gem::Requirement
117
+ requirement: &id010 !ruby/object:Gem::Requirement
96
118
  none: false
97
119
  requirements:
98
120
  - - ">="
99
121
  - !ruby/object:Gem::Version
100
122
  version: "1.7"
101
123
  type: :development
102
- version_requirements: *id008
124
+ version_requirements: *id010
103
125
  description: ""
104
126
  email:
105
127
  - evansagge@gmail.com
@@ -119,17 +141,31 @@ files:
119
141
  - lib/faraday/response/raise_flickr_error.rb
120
142
  - lib/flickr.rb
121
143
  - lib/flickr/client.rb
144
+ - lib/flickr/client/authentication.rb
145
+ - lib/flickr/client/connection.rb
146
+ - lib/flickr/client/requests.rb
147
+ - lib/flickr/client/upload.rb
122
148
  - lib/flickr/error.rb
123
149
  - lib/flickr/node.rb
124
150
  - lib/flickr_oauth.rb
125
151
  - lib/flickr_oauth/version.rb
126
- - spec/fixtures/cassettes/JSON_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/no_oauth_token.yml
127
- - spec/fixtures/cassettes/JSON_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/with_oauth_token.yml
128
- - spec/fixtures/cassettes/REST_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/no_oauth_token.yml
129
- - spec/fixtures/cassettes/REST_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/with_oauth_token.yml
130
- - spec/json/flickr_spec.rb
131
- - spec/rest/flickr_spec.rb
132
- - spec/shared_examples.rb
152
+ - spec/.DS_Store
153
+ - spec/fixtures/.DS_Store
154
+ - spec/fixtures/cassettes/.DS_Store
155
+ - spec/fixtures/cassettes/flickr_reflection_getMethodInfo/_format_json.yml
156
+ - spec/fixtures/cassettes/flickr_reflection_getMethodInfo/_format_rest.yml
157
+ - spec/fixtures/cassettes/flickr_reflection_getMethods/.yml
158
+ - spec/fixtures/cassettes/flickr_reflection_getMethods/_format_json.yml
159
+ - spec/fixtures/cassettes/flickr_reflection_getMethods/_format_rest.yml
160
+ - spec/fixtures/cassettes/flickr_test_echo/_format_json.yml
161
+ - spec/fixtures/cassettes/flickr_test_echo/_format_rest.yml
162
+ - spec/fixtures/cassettes/flickr_upload.yml
163
+ - spec/fixtures/test.jpg
164
+ - spec/fixtures/test_2.jpg
165
+ - spec/flickr/reflection/getMethodInfo_spec.rb
166
+ - spec/flickr/reflection/getMethods_spec.rb
167
+ - spec/flickr/test/echo_spec.rb
168
+ - spec/flickr/upload_spec.rb
133
169
  - spec/spec_helper.rb
134
170
  homepage: http://github.com/evansagge/flickr_oauth
135
171
  licenses: []
@@ -159,11 +195,20 @@ signing_key:
159
195
  specification_version: 3
160
196
  summary: Flickr API adapter using OAuth
161
197
  test_files:
162
- - spec/fixtures/cassettes/JSON_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/no_oauth_token.yml
163
- - spec/fixtures/cassettes/JSON_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/with_oauth_token.yml
164
- - spec/fixtures/cassettes/REST_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/no_oauth_token.yml
165
- - spec/fixtures/cassettes/REST_format/it_should_behave_like_Flickr_with_specified_format/Flickr/flickr_test_echo/with_oauth_token.yml
166
- - spec/json/flickr_spec.rb
167
- - spec/rest/flickr_spec.rb
168
- - spec/shared_examples.rb
198
+ - spec/fixtures/.DS_Store
199
+ - spec/fixtures/cassettes/.DS_Store
200
+ - spec/fixtures/cassettes/flickr_reflection_getMethodInfo/_format_json.yml
201
+ - spec/fixtures/cassettes/flickr_reflection_getMethodInfo/_format_rest.yml
202
+ - spec/fixtures/cassettes/flickr_reflection_getMethods/.yml
203
+ - spec/fixtures/cassettes/flickr_reflection_getMethods/_format_json.yml
204
+ - spec/fixtures/cassettes/flickr_reflection_getMethods/_format_rest.yml
205
+ - spec/fixtures/cassettes/flickr_test_echo/_format_json.yml
206
+ - spec/fixtures/cassettes/flickr_test_echo/_format_rest.yml
207
+ - spec/fixtures/cassettes/flickr_upload.yml
208
+ - spec/fixtures/test.jpg
209
+ - spec/fixtures/test_2.jpg
210
+ - spec/flickr/reflection/getMethodInfo_spec.rb
211
+ - spec/flickr/reflection/getMethods_spec.rb
212
+ - spec/flickr/test/echo_spec.rb
213
+ - spec/flickr/upload_spec.rb
169
214
  - spec/spec_helper.rb
@@ -1,40 +0,0 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
4
- method: :get
5
- uri: http://api.flickr.com:80/services/rest?foo=bar&format=json&method=flickr.test.echo&nojsoncallback=1
6
- body:
7
- headers:
8
- authorization:
9
- - OAuth oauth_consumer_key="", oauth_nonce="beff09eaac9ae76f7e8494a19602b8cc", oauth_signature="9CcsMhPiC0Qz7TqOb3m11yYUJ%2Fs%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1309463375", oauth_token="", oauth_version="1.0"
10
- accept-encoding:
11
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
- response: !ruby/struct:VCR::Response
13
- status: !ruby/struct:VCR::ResponseStatus
14
- code: 200
15
- message: OK
16
- headers:
17
- date:
18
- - Thu, 30 Jun 2011 19:49:36 GMT
19
- p3p:
20
- - policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
21
- access-control-allow-origin:
22
- - "*"
23
- x-served-by:
24
- - www136.flickr.mud.yahoo.com
25
- cache-control:
26
- - private
27
- vary:
28
- - Accept-Encoding
29
- content-encoding:
30
- - gzip
31
- content-length:
32
- - "91"
33
- content-type:
34
- - text/plain; charset=utf-8
35
- body: !binary |
36
- H4sIAAAAAAAAA6tWKi5JLFGyUkpLzMxR0lFQSs5PSVWyMjQwALJzU4uLE9OB
37
- XCXPvLLEnMwUBccATwXv1EoFDRCRkViskAmVSMsvyk0s0VSqBQC/jELiUQAA
38
- AA==
39
-
40
- http_version: "1.1"