instagram-innonate 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) 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 -0
  7. data/Rakefile +27 -0
  8. data/instagram.gemspec +26 -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 +26 -0
  13. data/lib/instagram/api.rb +23 -0
  14. data/lib/instagram/client.rb +20 -0
  15. data/lib/instagram/client/comments.rb +62 -0
  16. data/lib/instagram/client/geographies.rb +29 -0
  17. data/lib/instagram/client/likes.rb +58 -0
  18. data/lib/instagram/client/locations.rb +59 -0
  19. data/lib/instagram/client/media.rb +63 -0
  20. data/lib/instagram/client/subscriptions.rb +157 -0
  21. data/lib/instagram/client/tags.rb +59 -0
  22. data/lib/instagram/client/users.rb +309 -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 +19 -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/approve_user.json +8 -0
  33. data/spec/fixtures/block_user.json +8 -0
  34. data/spec/fixtures/deny_user.json +8 -0
  35. data/spec/fixtures/follow_user.json +8 -0
  36. data/spec/fixtures/followed_by.json +1 -0
  37. data/spec/fixtures/follows.json +1 -0
  38. data/spec/fixtures/geography_recent_media.json +1 -0
  39. data/spec/fixtures/liked_media.json +1 -0
  40. data/spec/fixtures/location.json +1 -0
  41. data/spec/fixtures/location_recent_media.json +1 -0
  42. data/spec/fixtures/location_search.json +1 -0
  43. data/spec/fixtures/media.json +1 -0
  44. data/spec/fixtures/media_comment.json +1 -0
  45. data/spec/fixtures/media_comment_deleted.json +1 -0
  46. data/spec/fixtures/media_comments.json +1 -0
  47. data/spec/fixtures/media_liked.json +1 -0
  48. data/spec/fixtures/media_likes.json +1 -0
  49. data/spec/fixtures/media_popular.json +1 -0
  50. data/spec/fixtures/media_search.json +1 -0
  51. data/spec/fixtures/media_unliked.json +1 -0
  52. data/spec/fixtures/mikeyk.json +1 -0
  53. data/spec/fixtures/recent_media.json +1 -0
  54. data/spec/fixtures/relationship.json +9 -0
  55. data/spec/fixtures/requested_by.json +12 -0
  56. data/spec/fixtures/shayne.json +1 -0
  57. data/spec/fixtures/subscription.json +12 -0
  58. data/spec/fixtures/subscription_deleted.json +1 -0
  59. data/spec/fixtures/subscription_payload.json +14 -0
  60. data/spec/fixtures/subscriptions.json +22 -0
  61. data/spec/fixtures/tag.json +1 -0
  62. data/spec/fixtures/tag_recent_media.json +1 -0
  63. data/spec/fixtures/tag_search.json +1 -0
  64. data/spec/fixtures/unblock_user.json +8 -0
  65. data/spec/fixtures/unfollow_user.json +8 -0
  66. data/spec/fixtures/user_media_feed.json +1 -0
  67. data/spec/fixtures/user_search.json +1 -0
  68. data/spec/instagram/api_spec.rb +110 -0
  69. data/spec/instagram/client/comments_spec.rb +71 -0
  70. data/spec/instagram/client/geography_spec.rb +37 -0
  71. data/spec/instagram/client/likes_spec.rb +66 -0
  72. data/spec/instagram/client/locations_spec.rb +78 -0
  73. data/spec/instagram/client/media_spec.rb +78 -0
  74. data/spec/instagram/client/subscriptions_spec.rb +148 -0
  75. data/spec/instagram/client/tags_spec.rb +78 -0
  76. data/spec/instagram/client/users_spec.rb +400 -0
  77. data/spec/instagram/client_spec.rb +23 -0
  78. data/spec/instagram_spec.rb +97 -0
  79. data/spec/spec_helper.rb +59 -0
  80. metadata +303 -0
@@ -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,59 @@
1
+ begin
2
+ require 'simplecov'
3
+ rescue LoadError
4
+ # ignore
5
+ else
6
+ SimpleCov.start do
7
+ add_group 'Instagram', 'lib/instagram'
8
+ add_group 'Faraday Middleware', 'lib/faraday'
9
+ add_group 'Specs', 'spec'
10
+ end
11
+ end
12
+
13
+ require File.expand_path('../../lib/instagram', __FILE__)
14
+
15
+ require 'rspec'
16
+ require 'webmock/rspec'
17
+ RSpec.configure do |config|
18
+ config.include WebMock::API
19
+ end
20
+
21
+ def a_delete(path)
22
+ a_request(:delete, Instagram.endpoint + path)
23
+ end
24
+
25
+ def a_get(path)
26
+ a_request(:get, Instagram.endpoint + path)
27
+ end
28
+
29
+ def a_post(path)
30
+ a_request(:post, Instagram.endpoint + path)
31
+ end
32
+
33
+ def a_put(path)
34
+ a_request(:put, Instagram.endpoint + path)
35
+ end
36
+
37
+ def stub_delete(path)
38
+ stub_request(:delete, Instagram.endpoint + path)
39
+ end
40
+
41
+ def stub_get(path)
42
+ stub_request(:get, Instagram.endpoint + path)
43
+ end
44
+
45
+ def stub_post(path)
46
+ stub_request(:post, Instagram.endpoint + path)
47
+ end
48
+
49
+ def stub_put(path)
50
+ stub_request(:put, Instagram.endpoint + path)
51
+ end
52
+
53
+ def fixture_path
54
+ File.expand_path("../fixtures", __FILE__)
55
+ end
56
+
57
+ def fixture(file)
58
+ File.new(fixture_path + '/' + file)
59
+ end
metadata ADDED
@@ -0,0 +1,303 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: instagram-innonate
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 8
9
+ version: "0.8"
10
+ platform: ruby
11
+ authors:
12
+ - Shayne Sweeney, Nate Westheimer
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-09-15 00:00:00 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: rspec
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ hash: 11
28
+ segments:
29
+ - 2
30
+ - 4
31
+ version: "2.4"
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: webmock
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 1
45
+ - 6
46
+ version: "1.6"
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: bluecloth
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ hash: 25
58
+ segments:
59
+ - 2
60
+ - 0
61
+ - 11
62
+ version: 2.0.11
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: faraday
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ - 5
77
+ - 4
78
+ version: 0.5.4
79
+ type: :runtime
80
+ version_requirements: *id004
81
+ - !ruby/object:Gem::Dependency
82
+ name: faraday_middleware
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 17
90
+ segments:
91
+ - 0
92
+ - 3
93
+ - 1
94
+ version: 0.3.1
95
+ type: :runtime
96
+ version_requirements: *id005
97
+ - !ruby/object:Gem::Dependency
98
+ name: multi_json
99
+ prerelease: false
100
+ requirement: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 21
106
+ segments:
107
+ - 0
108
+ - 0
109
+ - 5
110
+ version: 0.0.5
111
+ type: :runtime
112
+ version_requirements: *id006
113
+ - !ruby/object:Gem::Dependency
114
+ name: hashie
115
+ prerelease: false
116
+ requirement: &id007 !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ hash: 15
122
+ segments:
123
+ - 0
124
+ - 4
125
+ - 0
126
+ version: 0.4.0
127
+ type: :runtime
128
+ version_requirements: *id007
129
+ description: A Ruby wrapper for the Instagram REST and Search APIs - adapted poorly but workingly by innonate.
130
+ email:
131
+ - nate@innonate.com
132
+ executables: []
133
+
134
+ extensions: []
135
+
136
+ extra_rdoc_files: []
137
+
138
+ files:
139
+ - .gitignore
140
+ - .rspec
141
+ - .yardopts
142
+ - Gemfile
143
+ - LICENSE.md
144
+ - README.md
145
+ - Rakefile
146
+ - instagram.gemspec
147
+ - lib/faraday/oauth2.rb
148
+ - lib/faraday/raise_http_4xx.rb
149
+ - lib/faraday/raise_http_5xx.rb
150
+ - lib/instagram.rb
151
+ - lib/instagram/api.rb
152
+ - lib/instagram/client.rb
153
+ - lib/instagram/client/comments.rb
154
+ - lib/instagram/client/geographies.rb
155
+ - lib/instagram/client/likes.rb
156
+ - lib/instagram/client/locations.rb
157
+ - lib/instagram/client/media.rb
158
+ - lib/instagram/client/subscriptions.rb
159
+ - lib/instagram/client/tags.rb
160
+ - lib/instagram/client/users.rb
161
+ - lib/instagram/client/utils.rb
162
+ - lib/instagram/configuration.rb
163
+ - lib/instagram/connection.rb
164
+ - lib/instagram/error.rb
165
+ - lib/instagram/oauth.rb
166
+ - lib/instagram/request.rb
167
+ - lib/instagram/version.rb
168
+ - spec/faraday/response_spec.rb
169
+ - spec/fixtures/access_token.json
170
+ - spec/fixtures/approve_user.json
171
+ - spec/fixtures/block_user.json
172
+ - spec/fixtures/deny_user.json
173
+ - spec/fixtures/follow_user.json
174
+ - spec/fixtures/followed_by.json
175
+ - spec/fixtures/follows.json
176
+ - spec/fixtures/geography_recent_media.json
177
+ - spec/fixtures/liked_media.json
178
+ - spec/fixtures/location.json
179
+ - spec/fixtures/location_recent_media.json
180
+ - spec/fixtures/location_search.json
181
+ - spec/fixtures/media.json
182
+ - spec/fixtures/media_comment.json
183
+ - spec/fixtures/media_comment_deleted.json
184
+ - spec/fixtures/media_comments.json
185
+ - spec/fixtures/media_liked.json
186
+ - spec/fixtures/media_likes.json
187
+ - spec/fixtures/media_popular.json
188
+ - spec/fixtures/media_search.json
189
+ - spec/fixtures/media_unliked.json
190
+ - spec/fixtures/mikeyk.json
191
+ - spec/fixtures/recent_media.json
192
+ - spec/fixtures/relationship.json
193
+ - spec/fixtures/requested_by.json
194
+ - spec/fixtures/shayne.json
195
+ - spec/fixtures/subscription.json
196
+ - spec/fixtures/subscription_deleted.json
197
+ - spec/fixtures/subscription_payload.json
198
+ - spec/fixtures/subscriptions.json
199
+ - spec/fixtures/tag.json
200
+ - spec/fixtures/tag_recent_media.json
201
+ - spec/fixtures/tag_search.json
202
+ - spec/fixtures/unblock_user.json
203
+ - spec/fixtures/unfollow_user.json
204
+ - spec/fixtures/user_media_feed.json
205
+ - spec/fixtures/user_search.json
206
+ - spec/instagram/api_spec.rb
207
+ - spec/instagram/client/comments_spec.rb
208
+ - spec/instagram/client/geography_spec.rb
209
+ - spec/instagram/client/likes_spec.rb
210
+ - spec/instagram/client/locations_spec.rb
211
+ - spec/instagram/client/media_spec.rb
212
+ - spec/instagram/client/subscriptions_spec.rb
213
+ - spec/instagram/client/tags_spec.rb
214
+ - spec/instagram/client/users_spec.rb
215
+ - spec/instagram/client_spec.rb
216
+ - spec/instagram_spec.rb
217
+ - spec/spec_helper.rb
218
+ homepage: https://github.com/innonate/instagram-ruby-gem/
219
+ licenses: []
220
+
221
+ post_install_message:
222
+ rdoc_options: []
223
+
224
+ require_paths:
225
+ - lib
226
+ required_ruby_version: !ruby/object:Gem::Requirement
227
+ none: false
228
+ requirements:
229
+ - - ">="
230
+ - !ruby/object:Gem::Version
231
+ hash: 3
232
+ segments:
233
+ - 0
234
+ version: "0"
235
+ required_rubygems_version: !ruby/object:Gem::Requirement
236
+ none: false
237
+ requirements:
238
+ - - ">="
239
+ - !ruby/object:Gem::Version
240
+ hash: 23
241
+ segments:
242
+ - 1
243
+ - 3
244
+ - 6
245
+ version: 1.3.6
246
+ requirements: []
247
+
248
+ rubyforge_project: instagram-innonate
249
+ rubygems_version: 1.8.10
250
+ signing_key:
251
+ specification_version: 3
252
+ summary: Ruby wrapper for the Instagram API
253
+ test_files:
254
+ - spec/faraday/response_spec.rb
255
+ - spec/fixtures/access_token.json
256
+ - spec/fixtures/approve_user.json
257
+ - spec/fixtures/block_user.json
258
+ - spec/fixtures/deny_user.json
259
+ - spec/fixtures/follow_user.json
260
+ - spec/fixtures/followed_by.json
261
+ - spec/fixtures/follows.json
262
+ - spec/fixtures/geography_recent_media.json
263
+ - spec/fixtures/liked_media.json
264
+ - spec/fixtures/location.json
265
+ - spec/fixtures/location_recent_media.json
266
+ - spec/fixtures/location_search.json
267
+ - spec/fixtures/media.json
268
+ - spec/fixtures/media_comment.json
269
+ - spec/fixtures/media_comment_deleted.json
270
+ - spec/fixtures/media_comments.json
271
+ - spec/fixtures/media_liked.json
272
+ - spec/fixtures/media_likes.json
273
+ - spec/fixtures/media_popular.json
274
+ - spec/fixtures/media_search.json
275
+ - spec/fixtures/media_unliked.json
276
+ - spec/fixtures/mikeyk.json
277
+ - spec/fixtures/recent_media.json
278
+ - spec/fixtures/relationship.json
279
+ - spec/fixtures/requested_by.json
280
+ - spec/fixtures/shayne.json
281
+ - spec/fixtures/subscription.json
282
+ - spec/fixtures/subscription_deleted.json
283
+ - spec/fixtures/subscription_payload.json
284
+ - spec/fixtures/subscriptions.json
285
+ - spec/fixtures/tag.json
286
+ - spec/fixtures/tag_recent_media.json
287
+ - spec/fixtures/tag_search.json
288
+ - spec/fixtures/unblock_user.json
289
+ - spec/fixtures/unfollow_user.json
290
+ - spec/fixtures/user_media_feed.json
291
+ - spec/fixtures/user_search.json
292
+ - spec/instagram/api_spec.rb
293
+ - spec/instagram/client/comments_spec.rb
294
+ - spec/instagram/client/geography_spec.rb
295
+ - spec/instagram/client/likes_spec.rb
296
+ - spec/instagram/client/locations_spec.rb
297
+ - spec/instagram/client/media_spec.rb
298
+ - spec/instagram/client/subscriptions_spec.rb
299
+ - spec/instagram/client/tags_spec.rb
300
+ - spec/instagram/client/users_spec.rb
301
+ - spec/instagram/client_spec.rb
302
+ - spec/instagram_spec.rb
303
+ - spec/spec_helper.rb