fb_graph2 0.4.1 → 0.4.3
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 +4 -4
- data/VERSION +1 -1
- data/lib/fb_graph2/event.rb +1 -0
- data/lib/fb_graph2/group.rb +1 -0
- data/lib/fb_graph2/page.rb +1 -0
- data/lib/fb_graph2/place.rb +4 -0
- data/lib/fb_graph2/searchable/result.rb +32 -0
- data/lib/fb_graph2/searchable.rb +27 -0
- data/lib/fb_graph2/struct/education.rb +2 -2
- data/lib/fb_graph2/user.rb +1 -0
- data/lib/fb_graph2.rb +1 -0
- data/spec/fb_graph2/searchable_spec.rb +50 -0
- data/spec/fb_graph2_spec.rb +1 -1
- data/spec/mock_json/search/user.json +9 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27eba51717bb5b667d0e6c6f4919c4d896c7c444
|
4
|
+
data.tar.gz: 51dc48b5d3239da4c9573c217d95e85c4825e13f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 322128ddffe2d900508098b9098b1d71a1c492d755cea87c3be3d9d6ccfa0de945433f51fe4532234b4d1d3b5d39615b1b3404284ee21a661bd46387efe6d368
|
7
|
+
data.tar.gz: 9c2eaae75431949e4b659ded3a719483df74cb0d5000449050acac8519bd32e9f580b5d68b70114c567d911a5c8240ae888bba885293f4a4b930f618cdd0d424
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/lib/fb_graph2/event.rb
CHANGED
data/lib/fb_graph2/group.rb
CHANGED
data/lib/fb_graph2/page.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module FbGraph2
|
2
|
+
module Searchable
|
3
|
+
class Result < Collection
|
4
|
+
attr_accessor :query, :access_token, :klass, :collection, :options
|
5
|
+
|
6
|
+
def initialize(query, access_token, klass, options = {})
|
7
|
+
@klass = klass
|
8
|
+
@access_token = access_token
|
9
|
+
@query = query
|
10
|
+
@options = options
|
11
|
+
@collection = options.delete(:collection) || Collection.new
|
12
|
+
replace @collection
|
13
|
+
end
|
14
|
+
|
15
|
+
def next(_options_ = {})
|
16
|
+
if collection.next.present?
|
17
|
+
klass.search query, access_token, options.merge(_options_).merge(collection.next)
|
18
|
+
else
|
19
|
+
self.class.new query, access_token, klass
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def previous(_options_ = {})
|
24
|
+
if collection.previous.present?
|
25
|
+
klass.search query, access_token, options.merge(_options_).merge(collection.previous)
|
26
|
+
else
|
27
|
+
self.class.new query, access_token, klass
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module FbGraph2
|
2
|
+
module Searchable
|
3
|
+
def self.search(query, access_token, options = {})
|
4
|
+
klass = options.delete(:class) || Searchable
|
5
|
+
collection = Collection.new(
|
6
|
+
Node.new(:search).authenticate(
|
7
|
+
access_token
|
8
|
+
).send(:get, options.merge(q: query))
|
9
|
+
)
|
10
|
+
yield collection if block_given?
|
11
|
+
Searchable::Result.new(query, access_token, klass, options.merge(:collection => collection))
|
12
|
+
end
|
13
|
+
|
14
|
+
def search(query, access_token, options = {})
|
15
|
+
type = self.to_s.split('::').last.underscore
|
16
|
+
Searchable.search(query, access_token, options.merge(:type => type, :class => self)) do |collection|
|
17
|
+
collection.map! do |obj|
|
18
|
+
self.new(obj[:id], obj.merge(
|
19
|
+
:access_token => options[:access_token]
|
20
|
+
))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'fb_graph2/searchable/result'
|
data/lib/fb_graph2/user.rb
CHANGED
data/lib/fb_graph2.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph2::Searchable do
|
4
|
+
describe 'search' do
|
5
|
+
context 'User' do
|
6
|
+
it 'should return users' do
|
7
|
+
users = mock_graph :get, 'search', 'search/user', access_token: 'token', params: {
|
8
|
+
q: 'nov.matake',
|
9
|
+
type: 'user'
|
10
|
+
} do
|
11
|
+
FbGraph2::User.search 'nov.matake', 'token'
|
12
|
+
end
|
13
|
+
users.should be_instance_of FbGraph2::Searchable::Result
|
14
|
+
users.should_not be_empty
|
15
|
+
users.each do |user|
|
16
|
+
user.should be_instance_of FbGraph2::User
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'pagination' do
|
23
|
+
context 'when first page' do
|
24
|
+
let :page1 do
|
25
|
+
mock_graph :get, 'search', 'search/user', access_token: 'token', params: {
|
26
|
+
q: 'nov.matake',
|
27
|
+
type: 'user'
|
28
|
+
} do
|
29
|
+
FbGraph2::User.search 'nov.matake', 'token'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should have next' do
|
34
|
+
mock_graph :get, 'search', 'blank_collection', access_token: 'token', params: {
|
35
|
+
q: 'nov.matake',
|
36
|
+
type: 'user',
|
37
|
+
__after_id: 'enc_AeyyBJc7uo9gY-nHN9-LM0yG_IKBN5nCmqdkG8b4Ql-COLTnpQ-2NUc-xSDK6VwPhsq2W9Ktnr0zf7dD25Bc9eKT',
|
38
|
+
limit: 5000,
|
39
|
+
offset: 5000
|
40
|
+
} do
|
41
|
+
page1.next
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should have no previous' do
|
46
|
+
page1.previous.should be_blank
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/spec/fb_graph2_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe FbGraph2 do
|
|
8
8
|
its(:logger) { should be_a Logger }
|
9
9
|
its(:api_version) { should == 'v2.0' }
|
10
10
|
its(:root_url) { should == 'https://graph.facebook.com' }
|
11
|
-
its(:object_classes) { should contain_exactly *FbGraph2::Node.subclasses }
|
11
|
+
its(:object_classes) { should contain_exactly *FbGraph2::Node.subclasses + [FbGraph2::Place] }
|
12
12
|
it { should_not be_debugging }
|
13
13
|
end
|
14
14
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
{
|
2
|
+
"data": [{
|
3
|
+
"name": "Nov Matake",
|
4
|
+
"id": "426118390869327"
|
5
|
+
}],
|
6
|
+
"paging": {
|
7
|
+
"next": "https:\/\/graph.facebook.com\/v2.0\/search?type=user&q=nov.matake&limit=5000&offset=5000&__after_id=enc_AeyyBJc7uo9gY-nHN9-LM0yG_IKBN5nCmqdkG8b4Ql-COLTnpQ-2NUc-xSDK6VwPhsq2W9Ktnr0zf7dD25Bc9eKT"
|
8
|
+
}
|
9
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb_graph2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nov matake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -247,12 +247,15 @@ files:
|
|
247
247
|
- lib/fb_graph2/page_category.rb
|
248
248
|
- lib/fb_graph2/payment.rb
|
249
249
|
- lib/fb_graph2/photo.rb
|
250
|
+
- lib/fb_graph2/place.rb
|
250
251
|
- lib/fb_graph2/place_tag.rb
|
251
252
|
- lib/fb_graph2/post.rb
|
252
253
|
- lib/fb_graph2/request.rb
|
253
254
|
- lib/fb_graph2/request_filter/authenticator.rb
|
254
255
|
- lib/fb_graph2/request_filter/debugger.rb
|
255
256
|
- lib/fb_graph2/review.rb
|
257
|
+
- lib/fb_graph2/searchable.rb
|
258
|
+
- lib/fb_graph2/searchable/result.rb
|
256
259
|
- lib/fb_graph2/struct.rb
|
257
260
|
- lib/fb_graph2/struct/action.rb
|
258
261
|
- lib/fb_graph2/struct/age_range.rb
|
@@ -346,6 +349,7 @@ files:
|
|
346
349
|
- spec/fb_graph2/page_spec.rb
|
347
350
|
- spec/fb_graph2/request_filter/authenticator_spec.rb
|
348
351
|
- spec/fb_graph2/request_filter/debugger_spec.rb
|
352
|
+
- spec/fb_graph2/searchable_spec.rb
|
349
353
|
- spec/fb_graph2/token_metadata_spec.rb
|
350
354
|
- spec/fb_graph2/user_spec.rb
|
351
355
|
- spec/fb_graph2/util_spec.rb
|
@@ -380,6 +384,7 @@ files:
|
|
380
384
|
- spec/mock_json/post/liked_and_commented.json
|
381
385
|
- spec/mock_json/post/likes.json
|
382
386
|
- spec/mock_json/post/shared_posts.json
|
387
|
+
- spec/mock_json/search/user.json
|
383
388
|
- spec/mock_json/success_true.json
|
384
389
|
- spec/mock_json/success_with_id.json
|
385
390
|
- spec/mock_json/token_metadata/app_token.json
|
@@ -443,7 +448,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
443
448
|
version: '0'
|
444
449
|
requirements: []
|
445
450
|
rubyforge_project:
|
446
|
-
rubygems_version: 2.
|
451
|
+
rubygems_version: 2.4.5
|
447
452
|
signing_key:
|
448
453
|
specification_version: 4
|
449
454
|
summary: Facebook Graph API v2.0 Wrapper in Ruby
|