koala 2.4.0 → 2.5.0rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa79bc7b848a2513d2f1aac248d1aac70d8a392c
4
- data.tar.gz: edfd57c54b0b96a4682cf23af9e388ed59e4aa3d
3
+ metadata.gz: f88dda2979fd111e38bc82c0736c3445859e267b
4
+ data.tar.gz: 4fce57cdb6eae0086e9262c5034e21e8bf5a92f4
5
5
  SHA512:
6
- metadata.gz: ed4e62ff0f2d70c17cf0301be06e552940fd14654b1dc715f10477f63da89d2b6aa14b21105e2b9e90ca88ee1ff7a60e737f2f24744ab6cb86cf4b9f6aac80ce
7
- data.tar.gz: 7a5b55d226afdd6f8e6d8af440b7e714a1cb8ffd68c35a0f80dfdb61d042d988b8b7eb8fad95d30e3cff094a0a3ecfc07fe418d2ec61826a7338b027933d1636
6
+ metadata.gz: 26968b19aa310ef775d82d05b3a544353465048eea17601a8864d87532287eb743751f5094b94cff58a75f5312c317255fb06f1fa2c161dfa7aea0db655d50d3
7
+ data.tar.gz: a3335869322f904f144e57fd6dfa96e31e32a238b0bcdb0d01b52538dbdfda2e2a5022aac748a63c3341707993d1b5868d56cb1b864dd8c2df97f6df451200c7
@@ -1,3 +1,18 @@
1
+ v2.5.0
2
+ ======
3
+
4
+ New features:
5
+
6
+ * API#get_object_metadata provides a convenient accessor to an object's graph metadata (thanks, sancopanco!)
7
+
8
+ Documentation improvements:
9
+
10
+ * Add explicit require to examples in readme.md (thanks, dwkns!)
11
+
12
+ Internal improvements:
13
+
14
+ * Remove MultiJson dependency (thanks, sakuro!)
15
+
1
16
  v2.4.0
2
17
  ======
3
18
 
@@ -18,7 +33,7 @@ Internal improvements:
18
33
 
19
34
  Testing improvements:
20
35
 
21
- * Test Koala against Ruby 2.3.0
36
+ * Test Koala against Ruby 2.3.0 (thanks, thedrow!)
22
37
 
23
38
 
24
39
  v2.3.0
@@ -21,7 +21,6 @@ Gem::Specification.new do |gem|
21
21
  gem.extra_rdoc_files = ["readme.md", "changelog.md"]
22
22
  gem.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Koala"]
23
23
 
24
- gem.add_runtime_dependency("multi_json", ">= 1.3.0")
25
24
  gem.add_runtime_dependency("faraday")
26
25
  gem.add_runtime_dependency("addressable")
27
26
  end
@@ -1,6 +1,6 @@
1
1
  # useful tools
2
2
  require 'digest/md5'
3
- require 'multi_json'
3
+ require 'json'
4
4
 
5
5
  # include koala modules
6
6
  require 'koala/errors'
@@ -84,9 +84,10 @@ module Koala
84
84
  component == :response ? result : result.send(options[:http_component])
85
85
  else
86
86
  # parse the body as JSON and run it through the error checker (if provided)
87
- # Note: Facebook sometimes sends results like "true" and "false", which aren't strictly objects
88
- # and cause MultiJson.load to fail -- so we account for that by wrapping the result in []
89
- MultiJson.load("[#{result.body.to_s}]")[0]
87
+ # Note: Facebook sometimes sends results like "true" and "false", which are valid[RFC7159]
88
+ # but unsupported by Ruby's stdlib[RFC4627] and cause JSON.load to fail -- so we account for
89
+ # that by wrapping the result in []
90
+ JSON.load("[#{result.body.to_s}]")[0]
90
91
  end
91
92
  end
92
93
 
@@ -57,6 +57,20 @@ module Koala
57
57
  graph_call(id, args, "get", options, &block)
58
58
  end
59
59
 
60
+ # Get the metadata of a Facebook object, including its type.
61
+ #
62
+ # @param id the object ID (string or number)
63
+ #
64
+ # @raise [Koala::Facebook::ClientError] if the ID is invalid
65
+ # @example
66
+ # get_object_metadata("442575165800306")=>{"metadata" => "page", ...}
67
+ # get_object_metadata("190822584430113")=>{"metadata" => "status", ...}
68
+ # @return a string of Facebook object type
69
+ def get_object_metadata(id, &block)
70
+ result = graph_call(id, {"metadata" => "1"}, "get", {}, &block)
71
+ result["metadata"]
72
+ end
73
+
60
74
  # Get information about multiple Facebook objects in one call.
61
75
  #
62
76
  # @param ids an array or comma-separated string of object IDs
@@ -274,7 +288,7 @@ module Koala
274
288
  # @return (see #put_connections)
275
289
  def put_wall_post(message, attachment = {}, target_id = "me", options = {}, &block)
276
290
  if properties = attachment.delete(:properties) || attachment.delete("properties")
277
- properties = MultiJson.dump(properties) if properties.is_a?(Hash) || properties.is_a?(Array)
291
+ properties = JSON.dump(properties) if properties.is_a?(Hash) || properties.is_a?(Array)
278
292
  attachment["properties"] = properties
279
293
  end
280
294
  put_connections(target_id, "feed", attachment.merge({:message => message}), options, &block)
@@ -376,7 +390,7 @@ module Koala
376
390
  #
377
391
  # @return a hash of FQL results keyed to the appropriate query
378
392
  def fql_multiquery(queries = {}, args = {}, options = {}, &block)
379
- resolved_results = if results = get_object("fql", args.merge(:q => MultiJson.dump(queries)), options)
393
+ resolved_results = if results = get_object("fql", args.merge(:q => JSON.dump(queries)), options)
380
394
  # simplify the multiquery result format
381
395
  results.inject({}) {|outcome, data| outcome[data["name"]] = data["fql_result_set"]; outcome}
382
396
  end
@@ -441,7 +455,7 @@ module Koala
441
455
  # @param options (see #get_object)
442
456
  # @param block (see Koala::Facebook::API#api)
443
457
  def set_app_restrictions(app_id, restrictions_hash, args = {}, options = {}, &block)
444
- graph_call(app_id, args.merge(:restrictions => MultiJson.dump(restrictions_hash)), "post", options, &block)
458
+ graph_call(app_id, args.merge(:restrictions => JSON.dump(restrictions_hash)), "post", options, &block)
445
459
  end
446
460
 
447
461
  # Certain calls such as {#get_connections} return an array of results which you can page through
@@ -44,7 +44,7 @@ module Koala
44
44
  return [] unless batch_calls.length > 0
45
45
  # Turn the call args collected into what facebook expects
46
46
  args = {}
47
- args["batch"] = MultiJson.dump(batch_calls.map { |batch_op|
47
+ args["batch"] = JSON.dump(batch_calls.map { |batch_op|
48
48
  args.merge!(batch_op.files) if batch_op.files
49
49
  batch_op.to_batch_params(access_token, app_secret)
50
50
  })
@@ -75,7 +75,7 @@ module Koala
75
75
  raw_result = error
76
76
  else
77
77
  # (see note in regular api method about JSON parsing)
78
- body = MultiJson.load("[#{call_result['body'].to_s}]")[0]
78
+ body = JSON.load("[#{call_result['body'].to_s}]")[0]
79
79
 
80
80
  # Get the HTTP component they want
81
81
  raw_result = case batch_op.http_options[:http_component]
@@ -61,8 +61,8 @@ module Koala
61
61
  # Normally, we start with the response body. If it isn't valid JSON, we start with an empty
62
62
  # hash and fill it with error data.
63
63
  @response_hash ||= begin
64
- MultiJson.load(body)
65
- rescue MultiJson::DecodeError
64
+ JSON.load(body)
65
+ rescue JSON::ParserError
66
66
  {}
67
67
  end
68
68
  end
@@ -20,7 +20,7 @@ module Koala
20
20
  # @return true if successful, false if not. (This call currently doesn't give useful feedback on failure.)
21
21
  def set_app_properties(properties, args = {}, options = {})
22
22
  raise AuthenticationError.new(nil, nil, "setAppProperties requires an access token") unless @access_token
23
- rest_call("admin.setAppProperties", args.merge(:properties => MultiJson.dump(properties)), options, "post")
23
+ rest_call("admin.setAppProperties", args.merge(:properties => JSON.dump(properties)), options, "post")
24
24
  end
25
25
 
26
26
  # Make a call to the REST API.
@@ -44,8 +44,8 @@ module Koala
44
44
  # check for REST API-specific errors
45
45
  if response.status >= 400
46
46
  begin
47
- response_hash = MultiJson.load(response.body)
48
- rescue MultiJson::DecodeError
47
+ response_hash = JSON.load(response.body)
48
+ rescue JSON::ParserError
49
49
  response_hash = {}
50
50
  end
51
51
 
@@ -50,7 +50,7 @@ module Koala
50
50
  else
51
51
  unless error_info
52
52
  begin
53
- error_info = MultiJson.load(response_body)['error'] if response_body
53
+ error_info = JSON.load(response_body)['error'] if response_body
54
54
  rescue
55
55
  end
56
56
  error_info ||= {}
@@ -130,7 +130,7 @@ module Koala
130
130
  # @return the appropriately-encoded string
131
131
  def self.encode_params(param_hash)
132
132
  ((param_hash || {}).sort_by{|k, v| k.to_s}.collect do |key_and_value|
133
- key_and_value[1] = MultiJson.dump(key_and_value[1]) unless key_and_value[1].is_a? String
133
+ key_and_value[1] = JSON.dump(key_and_value[1]) unless key_and_value[1].is_a? String
134
134
  "#{key_and_value[0].to_s}=#{CGI.escape key_and_value[1]}"
135
135
  end).join("&")
136
136
  end
@@ -134,7 +134,7 @@ module Koala
134
134
  if response == ''
135
135
  raise BadFacebookResponse.new(200, '', 'generate_client_code received an error: empty response body')
136
136
  else
137
- result = MultiJson.load(response)
137
+ result = JSON.load(response)
138
138
  end
139
139
 
140
140
  result.has_key?('code') ? result['code'] : raise(Koala::KoalaError.new("Facebook returned a valid response without the expected 'code' in the body (response = #{response})"))
@@ -240,7 +240,7 @@ module Koala
240
240
  raise OAuthSignatureError, 'Invalid (incomplete) signature data' unless encoded_sig && encoded_envelope
241
241
 
242
242
  signature = base64_url_decode(encoded_sig).unpack("H*").first
243
- envelope = MultiJson.load(base64_url_decode(encoded_envelope))
243
+ envelope = JSON.load(base64_url_decode(encoded_envelope))
244
244
 
245
245
  raise OAuthSignatureError, "Unsupported algorithm #{envelope['algorithm']}" if envelope['algorithm'] != 'HMAC-SHA256'
246
246
 
@@ -260,8 +260,8 @@ module Koala
260
260
  end
261
261
 
262
262
  def parse_access_token(response_text)
263
- MultiJson.load(response_text)
264
- rescue MultiJson::LoadError
263
+ JSON.load(response_text)
264
+ rescue JSON::ParserError
265
265
  response_text.split("&").inject({}) do |hash, bit|
266
266
  key, value = bit.split("=")
267
267
  hash.merge!(key => value)
@@ -1,3 +1,3 @@
1
1
  module Koala
2
- VERSION = "2.4.0"
2
+ VERSION = "2.5.0rc1"
3
3
  end
data/readme.md CHANGED
@@ -38,6 +38,8 @@ Facebook's [Graph API Explorer](https://developers.facebook.com/tools/explorer)
38
38
  Then, go exploring:
39
39
 
40
40
  ```ruby
41
+ require 'koala'
42
+
41
43
  @graph = Koala::Facebook::API.new(oauth_access_token)
42
44
 
43
45
  profile = @graph.get_object("me")
@@ -128,7 +128,7 @@ describe "Koala::Facebook::API" do
128
128
  allow(Koala).to receive(:make_request).and_return(response)
129
129
 
130
130
  json_body = double('JSON body')
131
- allow(MultiJson).to receive(:load).and_return([json_body])
131
+ allow(JSON).to receive(:load).and_return([json_body])
132
132
 
133
133
  expect(@service.api('anything')).to eq(json_body)
134
134
  end
@@ -322,7 +322,7 @@ describe "Koala::Facebook::GraphAPI in batch mode" do
322
322
  allow(Koala::Facebook::GraphBatchAPI::BatchOperation).to receive(:new).and_return(op)
323
323
 
324
324
  # two requests should generate two batch operations
325
- expected = MultiJson.dump([op.to_batch_params(access_token, nil), op.to_batch_params(access_token, nil)])
325
+ expected = JSON.dump([op.to_batch_params(access_token, nil), op.to_batch_params(access_token, nil)])
326
326
  expect(Koala).to receive(:make_request).with(anything, hash_including("batch" => expected), anything, anything).and_return(@fake_response)
327
327
  Koala::Facebook::API.new(access_token).batch do |batch_api|
328
328
  batch_api.get_object('me')
@@ -141,7 +141,7 @@ describe Koala::HTTPService do
141
141
  val = 'json_value'
142
142
  not_a_string = 'not_a_string'
143
143
  allow(not_a_string).to receive(:is_a?).and_return(false)
144
- expect(MultiJson).to receive(:dump).with(not_a_string).and_return(val)
144
+ expect(JSON).to receive(:dump).with(not_a_string).and_return(val)
145
145
 
146
146
  string = "hi"
147
147
 
@@ -401,7 +401,7 @@ describe "Koala::Facebook::OAuth" do
401
401
  allow(Koala).to receive(:make_request).and_return(
402
402
  Koala::HTTPService::Response.new(
403
403
  200,
404
- MultiJson.dump(result),
404
+ JSON.dump(result),
405
405
  {}
406
406
  )
407
407
  )
@@ -584,7 +584,7 @@ describe "Koala::Facebook::OAuth" do
584
584
  # the signed request code is ported directly from Facebook
585
585
  # so we only need to test at a high level that it works
586
586
  it "throws an error if the algorithm is unsupported" do
587
- allow(MultiJson).to receive(:load).and_return("algorithm" => "my fun algorithm")
587
+ allow(JSON).to receive(:load).and_return("algorithm" => "my fun algorithm")
588
588
  expect { @oauth.parse_signed_request(@signed_params) }.to raise_error(Koala::Facebook::OAuthSignatureError)
589
589
  end
590
590
 
@@ -74,58 +74,58 @@ graph_api:
74
74
  no_token: '{"facebook":"{}","koppel":"{}"}'
75
75
 
76
76
  # Ruby 1.8.7 and 1.9.2 generate JSON with different key ordering, hence we have to dynamically generate it here
77
- batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "koppel"}]) %>:
77
+ batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "koppel"}]) %>:
78
78
  post:
79
79
  with_token: '[{"code": 200, "body":"{\"id\":\"123\"}"}, {"code": 200, "body":"{\"id\":\"456\"}"}]'
80
- batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me/picture"}]) %>:
80
+ batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me/picture"}]) %>:
81
81
  post:
82
82
  with_token: '[{"code": 302, "headers":[{"name":"Location","value":"http://google.com"}]}]'
83
- batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me/picture?redirect=false"}]) %>:
83
+ batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me/picture?redirect=false"}]) %>:
84
84
  post:
85
85
  with_token: '[{"code": 200, "body":"{\"data\":{\"is_silhouette\":false,\"url\":\"http:\/\/google.com\"}}"}]'
86
- batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "me/friends"}]) %>:
86
+ batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "me/friends"}]) %>:
87
87
  post:
88
88
  with_token: '[{"code": 200, "body":"{\"id\":\"koppel\"}"}, {"code": 200, "body":"{\"data\":[{\"id\":\"lukeshepard\"}],\"paging\":{}}"}]'
89
- batch=<%= MultiJson.dump([{"method"=>"get", "relative_url"=>"me"}, {"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
89
+ batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"me"}, {"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
90
90
  post:
91
91
  with_token: '[{"code": 200, "body":"{\"id\":\"123\"}"}, {"code": 200, "body":"{\"data\":[],\"paging\":{}}"}]'
92
- batch=<%= MultiJson.dump([{"method"=>"get", "relative_url"=>"2/invalidconnection"}, {"method"=>"get", "relative_url"=>"koppel?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
92
+ batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"2/invalidconnection"}, {"method"=>"get", "relative_url"=>"koppel?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
93
93
  post:
94
94
  with_token: '[{"code": 400, "body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},{"code": 200, "body":"{\"id\":\"123\"}"}]'
95
- batch=<%= MultiJson.dump([{"method"=>"post", "relative_url"=>"FEED_ITEM_BATCH/likes"}, {"method"=>"delete", "relative_url"=> "FEED_ITEM_BATCH"}]) %>:
95
+ batch=<%= JSON.dump([{"method"=>"post", "relative_url"=>"FEED_ITEM_BATCH/likes"}, {"method"=>"delete", "relative_url"=> "FEED_ITEM_BATCH"}]) %>:
96
96
  post:
97
97
  with_token: '[{"code": 200, "body": "{\"id\": \"MOCK_LIKE\"}"},{"code": 200, "body":true}]'
98
- batch=<%= MultiJson.dump([{"method" => "post", "relative_url" => "method/fql.query", "body" => "query=select+first_name+from+user+where+uid%3D2905623"}]) %>:
98
+ batch=<%= JSON.dump([{"method" => "post", "relative_url" => "method/fql.query", "body" => "query=select+first_name+from+user+where+uid%3D2905623"}]) %>:
99
99
  post:
100
100
  with_token: '[{"code": 200, "body":"[{\"first_name\":\"Alex\"}]"}]'
101
101
 
102
102
  # dependencies
103
- batch=<%= MultiJson.dump([{"method"=>"get", "relative_url"=>"me", "name" => "getme"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getme"}]) %>:
103
+ batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"me", "name" => "getme"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getme"}]) %>:
104
104
  post:
105
105
  with_token: '[null,{"code": 200, "body":"{\"id\":\"123\"}"}]'
106
- batch=<%= MultiJson.dump([{"method"=>"get", "relative_url"=>"2/invalidconnection", "name" => "getdata"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getdata"}]) %>:
106
+ batch=<%= JSON.dump([{"method"=>"get", "relative_url"=>"2/invalidconnection", "name" => "getdata"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getdata"}]) %>:
107
107
  post:
108
108
  with_token: '[{"code": 400, "body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]'
109
- batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>:
109
+ batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>:
110
110
  post:
111
111
  with_token: '[null,{"code": 200, "body":"{}"}]'
112
- batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends", "omit_response_on_success" => false}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>:
112
+ batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends", "omit_response_on_success" => false}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>:
113
113
  post:
114
114
  with_token: '[{"code": 200, "body":"{\"data\":[],\"paging\":{}}"},{"code": 200, "body":"{}"}]'
115
- batch=<%= MultiJson.dump([{"method" => "get", "relative_url" => "me/friends?limit=5"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=i-dont-exist:$.data.*.id}"}"}]) %>:
115
+ batch=<%= JSON.dump([{"method" => "get", "relative_url" => "me/friends?limit=5"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=i-dont-exist:$.data.*.id}"}"}]) %>:
116
116
  post:
117
117
  with_token:
118
118
  code: 400
119
119
  body: '{"error_code":190,"error_description":"Error validating access token."}'
120
120
 
121
121
  # attached files tests
122
- batch=<%= MultiJson.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]:
122
+ batch=<%= JSON.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]:
123
123
  post:
124
124
  with_token: '[{"code": 400, body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]'
125
- batch=<%= MultiJson.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]:
125
+ batch=<%= JSON.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]:
126
126
  post:
127
127
  with_token: '[{"code": 200, "body":"{\"id\": \"MOCK_PHOTO\"}"}]'
128
- batch=<%= MultiJson.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}, {"method"=>"post", "relative_url"=>"koppel/photos", "attached_files" => "op2_file0"}]) %>&op1_file0=[FILE]&op2_file0=[FILE]:
128
+ batch=<%= JSON.dump([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}, {"method"=>"post", "relative_url"=>"koppel/photos", "attached_files" => "op2_file0"}]) %>&op1_file0=[FILE]&op2_file0=[FILE]:
129
129
  post:
130
130
  with_token: '[{"code": 200, "body":"{\"id\": \"MOCK_PHOTO\"}"}, {"code": 200, "body":"{\"id\": \"MOCK_PHOTO\"}"}]'
131
131
 
@@ -166,7 +166,7 @@ graph_api:
166
166
  link=http://oauth.twoalex.com/&message=Hello, world, from the test suite again!&name=OAuth Playground:
167
167
  post:
168
168
  with_token: '{"id": "FEED_ITEM_CONTEXT"}'
169
- link=http://oauth.twoalex.com/&message=body&name=It's a big question&picture=http://oauth.twoalex.com//images/logo.png&properties=<%= MultiJson.encode({"Link1"=>{"text"=>"Left", "href"=>"http://oauth.twoalex.com/"}, "other" => {"text"=>"Straight ahead", "href"=>"http://oauth.twoalex.com/?"}}) %>&type=link:
169
+ link=http://oauth.twoalex.com/&message=body&name=It's a big question&picture=http://oauth.twoalex.com//images/logo.png&properties=<%= JSON.dump({"Link1"=>{"text"=>"Left", "href"=>"http://oauth.twoalex.com/"}, "other" => {"text"=>"Straight ahead", "href"=>"http://oauth.twoalex.com/?"}}) %>&type=link:
170
170
  post:
171
171
  with_token: '{"id": "FEED_ITEM_DICTIONARY"}'
172
172
 
@@ -216,6 +216,9 @@ graph_api:
216
216
  get:
217
217
  with_token: '{"id": 1, "name": 1, "updated_time": 1}'
218
218
  no_token: '{"id": 1, "name": 1}'
219
+ metadata=1:
220
+ get:
221
+ with_token: '{"name": "Alex Koppel","metadata": {"fields": [{"name": "id"}],"type": "user","connections": {}},"id": "2905623"}'
219
222
 
220
223
  /facebook:
221
224
  no_args:
@@ -302,11 +305,11 @@ graph_api:
302
305
  get:
303
306
  <<: *token_required
304
307
  with_token: '[{"read_stream":1}]'
305
- 'q=<%= MultiJson.dump({"query1" => "select post_id from stream where source_id = me()", "query2" => "select fromid from comment where post_id in (select post_id from #query1)", "query3" => "select uid, name from user where uid in (select fromid from #query2)"}) %>':
308
+ 'q=<%= JSON.dump({"query1" => "select post_id from stream where source_id = me()", "query2" => "select fromid from comment where post_id in (select post_id from #query1)", "query3" => "select uid, name from user where uid in (select fromid from #query2)"}) %>':
306
309
  get:
307
310
  <<: *token_required
308
311
  with_token: '[{"name":"query1", "fql_result_set":[]},{"name":"query2", "fql_result_set":[]},{"name":"query3", "fql_result_set":[]}]'
309
- 'q=<%= MultiJson.dump({"query1" => "select uid, first_name from user where uid = 2901279", "query2" => "select uid, first_name from user where uid = 2905623"}) %>':
312
+ 'q=<%= JSON.dump({"query1" => "select uid, first_name from user where uid = 2901279", "query2" => "select uid, first_name from user where uid = 2905623"}) %>':
310
313
  get:
311
314
  with_token: '[{"name":"query1", "fql_result_set":[{"uid":2901279,"first_name":"Luke"}]},{"name":"query2", "fql_result_set":[{"uid":"2905623","first_name":"Alex"}]}]'
312
315
  no_token: '[{"name":"query1", "fql_result_set":[{"uid":2901279,"first_name":"Luke"}]},{"name":"query2", "fql_result_set":[{"uid":"2905623","first_name":"Alex"}]}]'
@@ -325,7 +328,7 @@ graph_api:
325
328
 
326
329
 
327
330
  '/<%= APP_ID %>':
328
- restrictions=<%= MultiJson.dump({"age_distr" => "13+"}) %>:
331
+ restrictions=<%= JSON.dump({"age_distr" => "13+"}) %>:
329
332
  post:
330
333
  with_token: "true"
331
334
 
@@ -188,7 +188,7 @@ shared_examples_for "Koala GraphAPI" do
188
188
  it "passes a queries argument" do
189
189
  queries = double('query string')
190
190
  queries_json = "some JSON"
191
- allow(MultiJson).to receive(:dump).with(queries).and_return(queries_json)
191
+ allow(JSON).to receive(:dump).with(queries).and_return(queries_json)
192
192
 
193
193
  expect(@api).to receive(:get_object).with(anything, hash_including(:q => queries_json), anything)
194
194
  @api.fql_multiquery(queries)
@@ -234,6 +234,14 @@ shared_examples_for "Koala GraphAPI with an access token" do
234
234
  result = @api.get_objects([KoalaTest.page, KoalaTest.user1])
235
235
  expect(result.length).to eq(2)
236
236
  end
237
+
238
+ describe "#get_object_metadata" do
239
+ it "can access an object's metadata" do
240
+ result = @api.get_object_metadata(KoalaTest.user1)
241
+ expect(result["type"]).to eq("user")
242
+ end
243
+ end
244
+
237
245
  it "can access connections from users" do
238
246
  result = @api.get_connections(KoalaTest.user2, "friends")
239
247
  expect(result.length).to be > 0
@@ -485,7 +493,7 @@ shared_examples_for "Koala GraphAPI with an access token" do
485
493
  end
486
494
 
487
495
  it "JSON-encodes the restrictions" do
488
- expect(@app_api).to receive(:graph_call).with(anything, hash_including(:restrictions => MultiJson.dump(@restrictions)), anything, anything)
496
+ expect(@app_api).to receive(:graph_call).with(anything, hash_including(:restrictions => JSON.dump(@restrictions)), anything, anything)
489
497
  @app_api.set_app_restrictions(KoalaTest.app_id, @restrictions)
490
498
  end
491
499
 
@@ -243,7 +243,7 @@ module KoalaTest
243
243
  require 'typhoeus/adapters/faraday' if adapter.to_s == "typhoeus"
244
244
  Faraday.default_adapter = adapter.to_sym
245
245
  end
246
- rescue LoadError
246
+ rescue ParserError
247
247
  puts "Unable to load adapter #{adapter}, using Net::HTTP."
248
248
  ensure
249
249
  @adapter_activation_attempted = true
@@ -5,9 +5,6 @@ module Koala
5
5
  module MockHTTPService
6
6
  include Koala::HTTPService
7
7
 
8
- # fix our specs to use ok_json, so we always get the same results from to_json
9
- MultiJson.use :ok_json
10
-
11
8
  # Mocks all HTTP requests for with koala_spec_with_mocks.rb
12
9
  # Mocked values to be included in TEST_DATA used in specs
13
10
  ACCESS_TOKEN = '*'
@@ -91,7 +88,7 @@ module Koala
91
88
  args = arguments.inject({}) do |hash, (k, v)|
92
89
  # ensure our args are all stringified
93
90
  value = if v.is_a?(String)
94
- should_json_decode?(v) ? MultiJson.load(v) : v
91
+ should_json_decode?(v) ? JSON.load(v) : v
95
92
  elsif v.is_a?(Koala::UploadableIO)
96
93
  # obviously there are no files in the yaml
97
94
  "[FILE]"
@@ -122,7 +119,7 @@ module Koala
122
119
  # will remove +'s in restriction strings
123
120
  string.split("&").reduce({}) do |hash, component|
124
121
  k, v = component.split("=", 2) # we only care about the first =
125
- value = should_json_decode?(v) ? MultiJson.decode(v) : v.to_s rescue v.to_s
122
+ value = should_json_decode?(v) ? JSON.load(v) : v.to_s rescue v.to_s
126
123
  # some special-casing, unfortunate but acceptable in this testing
127
124
  # environment
128
125
  value = nil if value.empty?
@@ -126,7 +126,7 @@ shared_examples_for "Koala RestAPI with an access token" do
126
126
  describe "#set_app_properties" do
127
127
  it "sends Facebook the properties JSON-encoded as :properties" do
128
128
  props = {:a => 2, :c => [1, 2, "d"]}
129
- expect(@api).to receive(:rest_call).with(anything, hash_including(:properties => MultiJson.dump(props)), anything, anything)
129
+ expect(@api).to receive(:rest_call).with(anything, hash_including(:properties => JSON.dump(props)), anything, anything)
130
130
  @api.set_app_properties(props)
131
131
  end
132
132
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koala
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Koppel
@@ -10,20 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: multi_json
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.3.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 1.3.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: faraday
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -144,9 +130,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
130
  version: '0'
145
131
  required_rubygems_version: !ruby/object:Gem::Requirement
146
132
  requirements:
147
- - - ">="
133
+ - - ">"
148
134
  - !ruby/object:Gem::Version
149
- version: '0'
135
+ version: 1.3.1
150
136
  requirements: []
151
137
  rubyforge_project:
152
138
  rubygems_version: 2.4.6