koala 2.2.0rc2 → 2.2.0rc3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1e7b90f3b13d2c6f60d4c8a9e34204de7ab9ab3
4
- data.tar.gz: c32873fb598b147a635937b11185ee50c1447655
3
+ metadata.gz: 9d723adaf8f3575e75b06fbb1b71d1736f3dafd1
4
+ data.tar.gz: ce7831b6eb0075a69fc90ffae8ac9a2a1fb18e2b
5
5
  SHA512:
6
- metadata.gz: b1bf5427055f2839d424134140869c1b37d6bc79dc9a32f4ea3be347a5fab277d35318a14cc6f6940ed13dbe2ca3084e0dd55f1c6844110bc776fc1e1ec7ab69
7
- data.tar.gz: e8c54ab5045c917872ecab6290157a6a89abd4cfdaa273d84d35293a8d25ae4f445696550365a0c69926b3f00774b37f759f6414102cbe3d10379aeaec5d5142
6
+ metadata.gz: 7fc6c7a281d7ab3381157254b93daa41c3514354da7a886cf4cc60f40b27f0bd360f55120a724b9a139d855303dac36a985db6de0ab374f8048454973bc02159
7
+ data.tar.gz: cee4ec7905570dbe9194d49a6fe0a5748ebb5111252281ca70db17c247a26b31333de4a07e9dffaf09b17061e37c2cfba8ed6d09f40584a316ba1687424bd7a3
@@ -3,6 +3,7 @@ v2.2.0
3
3
 
4
4
  Updated features:
5
5
 
6
+ * Restore API#search, since Facebook still supports that for certain usecases (thanks, vhoof!)
6
7
  * You can now specify format: :json in http_options to make Content-Type application/json requests (thanks, adparlor!)
7
8
  * Koala now supports uploading videos by URL (thanks, filipegiusti!)
8
9
  * GraphCollections now offer direct access to the collection summary data via #summary (thanks, vhoof!)
@@ -312,6 +312,20 @@ module Koala
312
312
  graph_call("#{id}/likes", {}, "delete", options, &block)
313
313
  end
314
314
 
315
+ # Search for a given query among visible Facebook objects.
316
+ # See {http://developers.facebook.com/docs/reference/api/#searching Facebook documentation} for more information.
317
+ #
318
+ # @param search_terms the query to search for
319
+ # @param args additional arguments, such as type, fields, etc.
320
+ # @param options (see #get_object)
321
+ # @param block (see Koala::Facebook::API#api)
322
+ #
323
+ # @return [Koala::Facebook::API::GraphCollection] an array of search results
324
+ def search(search_terms, args = {}, options = {}, &block)
325
+ args.merge!({:q => search_terms}) unless search_terms.nil?
326
+ graph_call("search", args, "get", options, &block)
327
+ end
328
+
315
329
  # Convenience Methods
316
330
  # In general, we're trying to avoid adding convenience methods to Koala
317
331
  # except to support cases where the Facebook API requires non-standard input
@@ -1,3 +1,3 @@
1
1
  module Koala
2
- VERSION = "2.2.0rc2"
2
+ VERSION = "2.2.0rc3"
3
3
  end
data/readme.md CHANGED
@@ -69,7 +69,7 @@ Koala.config.api_version = "v2.0"
69
69
 
70
70
  The response of most requests is the JSON data returned from the Facebook servers as a Hash.
71
71
 
72
- When retrieving data that returns an array of results (for example, when calling `API#get_connections`)
72
+ When retrieving data that returns an array of results (for example, when calling `API#get_connections` or `API#search`)
73
73
  a GraphCollection object will be returned, which makes it easy to page through the results:
74
74
 
75
75
  ```ruby
@@ -271,6 +271,16 @@ graph_api:
271
271
  code: 500
272
272
  body: '{"error": {"type": "Exception","message": "No node specified"}}'
273
273
 
274
+ /search:
275
+ q=facebook:
276
+ get:
277
+ with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
278
+ no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
279
+ "limit=25&q=facebook&until=<%= TEST_DATA['search_time'] %>":
280
+ get:
281
+ with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
282
+ no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
283
+
274
284
  /fql:
275
285
  q=select uid, first_name from user where uid = 2901279:
276
286
  get:
@@ -51,6 +51,12 @@ shared_examples_for "Koala GraphAPI" do
51
51
  end
52
52
  end
53
53
 
54
+ # SEARCH
55
+ it "can search" do
56
+ result = @api.search("facebook")
57
+ expect(result.length).to be_an(Integer)
58
+ end
59
+
54
60
  # DATA
55
61
  # access public info
56
62
 
@@ -117,6 +123,12 @@ shared_examples_for "Koala GraphAPI" do
117
123
  expect(result["http://developers.facebook.com/blog/post/490"] && result["http://developers.facebook.com/blog/post/472"]).to be_truthy
118
124
  end
119
125
 
126
+ # SEARCH
127
+ it "can search" do
128
+ result = @api.search("facebook")
129
+ expect(result.length).to be_an(Integer)
130
+ end
131
+
120
132
  # PAGING THROUGH COLLECTIONS
121
133
  # see also graph_collection_tests
122
134
  it "makes a request for a page when provided a specific set of page params" do
@@ -534,6 +546,7 @@ shared_examples_for "Koala GraphAPI with an access token" do
534
546
  :put_wall_post => 4,
535
547
  :put_comment => 3,
536
548
  :put_like => 2, :delete_like => 2,
549
+ :search => 3,
537
550
  :set_app_restrictions => 4,
538
551
  :get_page_access_token => 3,
539
552
  :fql_query => 3, :fql_multiquery => 3,
@@ -582,10 +595,26 @@ shared_examples_for "Koala GraphAPI with GraphCollection" do
582
595
  expect(@api.get_connections(KoalaTest.page, "photos")).to be_nil
583
596
  end
584
597
 
598
+ it "gets a GraphCollection when searching" do
599
+ result = @api.search("facebook")
600
+ expect(result).to be_a(Koala::Facebook::GraphCollection)
601
+ end
602
+
603
+ it "returns nil if the search call fails with nil" do
604
+ # this happens sometimes
605
+ expect(@api).to receive(:graph_call).and_return(nil)
606
+ expect(@api.search("facebook")).to be_nil
607
+ end
608
+
609
+ it "gets a GraphCollection when paging through results" do
610
+ @results = @api.get_page(["search", {"q"=>"facebook", "limit"=>"25", "until"=> KoalaTest.search_time}])
611
+ expect(@results).to be_a(Koala::Facebook::GraphCollection)
612
+ end
613
+
585
614
  it "returns nil if the page call fails with nil" do
586
615
  # this happens sometimes
587
616
  expect(@api).to receive(:graph_call).and_return(nil)
588
- expect(@api.get_connections(KoalaTest.page, "photos")).to be_nil
617
+ expect(@api.get_page(["search", {"q"=>"facebook", "limit"=>"25", "until"=> KoalaTest.search_time}])).to be_nil
589
618
  end
590
619
  end
591
620
  end
@@ -3,7 +3,7 @@ module KoalaTest
3
3
 
4
4
  class << self
5
5
  attr_accessor :oauth_token, :app_id, :secret, :app_access_token, :code, :session_key
6
- attr_accessor :oauth_test_data, :subscription_test_data
6
+ attr_accessor :oauth_test_data, :subscription_test_data, :search_time
7
7
  attr_accessor :test_user_api
8
8
  attr_accessor :vcr_oauth_token
9
9
  end
@@ -107,6 +107,9 @@ module KoalaTest
107
107
  self.session_key = data["oauth_test_data"]["session_key"]
108
108
 
109
109
  self.vcr_oauth_token = data["vcr_data"]["oauth_token"]
110
+
111
+ # fix the search time so it can be used in the mock responses
112
+ self.search_time = data["search_time"] || (Time.now - 3600).to_s
110
113
  end
111
114
 
112
115
  def self.testing_permissions
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.2.0rc2
4
+ version: 2.2.0rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Koppel