koala 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -1
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/.yardopts +3 -0
- data/CHANGELOG +28 -0
- data/Gemfile +14 -0
- data/Guardfile +6 -0
- data/koala.gemspec +3 -3
- data/lib/koala/api/batch_operation.rb +83 -0
- data/lib/koala/api/graph_api.rb +476 -0
- data/lib/koala/{graph_batch_api.rb → api/graph_batch_api.rb} +22 -17
- data/lib/koala/api/graph_collection.rb +107 -0
- data/lib/koala/api/legacy.rb +26 -0
- data/lib/koala/{rest_api.rb → api/rest_api.rb} +34 -13
- data/lib/koala/api.rb +93 -0
- data/lib/koala/http_service/multipart_request.rb +41 -0
- data/lib/koala/http_service/response.rb +18 -0
- data/lib/koala/http_service/uploadable_io.rb +187 -0
- data/lib/koala/http_service.rb +69 -20
- data/lib/koala/oauth.rb +170 -36
- data/lib/koala/realtime_updates.rb +89 -51
- data/lib/koala/test_users.rb +122 -32
- data/lib/koala/utils.rb +11 -4
- data/lib/koala/version.rb +1 -1
- data/lib/koala.rb +16 -96
- data/readme.md +9 -9
- data/spec/cases/api_spec.rb +19 -12
- data/spec/cases/error_spec.rb +10 -0
- data/spec/cases/graph_api_batch_spec.rb +100 -58
- data/spec/cases/graph_collection_spec.rb +23 -7
- data/spec/cases/http_service_spec.rb +5 -26
- data/spec/cases/koala_spec.rb +22 -4
- data/spec/cases/legacy_spec.rb +115 -0
- data/spec/cases/multipart_request_spec.rb +7 -7
- data/spec/cases/oauth_spec.rb +134 -48
- data/spec/cases/realtime_updates_spec.rb +154 -47
- data/spec/cases/test_users_spec.rb +276 -219
- data/spec/cases/uploadable_io_spec.rb +1 -1
- data/spec/cases/utils_spec.rb +29 -5
- data/spec/fixtures/mock_facebook_responses.yml +41 -30
- data/spec/spec_helper.rb +3 -0
- data/spec/support/custom_matchers.rb +28 -0
- data/spec/support/graph_api_shared_examples.rb +192 -14
- data/spec/support/koala_test.rb +10 -1
- data/spec/support/mock_http_service.rb +2 -2
- data/spec/support/rest_api_shared_examples.rb +5 -165
- metadata +75 -99
- data/lib/koala/batch_operation.rb +0 -74
- data/lib/koala/graph_api.rb +0 -270
- data/lib/koala/graph_collection.rb +0 -59
- data/lib/koala/multipart_request.rb +0 -35
- data/lib/koala/uploadable_io.rb +0 -181
- data/spec/cases/graph_and_rest_api_spec.rb +0 -22
- data/spec/cases/graph_api_spec.rb +0 -22
- data/spec/cases/rest_api_spec.rb +0 -22
|
@@ -112,145 +112,18 @@ shared_examples_for "Koala RestAPI" do
|
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
it "throws an APIError if the result hash has an error key" do
|
|
115
|
-
Koala.stub(:make_request).and_return(Koala::Response.new(500, {"error_code" => "An error occurred!"}, {}))
|
|
116
|
-
lambda { @api.rest_call(
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
describe "when making a FQL request" do
|
|
120
|
-
it "calls fql.query method" do
|
|
121
|
-
@api.should_receive(:rest_call).with(
|
|
122
|
-
"fql.query", anything, anything
|
|
123
|
-
).and_return(Koala::Response.new(200, "2", {}))
|
|
124
|
-
|
|
125
|
-
@api.fql_query stub('query string')
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
it "passes a query argument" do
|
|
129
|
-
query = stub('query string')
|
|
130
|
-
|
|
131
|
-
@api.should_receive(:rest_call).with(
|
|
132
|
-
anything, hash_including(:query => query), anything
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
@api.fql_query(query)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
it "passes on any other arguments provided" do
|
|
139
|
-
args = {:a => 2}
|
|
140
|
-
@api.should_receive(:rest_call).with(anything, hash_including(args), anything)
|
|
141
|
-
@api.fql_query("a query", args)
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
it "passes on any http options provided" do
|
|
145
|
-
opts = {:a => 2}
|
|
146
|
-
@api.should_receive(:rest_call).with(anything, anything, hash_including(opts))
|
|
147
|
-
@api.fql_query("a query", {}, opts)
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
describe "when making a FQL-multiquery request" do
|
|
152
|
-
it "calls fql.multiquery method" do
|
|
153
|
-
@api.should_receive(:rest_call).with(
|
|
154
|
-
"fql.multiquery", anything, anything
|
|
155
|
-
).and_return({})
|
|
156
|
-
|
|
157
|
-
@api.fql_multiquery 'query string'
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
it "passes a queries argument" do
|
|
161
|
-
queries = stub('query string')
|
|
162
|
-
queries_json = "some JSON"
|
|
163
|
-
MultiJson.stub(:encode).with(queries).and_return(queries_json)
|
|
164
|
-
|
|
165
|
-
@api.should_receive(:rest_call).with(
|
|
166
|
-
anything,
|
|
167
|
-
hash_including(:queries => queries_json),
|
|
168
|
-
anything
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
@api.fql_multiquery(queries)
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
it "simplifies the response format" do
|
|
175
|
-
raw_results = [
|
|
176
|
-
{"name" => "query1", "fql_result_set" => [1, 2, 3]},
|
|
177
|
-
{"name" => "query2", "fql_result_set" => [:a, :b, :c]}
|
|
178
|
-
]
|
|
179
|
-
expected_results = {
|
|
180
|
-
"query1" => [1, 2, 3],
|
|
181
|
-
"query2" => [:a, :b, :c]
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
@api.stub(:rest_call).and_return(raw_results)
|
|
185
|
-
results = @api.fql_multiquery({:query => true})
|
|
186
|
-
results.should == expected_results
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
it "passes on any other arguments provided" do
|
|
190
|
-
args = {:a => 2}
|
|
191
|
-
@api.should_receive(:rest_call).with(anything, hash_including(args), anything)
|
|
192
|
-
@api.fql_multiquery("a query", args)
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
it "passes on any http options provided" do
|
|
196
|
-
opts = {:a => 2}
|
|
197
|
-
@api.should_receive(:rest_call).with(anything, anything, hash_including(opts))
|
|
198
|
-
@api.fql_multiquery("a query", {}, opts)
|
|
199
|
-
end
|
|
115
|
+
Koala.stub(:make_request).and_return(Koala::HTTPService::Response.new(500, {"error_code" => "An error occurred!"}, {}))
|
|
116
|
+
lambda { @api.rest_call(KoalaTest.user1, {}) }.should raise_exception(Koala::Facebook::APIError)
|
|
200
117
|
end
|
|
201
118
|
end
|
|
202
119
|
|
|
203
120
|
it "can use the beta tier" do
|
|
204
|
-
@api.
|
|
121
|
+
@api.rest_call("fql.query", {:query => "select first_name from user where uid = #{KoalaTest.user2_id}"}, :beta => true)
|
|
205
122
|
end
|
|
206
123
|
end
|
|
207
124
|
|
|
208
125
|
shared_examples_for "Koala RestAPI with an access token" do
|
|
209
|
-
#
|
|
210
|
-
it "can access public information via FQL" do
|
|
211
|
-
result = @api.fql_query("select first_name from user where uid = #{KoalaTest.user2_id}")
|
|
212
|
-
result.size.should == 1
|
|
213
|
-
result.first['first_name'].should == KoalaTest.user2_name
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
it "can access public information via FQL.multiquery" do
|
|
217
|
-
result = @api.fql_multiquery(
|
|
218
|
-
:query1 => "select first_name from user where uid = #{KoalaTest.user2_id}",
|
|
219
|
-
:query2 => "select first_name from user where uid = #{KoalaTest.user1_id}"
|
|
220
|
-
)
|
|
221
|
-
result.size.should == 2
|
|
222
|
-
result["query1"].first['first_name'].should == KoalaTest.user2_name
|
|
223
|
-
result["query2"].first['first_name'].should == KoalaTest.user1_name
|
|
224
|
-
end
|
|
225
|
-
|
|
226
|
-
it "can access protected information via FQL" do
|
|
227
|
-
# Tests agains the permissions fql table
|
|
228
|
-
|
|
229
|
-
# get the current user's ID
|
|
230
|
-
# we're sneakily using the Graph API, which should be okay since it has its own tests
|
|
231
|
-
g = Koala::Facebook::API.new(@token)
|
|
232
|
-
id = g.get_object("me", :fields => "id")["id"]
|
|
233
|
-
|
|
234
|
-
# now send a query about your permissions
|
|
235
|
-
result = @api.fql_query("select read_stream from permissions where uid = #{id}")
|
|
236
|
-
|
|
237
|
-
result.size.should == 1
|
|
238
|
-
# we've verified that you have read_stream permissions, so we can test against that
|
|
239
|
-
result.first["read_stream"].should == 1
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
it "can access protected information via FQL.multiquery" do
|
|
243
|
-
result = @api.fql_multiquery(
|
|
244
|
-
:query1 => "select post_id from stream where source_id = me()",
|
|
245
|
-
:query2 => "select fromid from comment where post_id in (select post_id from #query1)",
|
|
246
|
-
:query3 => "select uid, name from user where uid in (select fromid from #query2)"
|
|
247
|
-
)
|
|
248
|
-
result.size.should == 3
|
|
249
|
-
result.keys.should include("query1", "query2", "query3")
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
describe ".set_app_properties" do
|
|
126
|
+
describe "#set_app_properties" do
|
|
254
127
|
it "sends Facebook the properties JSON-encoded as :properties" do
|
|
255
128
|
props = {:a => 2, :c => [1, 2, "d"]}
|
|
256
129
|
@api.should_receive(:rest_call).with(anything, hash_including(:properties => MultiJson.encode(props)), anything, anything)
|
|
@@ -283,46 +156,13 @@ shared_examples_for "Koala RestAPI with an access token" do
|
|
|
283
156
|
oauth = Koala::Facebook::OAuth.new(KoalaTest.app_id, KoalaTest.secret)
|
|
284
157
|
app_token = oauth.get_app_access_token
|
|
285
158
|
@app_api = Koala::Facebook::API.new(app_token)
|
|
286
|
-
@app_api.set_app_properties(
|
|
159
|
+
@app_api.set_app_properties(KoalaTest.app_properties).should be_true
|
|
287
160
|
end
|
|
288
161
|
end
|
|
289
162
|
end
|
|
290
163
|
|
|
291
164
|
|
|
292
165
|
shared_examples_for "Koala RestAPI without an access token" do
|
|
293
|
-
# FQL_QUERY
|
|
294
|
-
describe "when making a FQL request" do
|
|
295
|
-
it "can access public information via FQL" do
|
|
296
|
-
result = @api.fql_query("select first_name from user where uid = #{KoalaTest.user2_id}")
|
|
297
|
-
result.size.should == 1
|
|
298
|
-
result.first['first_name'].should == KoalaTest.user2_name
|
|
299
|
-
end
|
|
300
|
-
|
|
301
|
-
it "can access public information via FQL.multiquery" do
|
|
302
|
-
result = @api.fql_multiquery(
|
|
303
|
-
:query1 => "select first_name from user where uid = #{KoalaTest.user2_id}",
|
|
304
|
-
:query2 => "select first_name from user where uid = #{KoalaTest.user1_id}"
|
|
305
|
-
)
|
|
306
|
-
result.size.should == 2
|
|
307
|
-
result["query1"].first['first_name'].should == KoalaTest.user2_name
|
|
308
|
-
result["query2"].first['first_name'].should == KoalaTest.user1_name
|
|
309
|
-
end
|
|
310
|
-
|
|
311
|
-
it "can't access protected information via FQL" do
|
|
312
|
-
lambda { @api.fql_query("select read_stream from permissions where uid = #{KoalaTest.user2_id}") }.should raise_error(Koala::Facebook::APIError)
|
|
313
|
-
end
|
|
314
|
-
|
|
315
|
-
it "can't access protected information via FQL.multiquery" do
|
|
316
|
-
lambda {
|
|
317
|
-
@api.fql_multiquery(
|
|
318
|
-
:query1 => "select post_id from stream where source_id = me()",
|
|
319
|
-
:query2 => "select fromid from comment where post_id in (select post_id from #query1)",
|
|
320
|
-
:query3 => "select uid, name from user where uid in (select fromid from #query2)"
|
|
321
|
-
)
|
|
322
|
-
}.should raise_error(Koala::Facebook::APIError)
|
|
323
|
-
end
|
|
324
|
-
end
|
|
325
|
-
|
|
326
166
|
it "can't use set_app_properties" do
|
|
327
167
|
lambda { @api.set_app_properties(:desktop => 0) }.should raise_error(Koala::Facebook::APIError)
|
|
328
168
|
end
|
metadata
CHANGED
|
@@ -1,132 +1,113 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: koala
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
prerelease:
|
|
6
|
-
segments:
|
|
7
|
-
- 1
|
|
8
|
-
- 2
|
|
9
|
-
- 1
|
|
10
|
-
version: 1.2.1
|
|
11
6
|
platform: ruby
|
|
12
|
-
authors:
|
|
7
|
+
authors:
|
|
13
8
|
- Alex Koppel, Chris Baclig, Rafi Jacoby, Context Optional
|
|
14
9
|
autorequire:
|
|
15
10
|
bindir: bin
|
|
16
11
|
cert_chain: []
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
dependencies:
|
|
21
|
-
- !ruby/object:Gem::Dependency
|
|
22
|
-
type: :runtime
|
|
12
|
+
date: 2011-10-04 00:00:00.000000000Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
23
15
|
name: multi_json
|
|
24
|
-
|
|
16
|
+
requirement: &70194747941160 !ruby/object:Gem::Requirement
|
|
25
17
|
none: false
|
|
26
|
-
requirements:
|
|
18
|
+
requirements:
|
|
27
19
|
- - ~>
|
|
28
|
-
- !ruby/object:Gem::Version
|
|
29
|
-
|
|
30
|
-
segments:
|
|
31
|
-
- 1
|
|
32
|
-
- 0
|
|
33
|
-
version: "1.0"
|
|
34
|
-
requirement: *id001
|
|
35
|
-
prerelease: false
|
|
36
|
-
- !ruby/object:Gem::Dependency
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '1.0'
|
|
37
22
|
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: *70194747941160
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
38
26
|
name: faraday
|
|
39
|
-
|
|
27
|
+
requirement: &70194747940100 !ruby/object:Gem::Requirement
|
|
40
28
|
none: false
|
|
41
|
-
requirements:
|
|
29
|
+
requirements:
|
|
42
30
|
- - ~>
|
|
43
|
-
- !ruby/object:Gem::Version
|
|
44
|
-
hash: 3
|
|
45
|
-
segments:
|
|
46
|
-
- 0
|
|
47
|
-
- 7
|
|
48
|
-
- 0
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
49
32
|
version: 0.7.0
|
|
50
|
-
|
|
33
|
+
type: :runtime
|
|
51
34
|
prerelease: false
|
|
52
|
-
|
|
53
|
-
|
|
35
|
+
version_requirements: *70194747940100
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
54
37
|
name: rspec
|
|
55
|
-
|
|
38
|
+
requirement: &70194747938880 !ruby/object:Gem::Requirement
|
|
56
39
|
none: false
|
|
57
|
-
requirements:
|
|
40
|
+
requirements:
|
|
58
41
|
- - ~>
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
|
|
61
|
-
segments:
|
|
62
|
-
- 2
|
|
63
|
-
- 5
|
|
64
|
-
version: "2.5"
|
|
65
|
-
requirement: *id003
|
|
66
|
-
prerelease: false
|
|
67
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: 2.8.0rc1
|
|
68
44
|
type: :development
|
|
45
|
+
prerelease: false
|
|
46
|
+
version_requirements: *70194747938880
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
69
48
|
name: rake
|
|
70
|
-
|
|
49
|
+
requirement: &70194747937740 !ruby/object:Gem::Requirement
|
|
71
50
|
none: false
|
|
72
|
-
requirements:
|
|
51
|
+
requirements:
|
|
73
52
|
- - ~>
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
hash: 49
|
|
76
|
-
segments:
|
|
77
|
-
- 0
|
|
78
|
-
- 8
|
|
79
|
-
- 7
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
80
54
|
version: 0.8.7
|
|
81
|
-
|
|
55
|
+
type: :development
|
|
82
56
|
prerelease: false
|
|
83
|
-
|
|
57
|
+
version_requirements: *70194747937740
|
|
58
|
+
description: Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write
|
|
59
|
+
access to the social graph via the Graph and REST APIs, as well as support for realtime
|
|
60
|
+
updates and OAuth and Facebook Connect authentication. Koala is fully tested and
|
|
61
|
+
supports Net::HTTP and Typhoeus connections out of the box and can accept custom
|
|
62
|
+
modules for other services.
|
|
84
63
|
email: alex@alexkoppel.com
|
|
85
64
|
executables: []
|
|
86
|
-
|
|
87
65
|
extensions: []
|
|
88
|
-
|
|
89
|
-
extra_rdoc_files:
|
|
66
|
+
extra_rdoc_files:
|
|
90
67
|
- readme.md
|
|
91
68
|
- CHANGELOG
|
|
92
|
-
files:
|
|
69
|
+
files:
|
|
93
70
|
- .autotest
|
|
94
71
|
- .gitignore
|
|
72
|
+
- .rspec
|
|
95
73
|
- .travis.yml
|
|
74
|
+
- .yardopts
|
|
96
75
|
- CHANGELOG
|
|
97
76
|
- Gemfile
|
|
77
|
+
- Guardfile
|
|
98
78
|
- LICENSE
|
|
99
79
|
- Manifest
|
|
100
80
|
- Rakefile
|
|
101
81
|
- autotest/discover.rb
|
|
102
82
|
- koala.gemspec
|
|
103
83
|
- lib/koala.rb
|
|
104
|
-
- lib/koala/
|
|
105
|
-
- lib/koala/
|
|
106
|
-
- lib/koala/
|
|
107
|
-
- lib/koala/
|
|
84
|
+
- lib/koala/api.rb
|
|
85
|
+
- lib/koala/api/batch_operation.rb
|
|
86
|
+
- lib/koala/api/graph_api.rb
|
|
87
|
+
- lib/koala/api/graph_batch_api.rb
|
|
88
|
+
- lib/koala/api/graph_collection.rb
|
|
89
|
+
- lib/koala/api/legacy.rb
|
|
90
|
+
- lib/koala/api/rest_api.rb
|
|
108
91
|
- lib/koala/http_service.rb
|
|
109
|
-
- lib/koala/multipart_request.rb
|
|
92
|
+
- lib/koala/http_service/multipart_request.rb
|
|
93
|
+
- lib/koala/http_service/response.rb
|
|
94
|
+
- lib/koala/http_service/uploadable_io.rb
|
|
110
95
|
- lib/koala/oauth.rb
|
|
111
96
|
- lib/koala/realtime_updates.rb
|
|
112
|
-
- lib/koala/rest_api.rb
|
|
113
97
|
- lib/koala/test_users.rb
|
|
114
|
-
- lib/koala/uploadable_io.rb
|
|
115
98
|
- lib/koala/utils.rb
|
|
116
99
|
- lib/koala/version.rb
|
|
117
100
|
- readme.md
|
|
118
101
|
- spec/cases/api_spec.rb
|
|
119
102
|
- spec/cases/error_spec.rb
|
|
120
|
-
- spec/cases/graph_and_rest_api_spec.rb
|
|
121
103
|
- spec/cases/graph_api_batch_spec.rb
|
|
122
|
-
- spec/cases/graph_api_spec.rb
|
|
123
104
|
- spec/cases/graph_collection_spec.rb
|
|
124
105
|
- spec/cases/http_service_spec.rb
|
|
125
106
|
- spec/cases/koala_spec.rb
|
|
107
|
+
- spec/cases/legacy_spec.rb
|
|
126
108
|
- spec/cases/multipart_request_spec.rb
|
|
127
109
|
- spec/cases/oauth_spec.rb
|
|
128
110
|
- spec/cases/realtime_updates_spec.rb
|
|
129
|
-
- spec/cases/rest_api_spec.rb
|
|
130
111
|
- spec/cases/test_users_spec.rb
|
|
131
112
|
- spec/cases/uploadable_io_spec.rb
|
|
132
113
|
- spec/cases/utils_spec.rb
|
|
@@ -135,6 +116,7 @@ files:
|
|
|
135
116
|
- spec/fixtures/facebook_data.yml
|
|
136
117
|
- spec/fixtures/mock_facebook_responses.yml
|
|
137
118
|
- spec/spec_helper.rb
|
|
119
|
+
- spec/support/custom_matchers.rb
|
|
138
120
|
- spec/support/graph_api_shared_examples.rb
|
|
139
121
|
- spec/support/json_testing_fix.rb
|
|
140
122
|
- spec/support/koala_test.rb
|
|
@@ -142,57 +124,49 @@ files:
|
|
|
142
124
|
- spec/support/ordered_hash.rb
|
|
143
125
|
- spec/support/rest_api_shared_examples.rb
|
|
144
126
|
- spec/support/uploadable_io_shared_examples.rb
|
|
145
|
-
has_rdoc: true
|
|
146
127
|
homepage: http://github.com/arsduo/koala
|
|
147
128
|
licenses: []
|
|
148
|
-
|
|
149
129
|
post_install_message:
|
|
150
|
-
rdoc_options:
|
|
130
|
+
rdoc_options:
|
|
151
131
|
- --line-numbers
|
|
152
132
|
- --inline-source
|
|
153
133
|
- --title
|
|
154
134
|
- Koala
|
|
155
|
-
require_paths:
|
|
135
|
+
require_paths:
|
|
156
136
|
- lib
|
|
157
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
138
|
none: false
|
|
159
|
-
requirements:
|
|
160
|
-
- -
|
|
161
|
-
- !ruby/object:Gem::Version
|
|
162
|
-
|
|
163
|
-
segments:
|
|
139
|
+
requirements:
|
|
140
|
+
- - ! '>='
|
|
141
|
+
- !ruby/object:Gem::Version
|
|
142
|
+
version: '0'
|
|
143
|
+
segments:
|
|
164
144
|
- 0
|
|
165
|
-
|
|
166
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
|
+
hash: 3741350754426721879
|
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
147
|
none: false
|
|
168
|
-
requirements:
|
|
169
|
-
- -
|
|
170
|
-
- !ruby/object:Gem::Version
|
|
171
|
-
|
|
172
|
-
segments:
|
|
173
|
-
- 1
|
|
174
|
-
- 2
|
|
175
|
-
version: "1.2"
|
|
148
|
+
requirements:
|
|
149
|
+
- - ! '>='
|
|
150
|
+
- !ruby/object:Gem::Version
|
|
151
|
+
version: '1.2'
|
|
176
152
|
requirements: []
|
|
177
|
-
|
|
178
153
|
rubyforge_project:
|
|
179
|
-
rubygems_version: 1.
|
|
154
|
+
rubygems_version: 1.8.10
|
|
180
155
|
signing_key:
|
|
181
156
|
specification_version: 3
|
|
182
|
-
summary: A lightweight, flexible library for Facebook with support for the Graph API,
|
|
183
|
-
|
|
157
|
+
summary: A lightweight, flexible library for Facebook with support for the Graph API,
|
|
158
|
+
the REST API, realtime updates, and OAuth authentication.
|
|
159
|
+
test_files:
|
|
184
160
|
- spec/cases/api_spec.rb
|
|
185
161
|
- spec/cases/error_spec.rb
|
|
186
|
-
- spec/cases/graph_and_rest_api_spec.rb
|
|
187
162
|
- spec/cases/graph_api_batch_spec.rb
|
|
188
|
-
- spec/cases/graph_api_spec.rb
|
|
189
163
|
- spec/cases/graph_collection_spec.rb
|
|
190
164
|
- spec/cases/http_service_spec.rb
|
|
191
165
|
- spec/cases/koala_spec.rb
|
|
166
|
+
- spec/cases/legacy_spec.rb
|
|
192
167
|
- spec/cases/multipart_request_spec.rb
|
|
193
168
|
- spec/cases/oauth_spec.rb
|
|
194
169
|
- spec/cases/realtime_updates_spec.rb
|
|
195
|
-
- spec/cases/rest_api_spec.rb
|
|
196
170
|
- spec/cases/test_users_spec.rb
|
|
197
171
|
- spec/cases/uploadable_io_spec.rb
|
|
198
172
|
- spec/cases/utils_spec.rb
|
|
@@ -201,6 +175,7 @@ test_files:
|
|
|
201
175
|
- spec/fixtures/facebook_data.yml
|
|
202
176
|
- spec/fixtures/mock_facebook_responses.yml
|
|
203
177
|
- spec/spec_helper.rb
|
|
178
|
+
- spec/support/custom_matchers.rb
|
|
204
179
|
- spec/support/graph_api_shared_examples.rb
|
|
205
180
|
- spec/support/json_testing_fix.rb
|
|
206
181
|
- spec/support/koala_test.rb
|
|
@@ -208,3 +183,4 @@ test_files:
|
|
|
208
183
|
- spec/support/ordered_hash.rb
|
|
209
184
|
- spec/support/rest_api_shared_examples.rb
|
|
210
185
|
- spec/support/uploadable_io_shared_examples.rb
|
|
186
|
+
has_rdoc:
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
module Koala
|
|
2
|
-
module Facebook
|
|
3
|
-
class BatchOperation
|
|
4
|
-
attr_reader :access_token, :http_options, :post_processing, :files, :batch_api, :identifier
|
|
5
|
-
|
|
6
|
-
@identifier = 0
|
|
7
|
-
|
|
8
|
-
def self.next_identifier
|
|
9
|
-
@identifier += 1
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def initialize(options = {})
|
|
13
|
-
@identifier = self.class.next_identifier
|
|
14
|
-
@args = (options[:args] || {}).dup # because we modify it below
|
|
15
|
-
@access_token = options[:access_token]
|
|
16
|
-
@http_options = (options[:http_options] || {}).dup # dup because we modify it below
|
|
17
|
-
@batch_args = @http_options.delete(:batch_args) || {}
|
|
18
|
-
@url = options[:url]
|
|
19
|
-
@method = options[:method].to_sym
|
|
20
|
-
@post_processing = options[:post_processing]
|
|
21
|
-
|
|
22
|
-
process_binary_args
|
|
23
|
-
|
|
24
|
-
raise Koala::KoalaError, "Batch operations require an access token, none provided." unless @access_token
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def to_batch_params(main_access_token)
|
|
28
|
-
# set up the arguments
|
|
29
|
-
args_string = Koala.http_service.encode_params(@access_token == main_access_token ? @args : @args.merge(:access_token => @access_token))
|
|
30
|
-
|
|
31
|
-
response = {
|
|
32
|
-
:method => @method.to_s,
|
|
33
|
-
:relative_url => @url,
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
# handle batch-level arguments, such as name, depends_on, and attached_files
|
|
37
|
-
@batch_args[:attached_files] = @files.keys.join(",") if @files
|
|
38
|
-
response.merge!(@batch_args) if @batch_args
|
|
39
|
-
|
|
40
|
-
# for get and delete, we append args to the URL string
|
|
41
|
-
# otherwise, they go in the body
|
|
42
|
-
if args_string.length > 0
|
|
43
|
-
if args_in_url?
|
|
44
|
-
response[:relative_url] += (@url =~ /\?/ ? "&" : "?") + args_string if args_string.length > 0
|
|
45
|
-
else
|
|
46
|
-
response[:body] = args_string if args_string.length > 0
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
response
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
protected
|
|
54
|
-
|
|
55
|
-
def process_binary_args
|
|
56
|
-
# collect binary files
|
|
57
|
-
@args.each_pair do |key, value|
|
|
58
|
-
if UploadableIO.binary_content?(value)
|
|
59
|
-
@files ||= {}
|
|
60
|
-
# we use a class-level counter to ensure unique file identifiers across multiple batch operations
|
|
61
|
-
# (this is thread safe, since we just care about uniqueness)
|
|
62
|
-
# so remove the file from the original hash and add it to the file store
|
|
63
|
-
id = "op#{identifier}_file#{@files.keys.length}"
|
|
64
|
-
@files[id] = @args.delete(key).is_a?(UploadableIO) ? value : UploadableIO.new(value)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def args_in_url?
|
|
70
|
-
@method == :get || @method == :delete
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
end
|