fb_graph 2.7.14 → 2.7.15

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: 750927031ebf79366752c4d160d4325df2494864
4
- data.tar.gz: 2856aaea697629e81c13d335614ddfab5fd02bc9
3
+ metadata.gz: 368ca9c527e97ab552c51958ff0614ea86dd0d8b
4
+ data.tar.gz: 5ff8b37a4ea646ccb4a912848ba0cf7e782fee28
5
5
  SHA512:
6
- metadata.gz: 38a2f8f43c5821fa9e2bb7de372e1dbf736a4adf4f88ec102ff512278c390c11bb37691d58a902780ae44758c8568fab478050a402a39b9047eeac5495248dba
7
- data.tar.gz: fe7f26f2efd98cb43b924e4e3bddf810fc0c733e17c5a3b7bd2e76b923dffa3ada434e702325275291b1d4d9381a012cef45c74331d15aeb5b53ab70ecc7f953
6
+ metadata.gz: 6ad52e162c283b9e57293a7d351fcd6e5ff8af8896cae381bc3e55674221fda4607d5c7a349b53f61765c2284647e7a8cba091c64c37aea5b72cf0ef7be560e0
7
+ data.tar.gz: eda16eacf3f3aeac3dc05e038a45e26e6517c6eb5c31bf1fa19f7d313a9f978b641f4eeb391a75fe2f1bcbda56fe672e48de83f1f37c8c1d4795db688ca837bc
@@ -15,6 +15,13 @@ A full-stack Facebook Graph API wrapper in Ruby.
15
15
  * Subscribe Update Info (https://www.facebook.com/FbGraph)
16
16
  * Q&A on Google Groups (http://groups.google.com/group/fb_graph)
17
17
 
18
+ == Graph API v2.0
19
+
20
+ FbGraph is basically developed for v1.0, and could be buggy for v2.0.
21
+
22
+ Along with adding v2 support to this gem, I also started to develop fb_graph2 as Graph API v2.0 client library.
23
+ https://github.com/nov/fb_graph2
24
+
18
25
  == Examples
19
26
 
20
27
  Now FbGraph supports all objects listed here: http://developers.facebook.com/docs/reference/api/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.7.14
1
+ 2.7.15
@@ -2,17 +2,18 @@ module FbGraph
2
2
  module Connections
3
3
  module Permissions
4
4
  def permissions(options = {})
5
- if FbGraph.v2?
6
- self.connection(:permissions, options).try(:inject, []) do |arr, entry|
5
+ self.connection(:permissions, options).try(:inject, []) do |arr, entry|
6
+ if entry.include? :status
7
+ # v2.0
7
8
  arr << entry[:permission].to_sym if entry[:status] == 'granted'
8
- arr
9
- end || []
10
- else
11
- self.connection(:permissions, options).first.try(:inject, []) do |arr, (key, value)|
12
- arr << key.to_sym if value.to_i == 1
13
- arr
14
- end || []
15
- end
9
+ else
10
+ # v1.0
11
+ entry.each do |key, value|
12
+ arr << key.to_sym if value.to_i == 1
13
+ end
14
+ end
15
+ arr
16
+ end || []
16
17
  end
17
18
 
18
19
  def revoke!(permission = nil, options = {})
@@ -90,7 +90,11 @@ module FbGraph
90
90
  alias_method :cache_collection, :cache_collections
91
91
 
92
92
  def build_endpoint(params = {})
93
- File.join([self.endpoint, params.delete(:connection), params.delete(:connection_scope)].compact.collect(&:to_s))
93
+ _endpoint_ = URI.parse self.endpoint
94
+ if api_version = params.delete(:api_version)
95
+ _endpoint_.path = File.join('/', api_version, _endpoint_.path)
96
+ end
97
+ File.join([_endpoint_.to_s, params.delete(:connection), params.delete(:connection_scope)].compact.collect(&:to_s))
94
98
  end
95
99
 
96
100
  def build_params(params)
@@ -29,40 +29,46 @@ describe FbGraph::Connections::Permissions do
29
29
  end
30
30
 
31
31
  context 'v2 API' do
32
- def mock_v2_graph(response)
33
- stub_request(
34
- :get,
35
- File.join(FbGraph::ROOT_URL, 'v2.0', 'me', 'permissions')
36
- ).with(
37
- request_for(:get, { :params => { :access_token => 'access_token' } })
38
- ).to_return(
39
- { body: response }
40
- )
41
- end
32
+ context 'using global config' do
33
+ before(:each) do
34
+ FbGraph.v2!
35
+ end
42
36
 
43
- before(:each) do
44
- FbGraph.v2!
45
- end
37
+ after(:each) do
38
+ FbGraph.v1!
39
+ end
46
40
 
47
- after(:each) do
48
- FbGraph.v1!
49
- end
41
+ it 'should be an Array of Hash' do
42
+ mock_graph :get, 'v2.0/me/permissions', 'users/permissions/v2', :access_token => 'access_token' do
43
+ permissions = FbGraph::User.me('access_token').permissions
44
+ permissions.should be_instance_of Array
45
+ permissions.should_not be_blank
46
+ permissions.each do |permission|
47
+ permission.should be_instance_of Symbol
48
+ end
49
+ end
50
+ end
50
51
 
51
- it 'should be an Array of Hash' do
52
- mock_v2_graph("{\"data\":[{\"permission\":\"installed\",\"status\":\"granted\"},{\"permission\": \"public_profile\",\"status\": \"granted\"}]}")
53
- permissions = FbGraph::User.me('access_token').permissions
54
- permissions.should be_instance_of Array
55
- permissions.should_not be_blank
56
- permissions.each do |permission|
57
- permission.should be_instance_of Symbol
52
+ context 'when blank' do
53
+ it 'should return blank array' do
54
+ mock_graph :get, 'v2.0/me/permissions', 'users/permissions/blank', :access_token => 'access_token' do
55
+ permissions = FbGraph::User.me('access_token').permissions
56
+ permissions.should == []
57
+ end
58
+ end
58
59
  end
59
60
  end
60
61
 
61
- context 'when blank' do
62
- it 'should return blank array' do
63
- mock_v2_graph("{\"data\":[]}")
64
- permissions = FbGraph::User.me('access_token').permissions
65
- permissions.should == []
62
+ context 'using local config' do
63
+ it 'should be an Array of Hash' do
64
+ mock_graph :get, 'v2.0/me/permissions', 'users/permissions/v2', :access_token => 'access_token' do
65
+ permissions = FbGraph::User.me('access_token').permissions(:api_version => 'v2.0')
66
+ permissions.should be_instance_of Array
67
+ permissions.should_not be_blank
68
+ permissions.each do |permission|
69
+ permission.should be_instance_of Symbol
70
+ end
71
+ end
66
72
  end
67
73
  end
68
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.14
4
+ version: 2.7.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake