instagram 0.3.2 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/.gitignore +12 -0
  2. data/.rspec +3 -0
  3. data/.yardopts +9 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE.md +20 -0
  6. data/README.md +144 -55
  7. data/Rakefile +21 -9
  8. data/instagram.gemspec +41 -0
  9. data/lib/faraday/oauth2.rb +36 -0
  10. data/lib/faraday/raise_http_4xx.rb +37 -0
  11. data/lib/faraday/raise_http_5xx.rb +29 -0
  12. data/lib/instagram.rb +21 -55
  13. data/lib/instagram/api.rb +23 -0
  14. data/lib/instagram/client.rb +19 -0
  15. data/lib/instagram/client/comments.rb +62 -0
  16. data/lib/instagram/client/likes.rb +58 -0
  17. data/lib/instagram/client/locations.rb +59 -0
  18. data/lib/instagram/client/media.rb +63 -0
  19. data/lib/instagram/client/real_time.rb +8 -0
  20. data/lib/instagram/client/subscriptions.rb +141 -0
  21. data/lib/instagram/client/tags.rb +59 -0
  22. data/lib/instagram/client/users.rb +165 -0
  23. data/lib/instagram/client/utils.rb +15 -0
  24. data/lib/instagram/configuration.rb +90 -0
  25. data/lib/instagram/connection.rb +31 -0
  26. data/lib/instagram/error.rb +16 -0
  27. data/lib/instagram/oauth.rb +27 -0
  28. data/lib/instagram/request.rb +45 -0
  29. data/lib/instagram/version.rb +3 -0
  30. data/spec/faraday/response_spec.rb +28 -0
  31. data/spec/fixtures/access_token.json +9 -0
  32. data/spec/fixtures/followed_by.json +1 -0
  33. data/spec/fixtures/follows.json +1 -0
  34. data/spec/fixtures/location.json +1 -0
  35. data/spec/fixtures/location_recent_media.json +1 -0
  36. data/spec/fixtures/location_search.json +1 -0
  37. data/spec/fixtures/media.json +1 -0
  38. data/spec/fixtures/media_comment.json +1 -0
  39. data/spec/fixtures/media_comment_deleted.json +1 -0
  40. data/spec/fixtures/media_comments.json +1 -0
  41. data/spec/fixtures/media_liked.json +1 -0
  42. data/spec/fixtures/media_likes.json +1 -0
  43. data/spec/fixtures/media_popular.json +1 -0
  44. data/spec/fixtures/media_search.json +1 -0
  45. data/spec/fixtures/media_unliked.json +1 -0
  46. data/spec/fixtures/mikeyk.json +1 -0
  47. data/spec/fixtures/recent_media.json +1 -0
  48. data/spec/fixtures/requested_by.json +12 -0
  49. data/spec/fixtures/shayne.json +1 -0
  50. data/spec/fixtures/subscription.json +12 -0
  51. data/spec/fixtures/subscription_deleted.json +1 -0
  52. data/spec/fixtures/subscription_payload.json +14 -0
  53. data/spec/fixtures/subscriptions.json +22 -0
  54. data/spec/fixtures/tag.json +1 -0
  55. data/spec/fixtures/tag_recent_media.json +1 -0
  56. data/spec/fixtures/tag_search.json +1 -0
  57. data/spec/fixtures/user_media_feed.json +1 -0
  58. data/spec/fixtures/user_search.json +1 -0
  59. data/spec/instagram/api_spec.rb +110 -0
  60. data/spec/instagram/client/comments_spec.rb +71 -0
  61. data/spec/instagram/client/likes_spec.rb +66 -0
  62. data/spec/instagram/client/locations_spec.rb +78 -0
  63. data/spec/instagram/client/media_spec.rb +78 -0
  64. data/spec/instagram/client/real_time_spec.rb +13 -0
  65. data/spec/instagram/client/subscriptions_spec.rb +118 -0
  66. data/spec/instagram/client/tags_spec.rb +78 -0
  67. data/spec/instagram/client/users_spec.rb +237 -0
  68. data/spec/instagram/client_spec.rb +23 -0
  69. data/spec/instagram_spec.rb +97 -0
  70. data/spec/spec_helper.rb +54 -0
  71. metadata +265 -33
  72. data/MIT-LICENSE +0 -18
  73. data/lib/instagram/cached.rb +0 -25
  74. data/lib/instagram/failsafe_store.rb +0 -52
  75. data/lib/instagram/models.rb +0 -163
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Instagram::Client do
4
+ it "should connect using the endpoint configuration" do
5
+ client = Instagram::Client.new
6
+ endpoint = URI.parse(client.endpoint)
7
+ connection = client.send(:connection).build_url(nil).to_s
8
+ connection.should == endpoint.to_s
9
+ end
10
+
11
+ it "should not cache the user account across clients" do
12
+ stub_get("users/self.json").
13
+ with(:query => {:access_token => "at1"}).
14
+ to_return(:body => fixture("shayne.json"), :headers => {:content_type => "application/json; charset=utf-8"})
15
+ client1 = Instagram::Client.new(:access_token => "at1")
16
+ client1.send(:get_username).should == "shayne"
17
+ stub_get("users/self.json").
18
+ with(:query => {:access_token => "at2"}).
19
+ to_return(:body => fixture("mikeyk.json"), :headers => {:content_type => "application/json; charset=utf-8"})
20
+ client2 = Instagram::Client.new(:access_token => "at2")
21
+ client2.send(:get_username).should == "mikeyk"
22
+ end
23
+ end
@@ -0,0 +1,97 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ describe Instagram do
4
+ after do
5
+ Instagram.reset
6
+ end
7
+
8
+ context "when delegating to a client" do
9
+
10
+ before do
11
+ stub_get("users/self/feed.json").
12
+ to_return(:body => fixture("user_media_feed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
13
+ end
14
+
15
+ it "should get the correct resource" do
16
+ Instagram.user_media_feed()
17
+ a_get("users/self/feed.json").
18
+ should have_been_made
19
+ end
20
+
21
+ it "should return the same results as a client" do
22
+ Instagram.user_media_feed().should == Instagram::Client.new.user_media_feed()
23
+ end
24
+
25
+ end
26
+
27
+ describe ".client" do
28
+ it "should be a Instagram::Client" do
29
+ Instagram.client.should be_a Instagram::Client
30
+ end
31
+ end
32
+
33
+ describe ".adapter" do
34
+ it "should return the default adapter" do
35
+ Instagram.adapter.should == Instagram::Configuration::DEFAULT_ADAPTER
36
+ end
37
+ end
38
+
39
+ describe ".adapter=" do
40
+ it "should set the adapter" do
41
+ Instagram.adapter = :typhoeus
42
+ Instagram.adapter.should == :typhoeus
43
+ end
44
+ end
45
+
46
+ describe ".endpoint" do
47
+ it "should return the default endpoint" do
48
+ Instagram.endpoint.should == Instagram::Configuration::DEFAULT_ENDPOINT
49
+ end
50
+ end
51
+
52
+ describe ".endpoint=" do
53
+ it "should set the endpoint" do
54
+ Instagram.endpoint = 'http://tumblr.com'
55
+ Instagram.endpoint.should == 'http://tumblr.com'
56
+ end
57
+ end
58
+
59
+ describe ".format" do
60
+ it "should return the default format" do
61
+ Instagram.format.should == Instagram::Configuration::DEFAULT_FORMAT
62
+ end
63
+ end
64
+
65
+ describe ".format=" do
66
+ it "should set the format" do
67
+ Instagram.format = 'xml'
68
+ Instagram.format.should == 'xml'
69
+ end
70
+ end
71
+
72
+ describe ".user_agent" do
73
+ it "should return the default user agent" do
74
+ Instagram.user_agent.should == Instagram::Configuration::DEFAULT_USER_AGENT
75
+ end
76
+ end
77
+
78
+ describe ".user_agent=" do
79
+ it "should set the user_agent" do
80
+ Instagram.user_agent = 'Custom User Agent'
81
+ Instagram.user_agent.should == 'Custom User Agent'
82
+ end
83
+ end
84
+
85
+ describe ".configure" do
86
+
87
+ Instagram::Configuration::VALID_OPTIONS_KEYS.each do |key|
88
+
89
+ it "should set the #{key}" do
90
+ Instagram.configure do |config|
91
+ config.send("#{key}=", key)
92
+ Instagram.send(key).should == key
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,54 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_group 'Instagram', 'lib/Instagram'
4
+ add_group 'Faraday Middleware', 'lib/faraday'
5
+ add_group 'Specs', 'spec'
6
+ end
7
+
8
+ require File.expand_path('../../lib/Instagram', __FILE__)
9
+
10
+ require 'rspec'
11
+ require 'webmock/rspec'
12
+ RSpec.configure do |config|
13
+ config.include WebMock::API
14
+ end
15
+
16
+ def a_delete(path)
17
+ a_request(:delete, Instagram.endpoint + path)
18
+ end
19
+
20
+ def a_get(path)
21
+ a_request(:get, Instagram.endpoint + path)
22
+ end
23
+
24
+ def a_post(path)
25
+ a_request(:post, Instagram.endpoint + path)
26
+ end
27
+
28
+ def a_put(path)
29
+ a_request(:put, Instagram.endpoint + path)
30
+ end
31
+
32
+ def stub_delete(path)
33
+ stub_request(:delete, Instagram.endpoint + path)
34
+ end
35
+
36
+ def stub_get(path)
37
+ stub_request(:get, Instagram.endpoint + path)
38
+ end
39
+
40
+ def stub_post(path)
41
+ stub_request(:post, Instagram.endpoint + path)
42
+ end
43
+
44
+ def stub_put(path)
45
+ stub_request(:put, Instagram.endpoint + path)
46
+ end
47
+
48
+ def fixture_path
49
+ File.expand_path("../fixtures", __FILE__)
50
+ end
51
+
52
+ def fixture(file)
53
+ File.new(fixture_path + '/' + file)
54
+ end
metadata CHANGED
@@ -4,62 +4,179 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
- - 2
9
- version: 0.3.2
7
+ - 6
8
+ version: "0.6"
10
9
  platform: ruby
11
10
  authors:
12
- - "Mislav Marohni\xC4\x87"
11
+ - Shayne Sweeney
13
12
  autorequire:
14
13
  bindir: bin
15
14
  cert_chain: []
16
15
 
17
- date: 2011-01-28 00:00:00 +01:00
16
+ date: 2011-02-24 00:00:00 -08:00
18
17
  default_executable:
19
18
  dependencies:
20
19
  - !ruby/object:Gem::Dependency
21
- name: addressable
20
+ name: bundler
22
21
  prerelease: false
23
22
  requirement: &id001 !ruby/object:Gem::Requirement
24
23
  none: false
25
24
  requirements:
26
- - - ">="
25
+ - - ~>
27
26
  - !ruby/object:Gem::Version
28
27
  segments:
28
+ - 1
29
29
  - 0
30
- version: "0"
31
- type: :runtime
30
+ version: "1.0"
31
+ type: :development
32
32
  version_requirements: *id001
33
33
  - !ruby/object:Gem::Dependency
34
- name: yajl-ruby
34
+ name: rake
35
35
  prerelease: false
36
36
  requirement: &id002 !ruby/object:Gem::Requirement
37
37
  none: false
38
38
  requirements:
39
- - - ">="
39
+ - - ~>
40
40
  - !ruby/object:Gem::Version
41
41
  segments:
42
42
  - 0
43
- version: "0"
44
- type: :runtime
43
+ - 8
44
+ version: "0.8"
45
+ type: :development
45
46
  version_requirements: *id002
46
47
  - !ruby/object:Gem::Dependency
47
- name: nibbler
48
+ name: rspec
48
49
  prerelease: false
49
50
  requirement: &id003 !ruby/object:Gem::Requirement
50
51
  none: false
51
52
  requirements:
52
- - - ">="
53
+ - - ~>
53
54
  - !ruby/object:Gem::Version
54
55
  segments:
55
- - 1
56
56
  - 2
57
+ - 4
58
+ version: "2.4"
59
+ type: :development
60
+ version_requirements: *id003
61
+ - !ruby/object:Gem::Dependency
62
+ name: yard
63
+ prerelease: false
64
+ requirement: &id004 !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ segments:
57
70
  - 0
58
- version: 1.2.0
71
+ - 6
72
+ version: "0.6"
73
+ type: :development
74
+ version_requirements: *id004
75
+ - !ruby/object:Gem::Dependency
76
+ name: simplecov
77
+ prerelease: false
78
+ requirement: &id005 !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ - 3
86
+ version: "0.3"
87
+ type: :development
88
+ version_requirements: *id005
89
+ - !ruby/object:Gem::Dependency
90
+ name: webmock
91
+ prerelease: false
92
+ requirement: &id006 !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ segments:
98
+ - 1
99
+ - 6
100
+ version: "1.6"
101
+ type: :development
102
+ version_requirements: *id006
103
+ - !ruby/object:Gem::Dependency
104
+ name: ZenTest
105
+ prerelease: false
106
+ requirement: &id007 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ~>
110
+ - !ruby/object:Gem::Version
111
+ segments:
112
+ - 4
113
+ - 4
114
+ version: "4.4"
115
+ type: :development
116
+ version_requirements: *id007
117
+ - !ruby/object:Gem::Dependency
118
+ name: faraday
119
+ prerelease: false
120
+ requirement: &id008 !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ segments:
126
+ - 0
127
+ - 5
128
+ - 4
129
+ version: 0.5.4
59
130
  type: :runtime
60
- version_requirements: *id003
61
- description: Ruby library for consuming the Instagram public API.
62
- email: mislav.marohnic@gmail.com
131
+ version_requirements: *id008
132
+ - !ruby/object:Gem::Dependency
133
+ name: faraday_middleware
134
+ prerelease: false
135
+ requirement: &id009 !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ~>
139
+ - !ruby/object:Gem::Version
140
+ segments:
141
+ - 0
142
+ - 3
143
+ - 1
144
+ version: 0.3.1
145
+ type: :runtime
146
+ version_requirements: *id009
147
+ - !ruby/object:Gem::Dependency
148
+ name: multi_json
149
+ prerelease: false
150
+ requirement: &id010 !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ~>
154
+ - !ruby/object:Gem::Version
155
+ segments:
156
+ - 0
157
+ - 0
158
+ - 5
159
+ version: 0.0.5
160
+ type: :runtime
161
+ version_requirements: *id010
162
+ - !ruby/object:Gem::Dependency
163
+ name: hashie
164
+ prerelease: false
165
+ requirement: &id011 !ruby/object:Gem::Requirement
166
+ none: false
167
+ requirements:
168
+ - - ~>
169
+ - !ruby/object:Gem::Version
170
+ segments:
171
+ - 1
172
+ - 0
173
+ - 0
174
+ version: 1.0.0
175
+ type: :runtime
176
+ version_requirements: *id011
177
+ description: A Ruby wrapper for the Instagram REST and Search APIs
178
+ email:
179
+ - shayne@instagr.am
63
180
  executables: []
64
181
 
65
182
  extensions: []
@@ -67,18 +184,91 @@ extensions: []
67
184
  extra_rdoc_files: []
68
185
 
69
186
  files:
187
+ - .gitignore
188
+ - .rspec
189
+ - .yardopts
190
+ - Gemfile
191
+ - LICENSE.md
192
+ - README.md
70
193
  - Rakefile
71
- - lib/instagram/cached.rb
72
- - lib/instagram/failsafe_store.rb
73
- - lib/instagram/models.rb
194
+ - instagram.gemspec
195
+ - lib/faraday/oauth2.rb
196
+ - lib/faraday/raise_http_4xx.rb
197
+ - lib/faraday/raise_http_5xx.rb
74
198
  - lib/instagram.rb
75
- - README.md
76
- - MIT-LICENSE
199
+ - lib/instagram/api.rb
200
+ - lib/instagram/client.rb
201
+ - lib/instagram/client/comments.rb
202
+ - lib/instagram/client/likes.rb
203
+ - lib/instagram/client/locations.rb
204
+ - lib/instagram/client/media.rb
205
+ - lib/instagram/client/real_time.rb
206
+ - lib/instagram/client/subscriptions.rb
207
+ - lib/instagram/client/tags.rb
208
+ - lib/instagram/client/users.rb
209
+ - lib/instagram/client/utils.rb
210
+ - lib/instagram/configuration.rb
211
+ - lib/instagram/connection.rb
212
+ - lib/instagram/error.rb
213
+ - lib/instagram/oauth.rb
214
+ - lib/instagram/request.rb
215
+ - lib/instagram/version.rb
216
+ - spec/faraday/response_spec.rb
217
+ - spec/fixtures/access_token.json
218
+ - spec/fixtures/followed_by.json
219
+ - spec/fixtures/follows.json
220
+ - spec/fixtures/location.json
221
+ - spec/fixtures/location_recent_media.json
222
+ - spec/fixtures/location_search.json
223
+ - spec/fixtures/media.json
224
+ - spec/fixtures/media_comment.json
225
+ - spec/fixtures/media_comment_deleted.json
226
+ - spec/fixtures/media_comments.json
227
+ - spec/fixtures/media_liked.json
228
+ - spec/fixtures/media_likes.json
229
+ - spec/fixtures/media_popular.json
230
+ - spec/fixtures/media_search.json
231
+ - spec/fixtures/media_unliked.json
232
+ - spec/fixtures/mikeyk.json
233
+ - spec/fixtures/recent_media.json
234
+ - spec/fixtures/requested_by.json
235
+ - spec/fixtures/shayne.json
236
+ - spec/fixtures/subscription.json
237
+ - spec/fixtures/subscription_deleted.json
238
+ - spec/fixtures/subscription_payload.json
239
+ - spec/fixtures/subscriptions.json
240
+ - spec/fixtures/tag.json
241
+ - spec/fixtures/tag_recent_media.json
242
+ - spec/fixtures/tag_search.json
243
+ - spec/fixtures/user_media_feed.json
244
+ - spec/fixtures/user_search.json
245
+ - spec/instagram/api_spec.rb
246
+ - spec/instagram/client/comments_spec.rb
247
+ - spec/instagram/client/likes_spec.rb
248
+ - spec/instagram/client/locations_spec.rb
249
+ - spec/instagram/client/media_spec.rb
250
+ - spec/instagram/client/real_time_spec.rb
251
+ - spec/instagram/client/subscriptions_spec.rb
252
+ - spec/instagram/client/tags_spec.rb
253
+ - spec/instagram/client/users_spec.rb
254
+ - spec/instagram/client_spec.rb
255
+ - spec/instagram_spec.rb
256
+ - spec/spec_helper.rb
77
257
  has_rdoc: true
78
- homepage: http://github.com/mislav/instagram
258
+ homepage: https://github.com/Instagram/instagramrb
79
259
  licenses: []
80
260
 
81
- post_install_message:
261
+ post_install_message: |
262
+ ********************************************************************************
263
+
264
+ Follow @instagram on Twitter for announcements, updates, and news.
265
+ https://twitter.com/instagramapi
266
+
267
+ Join the mailing list!
268
+ https://groups.google.com/group/instagram-ruby-gem
269
+
270
+ ********************************************************************************
271
+
82
272
  rdoc_options: []
83
273
 
84
274
  require_paths:
@@ -97,14 +287,56 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
287
  - - ">="
98
288
  - !ruby/object:Gem::Version
99
289
  segments:
100
- - 0
101
- version: "0"
290
+ - 1
291
+ - 3
292
+ - 6
293
+ version: 1.3.6
102
294
  requirements: []
103
295
 
104
- rubyforge_project:
296
+ rubyforge_project: instagram
105
297
  rubygems_version: 1.3.7
106
298
  signing_key:
107
299
  specification_version: 3
108
- summary: Instagram API client
109
- test_files: []
110
-
300
+ summary: Ruby wrapper for the Instagram API
301
+ test_files:
302
+ - spec/faraday/response_spec.rb
303
+ - spec/fixtures/access_token.json
304
+ - spec/fixtures/followed_by.json
305
+ - spec/fixtures/follows.json
306
+ - spec/fixtures/location.json
307
+ - spec/fixtures/location_recent_media.json
308
+ - spec/fixtures/location_search.json
309
+ - spec/fixtures/media.json
310
+ - spec/fixtures/media_comment.json
311
+ - spec/fixtures/media_comment_deleted.json
312
+ - spec/fixtures/media_comments.json
313
+ - spec/fixtures/media_liked.json
314
+ - spec/fixtures/media_likes.json
315
+ - spec/fixtures/media_popular.json
316
+ - spec/fixtures/media_search.json
317
+ - spec/fixtures/media_unliked.json
318
+ - spec/fixtures/mikeyk.json
319
+ - spec/fixtures/recent_media.json
320
+ - spec/fixtures/requested_by.json
321
+ - spec/fixtures/shayne.json
322
+ - spec/fixtures/subscription.json
323
+ - spec/fixtures/subscription_deleted.json
324
+ - spec/fixtures/subscription_payload.json
325
+ - spec/fixtures/subscriptions.json
326
+ - spec/fixtures/tag.json
327
+ - spec/fixtures/tag_recent_media.json
328
+ - spec/fixtures/tag_search.json
329
+ - spec/fixtures/user_media_feed.json
330
+ - spec/fixtures/user_search.json
331
+ - spec/instagram/api_spec.rb
332
+ - spec/instagram/client/comments_spec.rb
333
+ - spec/instagram/client/likes_spec.rb
334
+ - spec/instagram/client/locations_spec.rb
335
+ - spec/instagram/client/media_spec.rb
336
+ - spec/instagram/client/real_time_spec.rb
337
+ - spec/instagram/client/subscriptions_spec.rb
338
+ - spec/instagram/client/tags_spec.rb
339
+ - spec/instagram/client/users_spec.rb
340
+ - spec/instagram/client_spec.rb
341
+ - spec/instagram_spec.rb
342
+ - spec/spec_helper.rb