fb_graph 2.7.13 → 2.7.14

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: 489cd8d4924f39bc8f9b12b22dca02cf4c2c98e4
4
- data.tar.gz: 82b991866315bd5b8a328ea2626845d8acfdc39c
3
+ metadata.gz: 750927031ebf79366752c4d160d4325df2494864
4
+ data.tar.gz: 2856aaea697629e81c13d335614ddfab5fd02bc9
5
5
  SHA512:
6
- metadata.gz: fb07775401d98bc9e862f62f61c70cd5045ae797da52a08b3ae783ed6e4bd352ff3d2b39a8d731d2c1c695565449f9ddd6333b2f263de09249ad7ec0399cb767
7
- data.tar.gz: d2e6d6ab8d413053382b3a3a57db1026d8cb7eb5289e9980a89ac46d31a47faa7f2cf0ab262c5acc453f7136685a2873ba9e90e6055335d00cf96ae730d0af32
6
+ metadata.gz: 38a2f8f43c5821fa9e2bb7de372e1dbf736a4adf4f88ec102ff512278c390c11bb37691d58a902780ae44758c8568fab478050a402a39b9047eeac5495248dba
7
+ data.tar.gz: fe7f26f2efd98cb43b924e4e3bddf810fc0c733e17c5a3b7bd2e76b923dffa3ada434e702325275291b1d4d9381a012cef45c74331d15aeb5b53ab70ecc7f953
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.7.13
1
+ 2.7.14
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.add_runtime_dependency "multi_json", ">= 1.3"
19
19
  s.add_development_dependency "rake", ">= 0.8"
20
20
  s.add_development_dependency "simplecov"
21
- s.add_development_dependency "rspec", ">= 2"
22
- s.add_development_dependency "fb_graph-mock", ">= 1.0.2"
21
+ s.add_development_dependency "rspec", "< 2.99"
22
+ s.add_development_dependency "fb_graph-mock", ">= 1.0.3"
23
23
  s.add_development_dependency "actionpack", ">= 3.0.6"
24
24
  end
@@ -9,7 +9,27 @@ module FbGraph
9
9
  VERSION = ::File.read(
10
10
  ::File.join(::File.dirname(__FILE__), '../VERSION')
11
11
  ).delete("\n\r")
12
- ROOT_URL = "https://graph.facebook.com"
12
+ ROOT_URL = 'https://graph.facebook.com'
13
+
14
+ def self.v1!
15
+ @v2 = false
16
+ end
17
+ def self.v2!
18
+ @v2 = true
19
+ end
20
+ def self.v1?
21
+ !v2?
22
+ end
23
+ def self.v2?
24
+ !!@v2
25
+ end
26
+ def self.root_url
27
+ if self.v2?
28
+ File.join(ROOT_URL, 'v2.0')
29
+ else
30
+ ROOT_URL
31
+ end
32
+ end
13
33
 
14
34
  def self.logger
15
35
  @@logger
@@ -8,7 +8,7 @@ module FbGraph
8
8
  @client = Rack::OAuth2::Client.new(
9
9
  :identifier => client_id,
10
10
  :secret => client_secret,
11
- :host => URI.parse(ROOT_URL).host,
11
+ :host => URI.parse(FbGraph.root_url).host,
12
12
  :authorization_endpoint => '/oauth/authorize',
13
13
  :token_endpoint => '/oauth/access_token',
14
14
  :redirect_uri => options[:redirect_uri]
@@ -2,10 +2,17 @@ module FbGraph
2
2
  module Connections
3
3
  module Permissions
4
4
  def permissions(options = {})
5
- self.connection(:permissions, options).first.try(:inject, []) do |arr, (key, value)|
6
- arr << key.to_sym if value.to_i == 1
7
- arr
8
- end || []
5
+ if FbGraph.v2?
6
+ self.connection(:permissions, options).try(:inject, []) do |arr, entry|
7
+ 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
16
  end
10
17
 
11
18
  def revoke!(permission = nil, options = {})
@@ -8,7 +8,7 @@ module FbGraph
8
8
 
9
9
  def initialize(identifier, attributes = {})
10
10
  @identifier = identifier
11
- @endpoint = File.join(ROOT_URL, identifier.to_s)
11
+ @endpoint = File.join(FbGraph.root_url, identifier.to_s)
12
12
  @access_token = attributes[:access_token]
13
13
  @raw_attributes = attributes
14
14
  @cached_collections = {}
@@ -69,14 +69,14 @@ describe FbGraph::Album do
69
69
 
70
70
  context 'when access token is given' do
71
71
  before { album.access_token = 'access_token' }
72
- it { should == File.join(FbGraph::ROOT_URL, '12345/picture?access_token=access_token') }
72
+ it { should == File.join(FbGraph.root_url, '12345/picture?access_token=access_token') }
73
73
  it 'should support size' do
74
- album.picture(:small).should == File.join(FbGraph::ROOT_URL, '12345/picture?type=small&access_token=access_token')
74
+ album.picture(:small).should == File.join(FbGraph.root_url, '12345/picture?type=small&access_token=access_token')
75
75
  end
76
76
  end
77
77
 
78
78
  context 'when no access token' do
79
- it { should == File.join(FbGraph::ROOT_URL, '12345/picture') }
79
+ it { should == File.join(FbGraph.root_url, '12345/picture') }
80
80
  end
81
81
 
82
82
  context 'when no redirect' do
@@ -2,23 +2,65 @@ require 'spec_helper'
2
2
 
3
3
  describe FbGraph::Connections::Permissions do
4
4
  describe '#permissions' do
5
- let :permissions do
6
- mock_graph :get, 'me/permissions', 'users/permissions/me_private', :access_token => 'access_token' do
7
- FbGraph::User.me('access_token').permissions
5
+
6
+ context 'v1 API' do
7
+ let :permissions do
8
+ mock_graph :get, 'me/permissions', 'users/permissions/me_private', :access_token => 'access_token' do
9
+ FbGraph::User.me('access_token').permissions
10
+ end
11
+ end
12
+
13
+ it 'should be an Array of Symbol' do
14
+ permissions.should be_instance_of Array
15
+ permissions.should_not be_blank
16
+ permissions.each do |permission|
17
+ permission.should be_instance_of Symbol
18
+ end
8
19
  end
9
- end
10
20
 
11
- it 'should be an Array of Symbol' do
12
- permissions.should be_instance_of Array
13
- permissions.should_not be_blank
14
- permissions.each do |permission|
15
- permission.should be_instance_of Symbol
21
+ context 'when blank' do
22
+ it 'should return blank array' do
23
+ mock_graph :get, 'me/permissions', 'users/permissions/blank', :access_token => 'access_token' do
24
+ permissions = FbGraph::User.me('access_token').permissions
25
+ permissions.should == []
26
+ end
27
+ end
16
28
  end
17
29
  end
18
30
 
19
- context 'when blank' do
20
- it 'should return blank array' do
21
- mock_graph :get, 'me/permissions', 'users/permissions/blank', :access_token => 'access_token' do
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
42
+
43
+ before(:each) do
44
+ FbGraph.v2!
45
+ end
46
+
47
+ after(:each) do
48
+ FbGraph.v1!
49
+ end
50
+
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
58
+ end
59
+ end
60
+
61
+ context 'when blank' do
62
+ it 'should return blank array' do
63
+ mock_v2_graph("{\"data\":[]}")
22
64
  permissions = FbGraph::User.me('access_token').permissions
23
65
  permissions.should == []
24
66
  end
@@ -4,30 +4,30 @@ describe FbGraph::Connections::Picture do
4
4
  describe '#picture' do
5
5
  context 'when included by FbGraph::User' do
6
6
  it 'should return image url' do
7
- FbGraph::User.new('matake').picture.should == File.join(FbGraph::ROOT_URL, 'matake/picture')
7
+ FbGraph::User.new('matake').picture.should == File.join(FbGraph.root_url, 'matake/picture')
8
8
  end
9
9
 
10
10
  it 'should support size option' do
11
11
  [:square, :small, :normal, :large].each do |size|
12
- FbGraph::User.new('matake').picture(size).should == File.join(FbGraph::ROOT_URL, "matake/picture?type=#{size}")
13
- FbGraph::User.new('matake').picture(:type => size).should == File.join(FbGraph::ROOT_URL, "matake/picture?type=#{size}")
12
+ FbGraph::User.new('matake').picture(size).should == File.join(FbGraph.root_url, "matake/picture?type=#{size}")
13
+ FbGraph::User.new('matake').picture(:type => size).should == File.join(FbGraph.root_url, "matake/picture?type=#{size}")
14
14
  end
15
15
  end
16
16
 
17
17
  it 'should support width option' do
18
- FbGraph::User.new('matake').picture(:width => 13).should == File.join(FbGraph::ROOT_URL, "matake/picture?width=13")
18
+ FbGraph::User.new('matake').picture(:width => 13).should == File.join(FbGraph.root_url, "matake/picture?width=13")
19
19
  end
20
20
 
21
21
  it 'should support height option' do
22
- FbGraph::User.new('matake').picture(:height => 37).should == File.join(FbGraph::ROOT_URL, "matake/picture?height=37")
22
+ FbGraph::User.new('matake').picture(:height => 37).should == File.join(FbGraph.root_url, "matake/picture?height=37")
23
23
  end
24
24
 
25
25
  it 'should support width and height options at the same time' do
26
26
  # Because we can't be sure of order of arguments and order by itself doesn't matter
27
27
  FbGraph::User.new('matake').picture(:width => 13, :height => 37).should satisfy { |uri|
28
28
  [
29
- File.join(FbGraph::ROOT_URL, "matake/picture?width=13&height=37"),
30
- File.join(FbGraph::ROOT_URL, "matake/picture?height=37&width=13")
29
+ File.join(FbGraph.root_url, "matake/picture?width=13&height=37"),
30
+ File.join(FbGraph.root_url, "matake/picture?height=37&width=13")
31
31
  ].include? uri
32
32
  }
33
33
  end
@@ -46,29 +46,29 @@ describe FbGraph::Connections::Picture do
46
46
 
47
47
  context 'when included by FbGraph::Page' do
48
48
  it 'should return image url' do
49
- FbGraph::Page.new('platform').picture.should == File.join(FbGraph::ROOT_URL, 'platform/picture')
49
+ FbGraph::Page.new('platform').picture.should == File.join(FbGraph.root_url, 'platform/picture')
50
50
  end
51
51
 
52
52
  it 'should support size option' do
53
53
  [:square, :small, :normal, :large].each do |size|
54
- FbGraph::Page.new('platform').picture(size).should == File.join(FbGraph::ROOT_URL, "platform/picture?type=#{size}")
55
- FbGraph::Page.new('platform').picture(:type => size).should == File.join(FbGraph::ROOT_URL, "platform/picture?type=#{size}")
54
+ FbGraph::Page.new('platform').picture(size).should == File.join(FbGraph.root_url, "platform/picture?type=#{size}")
55
+ FbGraph::Page.new('platform').picture(:type => size).should == File.join(FbGraph.root_url, "platform/picture?type=#{size}")
56
56
  end
57
57
  end
58
58
 
59
59
  it 'should support width option' do
60
- FbGraph::Page.new('platform').picture(:width => 13).should == File.join(FbGraph::ROOT_URL, "platform/picture?width=13")
60
+ FbGraph::Page.new('platform').picture(:width => 13).should == File.join(FbGraph.root_url, "platform/picture?width=13")
61
61
  end
62
62
 
63
63
  it 'should support height option' do
64
- FbGraph::Page.new('platform').picture(:height => 37).should == File.join(FbGraph::ROOT_URL, "platform/picture?height=37")
64
+ FbGraph::Page.new('platform').picture(:height => 37).should == File.join(FbGraph.root_url, "platform/picture?height=37")
65
65
  end
66
66
 
67
67
  it 'should support width and height options at the same time' do
68
68
  FbGraph::Page.new('platform').picture(:width => 13, :height => 37).should satisfy { |uri|
69
69
  [
70
- File.join(FbGraph::ROOT_URL, "platform/picture?width=13&height=37"),
71
- File.join(FbGraph::ROOT_URL, "platform/picture?height=37&width=13")
70
+ File.join(FbGraph.root_url, "platform/picture?width=13&height=37"),
71
+ File.join(FbGraph.root_url, "platform/picture?height=37&width=13")
72
72
  ].include? uri
73
73
  }
74
74
  end
@@ -4,7 +4,7 @@ describe FbGraph::Node do
4
4
 
5
5
  describe '.new' do
6
6
  it 'should setup endpoint' do
7
- FbGraph::Node.new('matake').endpoint.should == File.join(FbGraph::ROOT_URL, 'matake')
7
+ FbGraph::Node.new('matake').endpoint.should == File.join(FbGraph.root_url, 'matake')
8
8
  end
9
9
 
10
10
  it 'should support access_token option' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.13
4
+ version: 2.7.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2014-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -98,30 +98,30 @@ dependencies:
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "<"
102
102
  - !ruby/object:Gem::Version
103
- version: '2'
103
+ version: '2.99'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "<"
109
109
  - !ruby/object:Gem::Version
110
- version: '2'
110
+ version: '2.99'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: fb_graph-mock
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: 1.0.2
117
+ version: 1.0.3
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: 1.0.2
124
+ version: 1.0.3
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: actionpack
127
127
  requirement: !ruby/object:Gem::Requirement