fb_graph 2.5.5 → 2.5.6
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.
- data/.gitignore +1 -0
- data/Gemfile.lock +6 -6
- data/VERSION +1 -1
- data/lib/fb_graph/album.rb +11 -5
- data/lib/fb_graph/connections/picture.rb +25 -5
- data/lib/fb_graph/node.rb +0 -1
- data/lib/fb_graph/picture.rb +12 -0
- data/lib/fb_graph.rb +1 -0
- data/spec/fb_graph/album_spec.rb +14 -7
- data/spec/fb_graph/connections/picture_spec.rb +50 -4
- data/spec/mock_json/albums/picture/success.json +5 -0
- data/spec/mock_json/users/picture/success.json +6 -0
- metadata +13 -2
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fb_graph (2.5.
|
4
|
+
fb_graph (2.5.6)
|
5
5
|
httpclient (>= 2.2.0.2)
|
6
6
|
json
|
7
7
|
rack-oauth2 (>= 0.14.4)
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
multi_json (~> 1.0)
|
29
29
|
addressable (2.3.2)
|
30
30
|
attr_required (0.0.5)
|
31
|
-
builder (3.0.
|
31
|
+
builder (3.0.4)
|
32
32
|
configatron (2.9.1)
|
33
33
|
yamler (>= 0.1.0)
|
34
34
|
cover_me (1.2.0)
|
@@ -54,7 +54,7 @@ GEM
|
|
54
54
|
i18n
|
55
55
|
multi_json (>= 1.3.6)
|
56
56
|
rack (>= 1.1)
|
57
|
-
rack-test (0.6.
|
57
|
+
rack-test (0.6.2)
|
58
58
|
rack (>= 1.0)
|
59
59
|
rake (0.9.2.2)
|
60
60
|
rspec (2.11.0)
|
@@ -64,14 +64,14 @@ GEM
|
|
64
64
|
rspec-core (2.11.1)
|
65
65
|
rspec-expectations (2.11.3)
|
66
66
|
diff-lcs (~> 1.1.3)
|
67
|
-
rspec-mocks (2.11.
|
67
|
+
rspec-mocks (2.11.3)
|
68
68
|
sprockets (2.1.3)
|
69
69
|
hike (~> 1.2)
|
70
70
|
rack (~> 1.0)
|
71
71
|
tilt (~> 1.1, != 1.3.0)
|
72
72
|
tilt (1.3.3)
|
73
|
-
tzinfo (0.3.
|
74
|
-
webmock (1.8.
|
73
|
+
tzinfo (0.3.34)
|
74
|
+
webmock (1.8.11)
|
75
75
|
addressable (>= 2.2.7)
|
76
76
|
crack (>= 0.1.7)
|
77
77
|
yamler (0.1.0)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.6
|
data/lib/fb_graph/album.rb
CHANGED
@@ -42,11 +42,17 @@ module FbGraph
|
|
42
42
|
cache_collection attributes, :comments
|
43
43
|
end
|
44
44
|
|
45
|
-
def picture_with_access_token(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
def picture_with_access_token(options_or_size = {})
|
46
|
+
response = picture_without_access_token options_or_size
|
47
|
+
if response.is_a?(FbGraph::Picture)
|
48
|
+
response
|
49
|
+
else
|
50
|
+
_endpoint_ = URI.parse response
|
51
|
+
if self.access_token
|
52
|
+
_endpoint_.query = [_endpoint_.query, {:access_token => self.access_token.to_s}.to_query].compact.join('&')
|
53
|
+
end
|
54
|
+
_endpoint_.to_s
|
55
|
+
end
|
50
56
|
end
|
51
57
|
alias_method_chain :picture, :access_token
|
52
58
|
end
|
@@ -1,12 +1,32 @@
|
|
1
1
|
module FbGraph
|
2
2
|
module Connections
|
3
3
|
module Picture
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
# User can specify size in two ways:
|
5
|
+
# 1. By type: square | small | normal | large
|
6
|
+
# 2. By width and height, so facebook return the _closest_
|
7
|
+
# match to the size you specified, if only one parameter
|
8
|
+
# is set, then facebook will return square image
|
9
|
+
# See: https://developers.facebook.com/docs/reference/api/user/
|
10
|
+
def picture(options_or_size = {})
|
11
|
+
options = if options_or_size.is_a?(String) || options_or_size.is_a?(Symbol)
|
12
|
+
{:type => options_or_size}
|
13
|
+
else
|
14
|
+
options_or_size
|
15
|
+
end
|
16
|
+
_endpoint_ = ["#{self.endpoint}/picture", options.to_query].delete_if(&:blank?).join('?')
|
17
|
+
|
18
|
+
if options[:redirect] == false
|
19
|
+
response = get options.merge(
|
20
|
+
:connection => :picture,
|
21
|
+
|
22
|
+
# NOTE: can be removed when addressable 2.3.3+ released with this fix
|
23
|
+
# https://github.com/sporkmonger/addressable/commit/421a88fed1d2f14426f15158f3712ab563581327
|
24
|
+
:redirect => 'false'
|
25
|
+
)
|
26
|
+
FbGraph::Picture.new response[:data]
|
27
|
+
else
|
28
|
+
_endpoint_
|
8
29
|
end
|
9
|
-
_endpoint_
|
10
30
|
end
|
11
31
|
end
|
12
32
|
end
|
data/lib/fb_graph/node.rb
CHANGED
data/lib/fb_graph.rb
CHANGED
data/spec/fb_graph/album_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FbGraph::Album do
|
4
|
-
|
5
4
|
describe '.new' do
|
6
5
|
it 'should setup all supported attributes' do
|
7
6
|
attributes = {
|
@@ -66,21 +65,29 @@ describe FbGraph::Album do
|
|
66
65
|
|
67
66
|
describe '#picture' do
|
68
67
|
let(:album) { FbGraph::Album.new('12345') }
|
69
|
-
subject { album }
|
68
|
+
subject { album.picture }
|
70
69
|
|
71
70
|
context 'when access token is given' do
|
72
71
|
before { album.access_token = 'access_token' }
|
73
|
-
|
72
|
+
it { should == File.join(FbGraph::ROOT_URL, '12345/picture?access_token=access_token') }
|
74
73
|
it 'should support size' do
|
75
74
|
album.picture(:small).should == File.join(FbGraph::ROOT_URL, '12345/picture?type=small&access_token=access_token')
|
76
75
|
end
|
77
76
|
end
|
78
77
|
|
79
|
-
context '
|
80
|
-
it
|
81
|
-
|
78
|
+
context 'when no access token' do
|
79
|
+
it { should == File.join(FbGraph::ROOT_URL, '12345/picture') }
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when no redirect' do
|
83
|
+
before { album.access_token = 'access_token' }
|
84
|
+
it 'should return FbGraph::Picture' do
|
85
|
+
mock_graph :get, '12345/picture', 'albums/picture/success', :access_token => 'access_token', :params => {
|
86
|
+
:redirect => 'false'
|
87
|
+
} do
|
88
|
+
album.picture(:redirect => false).should be_instance_of FbGraph::Picture
|
89
|
+
end
|
82
90
|
end
|
83
91
|
end
|
84
92
|
end
|
85
|
-
|
86
93
|
end
|
@@ -1,15 +1,44 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FbGraph::Connections::Picture, '#picture' do
|
4
|
-
|
5
4
|
context 'when included by FbGraph::User' do
|
6
5
|
it 'should return image url' do
|
7
6
|
FbGraph::User.new('matake').picture.should == File.join(FbGraph::ROOT_URL, 'matake/picture')
|
8
7
|
end
|
9
8
|
|
10
9
|
it 'should support size option' do
|
11
|
-
[:square, :large].each do |size|
|
10
|
+
[:square, :small, :normal, :large].each do |size|
|
12
11
|
FbGraph::User.new('matake').picture(size).should == File.join(FbGraph::ROOT_URL, "matake/picture?type=#{size}")
|
12
|
+
FbGraph::User.new('matake').picture(:type => size).should == File.join(FbGraph::ROOT_URL, "matake/picture?type=#{size}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should support width option' do
|
17
|
+
FbGraph::User.new('matake').picture(:width => 13).should == File.join(FbGraph::ROOT_URL, "matake/picture?width=13")
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should support height option' do
|
21
|
+
FbGraph::User.new('matake').picture(:height => 37).should == File.join(FbGraph::ROOT_URL, "matake/picture?height=37")
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should support width and height options at the same time' do
|
25
|
+
# Because we can't be sure of order of arguments and order by itself doesn't matter
|
26
|
+
FbGraph::User.new('matake').picture(:width => 13, :height => 37).should satisfy { |uri|
|
27
|
+
[
|
28
|
+
File.join(FbGraph::ROOT_URL, "matake/picture?width=13&height=37"),
|
29
|
+
File.join(FbGraph::ROOT_URL, "matake/picture?height=37&width=13")
|
30
|
+
].include? uri
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when no-redirect' do
|
35
|
+
it 'should return Picture object' do
|
36
|
+
mock_graph :get, 'matake/picture', 'users/picture/success', :params => {
|
37
|
+
:redirect => 'false'
|
38
|
+
} do
|
39
|
+
picture = FbGraph::User.new('matake').picture(:redirect => false)
|
40
|
+
picture.should be_instance_of FbGraph::Picture
|
41
|
+
end
|
13
42
|
end
|
14
43
|
end
|
15
44
|
end
|
@@ -20,10 +49,27 @@ describe FbGraph::Connections::Picture, '#picture' do
|
|
20
49
|
end
|
21
50
|
|
22
51
|
it 'should support size option' do
|
23
|
-
[:square, :large].each do |size|
|
52
|
+
[:square, :small, :normal, :large].each do |size|
|
24
53
|
FbGraph::Page.new('platform').picture(size).should == File.join(FbGraph::ROOT_URL, "platform/picture?type=#{size}")
|
54
|
+
FbGraph::Page.new('platform').picture(:type => size).should == File.join(FbGraph::ROOT_URL, "platform/picture?type=#{size}")
|
25
55
|
end
|
26
56
|
end
|
27
|
-
end
|
28
57
|
|
58
|
+
it 'should support width option' do
|
59
|
+
FbGraph::Page.new('platform').picture(:width => 13).should == File.join(FbGraph::ROOT_URL, "platform/picture?width=13")
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should support height option' do
|
63
|
+
FbGraph::Page.new('platform').picture(:height => 37).should == File.join(FbGraph::ROOT_URL, "platform/picture?height=37")
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should support width and height options at the same time' do
|
67
|
+
FbGraph::Page.new('platform').picture(:width => 13, :height => 37).should satisfy { |uri|
|
68
|
+
[
|
69
|
+
File.join(FbGraph::ROOT_URL, "platform/picture?width=13&height=37"),
|
70
|
+
File.join(FbGraph::ROOT_URL, "platform/picture?height=37&width=13")
|
71
|
+
].include? uri
|
72
|
+
}
|
73
|
+
end
|
74
|
+
end
|
29
75
|
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.5.
|
4
|
+
version: 2.5.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httpclient
|
@@ -312,6 +312,7 @@ files:
|
|
312
312
|
- lib/fb_graph/page.rb
|
313
313
|
- lib/fb_graph/page/category_attributes.rb
|
314
314
|
- lib/fb_graph/photo.rb
|
315
|
+
- lib/fb_graph/picture.rb
|
315
316
|
- lib/fb_graph/place.rb
|
316
317
|
- lib/fb_graph/poke.rb
|
317
318
|
- lib/fb_graph/post.rb
|
@@ -521,6 +522,7 @@ files:
|
|
521
522
|
- spec/mock_json/ad_keywords/buffy_search.json
|
522
523
|
- spec/mock_json/albums/photos/matake_private.json
|
523
524
|
- spec/mock_json/albums/photos/post_with_valid_access_token.json
|
525
|
+
- spec/mock_json/albums/picture/success.json
|
524
526
|
- spec/mock_json/app_token_response.json
|
525
527
|
- spec/mock_json/applications/accounts/private.json
|
526
528
|
- spec/mock_json/applications/achievements/sample.json
|
@@ -687,6 +689,7 @@ files:
|
|
687
689
|
- spec/mock_json/users/notifications/all.json
|
688
690
|
- spec/mock_json/users/outbox/me_private.json
|
689
691
|
- spec/mock_json/users/permissions/me_private.json
|
692
|
+
- spec/mock_json/users/picture/success.json
|
690
693
|
- spec/mock_json/users/pokes/sample.json
|
691
694
|
- spec/mock_json/users/posts/arjun_private.json
|
692
695
|
- spec/mock_json/users/posts/arjun_public.json
|
@@ -720,12 +723,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
720
723
|
- - ! '>='
|
721
724
|
- !ruby/object:Gem::Version
|
722
725
|
version: '0'
|
726
|
+
segments:
|
727
|
+
- 0
|
728
|
+
hash: 77075375696592851
|
723
729
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
724
730
|
none: false
|
725
731
|
requirements:
|
726
732
|
- - ! '>='
|
727
733
|
- !ruby/object:Gem::Version
|
728
734
|
version: '0'
|
735
|
+
segments:
|
736
|
+
- 0
|
737
|
+
hash: 77075375696592851
|
729
738
|
requirements: []
|
730
739
|
rubyforge_project:
|
731
740
|
rubygems_version: 1.8.24
|
@@ -909,6 +918,7 @@ test_files:
|
|
909
918
|
- spec/mock_json/ad_keywords/buffy_search.json
|
910
919
|
- spec/mock_json/albums/photos/matake_private.json
|
911
920
|
- spec/mock_json/albums/photos/post_with_valid_access_token.json
|
921
|
+
- spec/mock_json/albums/picture/success.json
|
912
922
|
- spec/mock_json/app_token_response.json
|
913
923
|
- spec/mock_json/applications/accounts/private.json
|
914
924
|
- spec/mock_json/applications/achievements/sample.json
|
@@ -1075,6 +1085,7 @@ test_files:
|
|
1075
1085
|
- spec/mock_json/users/notifications/all.json
|
1076
1086
|
- spec/mock_json/users/outbox/me_private.json
|
1077
1087
|
- spec/mock_json/users/permissions/me_private.json
|
1088
|
+
- spec/mock_json/users/picture/success.json
|
1078
1089
|
- spec/mock_json/users/pokes/sample.json
|
1079
1090
|
- spec/mock_json/users/posts/arjun_private.json
|
1080
1091
|
- spec/mock_json/users/posts/arjun_public.json
|