fb_graph 2.5.8 → 2.5.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +19 -18
- data/README.rdoc +10 -0
- data/VERSION +1 -1
- data/lib/fb_graph/connections/picture.rb +6 -0
- data/lib/fb_graph/cover.rb +10 -0
- data/lib/fb_graph/page/category_attributes.rb +9 -13
- data/lib/fb_graph/page.rb +12 -3
- data/lib/fb_graph.rb +1 -0
- data/spec/fb_graph/connections/picture_spec.rb +72 -55
- data/spec/fb_graph/page_spec.rb +6 -4
- data/spec/mock_json/pages/platform_public.json +16 -12
- metadata +3 -8
data/Gemfile.lock
CHANGED
@@ -10,20 +10,20 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: http://rubygems.org/
|
12
12
|
specs:
|
13
|
-
actionpack (3.2.
|
14
|
-
activemodel (= 3.2.
|
15
|
-
activesupport (= 3.2.
|
13
|
+
actionpack (3.2.9)
|
14
|
+
activemodel (= 3.2.9)
|
15
|
+
activesupport (= 3.2.9)
|
16
16
|
builder (~> 3.0.0)
|
17
17
|
erubis (~> 2.7.0)
|
18
18
|
journey (~> 1.0.4)
|
19
19
|
rack (~> 1.4.0)
|
20
20
|
rack-cache (~> 1.2)
|
21
21
|
rack-test (~> 0.6.1)
|
22
|
-
sprockets (~> 2.1
|
23
|
-
activemodel (3.2.
|
24
|
-
activesupport (= 3.2.
|
22
|
+
sprockets (~> 2.2.1)
|
23
|
+
activemodel (3.2.9)
|
24
|
+
activesupport (= 3.2.9)
|
25
25
|
builder (~> 3.0.0)
|
26
|
-
activesupport (3.2.
|
26
|
+
activesupport (3.2.9)
|
27
27
|
i18n (~> 0.6)
|
28
28
|
multi_json (~> 1.0)
|
29
29
|
addressable (2.3.2)
|
@@ -43,7 +43,7 @@ GEM
|
|
43
43
|
i18n (0.6.1)
|
44
44
|
journey (1.0.4)
|
45
45
|
json (1.7.5)
|
46
|
-
multi_json (1.
|
46
|
+
multi_json (1.4.0)
|
47
47
|
rack (1.4.1)
|
48
48
|
rack-cache (1.2)
|
49
49
|
rack (>= 0.4)
|
@@ -56,22 +56,23 @@ GEM
|
|
56
56
|
rack (>= 1.1)
|
57
57
|
rack-test (0.6.2)
|
58
58
|
rack (>= 1.0)
|
59
|
-
rake (0.
|
60
|
-
rspec (2.
|
61
|
-
rspec-core (~> 2.
|
62
|
-
rspec-expectations (~> 2.
|
63
|
-
rspec-mocks (~> 2.
|
64
|
-
rspec-core (2.
|
65
|
-
rspec-expectations (2.
|
59
|
+
rake (10.0.2)
|
60
|
+
rspec (2.12.0)
|
61
|
+
rspec-core (~> 2.12.0)
|
62
|
+
rspec-expectations (~> 2.12.0)
|
63
|
+
rspec-mocks (~> 2.12.0)
|
64
|
+
rspec-core (2.12.0)
|
65
|
+
rspec-expectations (2.12.0)
|
66
66
|
diff-lcs (~> 1.1.3)
|
67
|
-
rspec-mocks (2.
|
68
|
-
sprockets (2.
|
67
|
+
rspec-mocks (2.12.0)
|
68
|
+
sprockets (2.2.2)
|
69
69
|
hike (~> 1.2)
|
70
|
+
multi_json (~> 1.0)
|
70
71
|
rack (~> 1.0)
|
71
72
|
tilt (~> 1.1, != 1.3.0)
|
72
73
|
tilt (1.3.3)
|
73
74
|
tzinfo (0.3.35)
|
74
|
-
webmock (1.
|
75
|
+
webmock (1.9.0)
|
75
76
|
addressable (>= 2.2.7)
|
76
77
|
crack (>= 0.1.7)
|
77
78
|
yamler (0.1.0)
|
data/README.rdoc
CHANGED
@@ -73,6 +73,16 @@ https://github.com/nov/fb_graph/wiki
|
|
73
73
|
me.home
|
74
74
|
:
|
75
75
|
|
76
|
+
By default, FbGraph will only return the default fields. In order to
|
77
|
+
get a non-default field, you have to supply the connect with an options hash
|
78
|
+
specifying the field. An example for events:
|
79
|
+
|
80
|
+
user.events({:fields => "owner,name,description,picture"}) # { and } optional
|
81
|
+
|
82
|
+
An overview of which fields you can include in the graph API can be found at
|
83
|
+
https://developers.facebook.com/docs/reference/api/, which has a description
|
84
|
+
of the specific objects fields in the sidebar under "Objects".
|
85
|
+
|
76
86
|
==== Search
|
77
87
|
|
78
88
|
# all objects
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.9
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module FbGraph
|
2
2
|
class Page
|
3
3
|
module CategoryAttributes
|
4
|
-
@@
|
5
|
-
@@
|
4
|
+
@@category_attributes = {}
|
5
|
+
@@category_attributes[:raw] = [
|
6
6
|
:affiliation,
|
7
7
|
:artists_we_like,
|
8
8
|
:attire,
|
@@ -11,7 +11,6 @@ module FbGraph
|
|
11
11
|
:band_members,
|
12
12
|
:bio,
|
13
13
|
:booking_agent,
|
14
|
-
:can_post,
|
15
14
|
:company_overview,
|
16
15
|
:culinary_team,
|
17
16
|
:current_location,
|
@@ -23,7 +22,6 @@ module FbGraph
|
|
23
22
|
:hometown,
|
24
23
|
:influences,
|
25
24
|
:is_community_page,
|
26
|
-
:link,
|
27
25
|
:location,
|
28
26
|
:mission,
|
29
27
|
:mpg,
|
@@ -43,24 +41,24 @@ module FbGraph
|
|
43
41
|
:website,
|
44
42
|
:written_by
|
45
43
|
]
|
46
|
-
@@
|
44
|
+
@@category_attributes[:symbols] = [
|
47
45
|
:parking,
|
48
46
|
:payment_options,
|
49
47
|
:restaurant_services,
|
50
48
|
:restaurant_specialties
|
51
49
|
]
|
52
|
-
@@
|
50
|
+
@@category_attributes[:date] = [
|
53
51
|
:birthday,
|
54
52
|
:built,
|
55
53
|
:founded,
|
56
54
|
:release_date
|
57
55
|
]
|
58
|
-
@@
|
56
|
+
@@category_attributes[:others] = [
|
59
57
|
:checkin_count,
|
60
58
|
:hours,
|
61
59
|
:location
|
62
60
|
]
|
63
|
-
attr_accessor *@@
|
61
|
+
attr_accessor *@@category_attributes.values.flatten
|
64
62
|
|
65
63
|
def self.included(klass)
|
66
64
|
klass.alias_method_chain :initialize, :category_specific_attributes
|
@@ -68,19 +66,17 @@ module FbGraph
|
|
68
66
|
|
69
67
|
def initialize_with_category_specific_attributes(identifier, attributes = {})
|
70
68
|
initialize_without_category_specific_attributes identifier, attributes
|
71
|
-
@@
|
69
|
+
@@category_attributes[:raw].each do |key|
|
72
70
|
self.send :"#{key}=", attributes[key]
|
73
71
|
end
|
74
72
|
|
75
|
-
|
76
|
-
|
77
|
-
@@attributes[:symbols].each do |key|
|
73
|
+
@@category_attributes[:symbols].each do |key|
|
78
74
|
self.send :"#{key}=", []
|
79
75
|
if attributes[key]
|
80
76
|
self.send :"#{key}=", attributes[key].keys.collect(&:to_sym)
|
81
77
|
end
|
82
78
|
end
|
83
|
-
@@
|
79
|
+
@@category_attributes[:date].each do |key|
|
84
80
|
date = if attributes[key]
|
85
81
|
begin
|
86
82
|
Date.parse attributes[key]
|
data/lib/fb_graph/page.rb
CHANGED
@@ -15,6 +15,7 @@ module FbGraph
|
|
15
15
|
include Connections::Notes
|
16
16
|
include Connections::Photos
|
17
17
|
include Connections::Picture
|
18
|
+
include Connections::Picture::Updatable
|
18
19
|
include Connections::Posts
|
19
20
|
include Connections::PromotablePosts
|
20
21
|
include Connections::Questions
|
@@ -25,15 +26,23 @@ module FbGraph
|
|
25
26
|
include Connections::Videos
|
26
27
|
extend Searchable
|
27
28
|
|
28
|
-
|
29
|
+
@@attributes = {
|
30
|
+
:raw => [:name, :username, :category, :link, :talking_about_count, :perms, :is_published, :can_post],
|
31
|
+
:custom => [:cover, :like_count]
|
32
|
+
}
|
33
|
+
|
34
|
+
attr_accessor *@@attributes.values.flatten
|
29
35
|
|
30
36
|
def initialize(identifier, attributes = {})
|
31
37
|
super
|
32
|
-
[:
|
38
|
+
@@attributes[:raw].each do |key|
|
33
39
|
self.send :"#{key}=", attributes[key]
|
34
40
|
end
|
41
|
+
@link ||= "https://www.facebook.com/#{username || identifier}"
|
35
42
|
@like_count = attributes[:likes] || attributes[:fan_count]
|
36
|
-
@
|
43
|
+
@cover = if (cover = attributes[:cover])
|
44
|
+
Cover.new cover[:cover_id], cover
|
45
|
+
end
|
37
46
|
end
|
38
47
|
end
|
39
48
|
end
|
data/lib/fb_graph.rb
CHANGED
@@ -1,75 +1,92 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe FbGraph::Connections::Picture
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
describe FbGraph::Connections::Picture do
|
4
|
+
describe '#picture' do
|
5
|
+
context 'when included by FbGraph::User' do
|
6
|
+
it 'should return image url' do
|
7
|
+
FbGraph::User.new('matake').picture.should == File.join(FbGraph::ROOT_URL, 'matake/picture')
|
8
|
+
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
it 'should support size option' do
|
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}")
|
14
|
+
end
|
13
15
|
end
|
14
|
-
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
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")
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
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")
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
it 'should support width and height options at the same time' do
|
26
|
+
# Because we can't be sure of order of arguments and order by itself doesn't matter
|
27
|
+
FbGraph::User.new('matake').picture(:width => 13, :height => 37).should satisfy { |uri|
|
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")
|
31
|
+
].include? uri
|
32
|
+
}
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
35
|
+
context 'when no-redirect' do
|
36
|
+
it 'should return Picture object' do
|
37
|
+
mock_graph :get, 'matake/picture', 'users/picture/success', :params => {
|
38
|
+
:redirect => 'false'
|
39
|
+
} do
|
40
|
+
picture = FbGraph::User.new('matake').picture(:redirect => false)
|
41
|
+
picture.should be_instance_of FbGraph::Picture
|
42
|
+
end
|
41
43
|
end
|
42
44
|
end
|
43
45
|
end
|
44
|
-
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
context 'when included by FbGraph::Page' do
|
48
|
+
it 'should return image url' do
|
49
|
+
FbGraph::Page.new('platform').picture.should == File.join(FbGraph::ROOT_URL, 'platform/picture')
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
it 'should support size option' do
|
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}")
|
56
|
+
end
|
55
57
|
end
|
56
|
-
end
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
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")
|
61
|
+
end
|
61
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")
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should support width and height options at the same time' do
|
68
|
+
FbGraph::Page.new('platform').picture(:width => 13, :height => 37).should satisfy { |uri|
|
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")
|
72
|
+
].include? uri
|
73
|
+
}
|
74
|
+
end
|
64
75
|
end
|
76
|
+
end
|
77
|
+
end
|
65
78
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
79
|
+
describe FbGraph::Connections::Picture::Updatable do
|
80
|
+
describe '#picture!' do
|
81
|
+
it 'should update profile picture' do
|
82
|
+
mock_graph :post, 'FbGraph/picture', 'true', :access_token => 'page_token', :params => {
|
83
|
+
:picture => 'http://example.com/images/FbGraph.png'
|
84
|
+
} do
|
85
|
+
page = FbGraph::Page.new('FbGraph', :access_token => 'page_token')
|
86
|
+
page.picture!(
|
87
|
+
:picture => 'http://example.com/images/FbGraph.png'
|
88
|
+
).should be_true
|
89
|
+
end
|
90
|
+
end
|
74
91
|
end
|
75
92
|
end
|
data/spec/fb_graph/page_spec.rb
CHANGED
@@ -41,10 +41,12 @@ describe FbGraph::Page do
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
its(:identifier) { should == '19292868552' }
|
44
|
-
its(:name) { should == 'Facebook
|
45
|
-
its(:category) { should == '
|
46
|
-
its(:like_count) { should ==
|
47
|
-
its(:talking_about_count) { should ==
|
44
|
+
its(:name) { should == 'Facebook Developers' }
|
45
|
+
its(:category) { should == 'Product/service' }
|
46
|
+
its(:like_count) { should == 237499 }
|
47
|
+
its(:talking_about_count) { should == 17811 }
|
48
|
+
its(:cover) { should be_instance_of FbGraph::Cover }
|
49
|
+
its(:is_published) { should be_true }
|
48
50
|
|
49
51
|
context 'when access_token field fetched' do
|
50
52
|
subject do
|
@@ -1,14 +1,18 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
2
|
+
"name": "Facebook Developers",
|
3
|
+
"is_published": true,
|
4
|
+
"website": "http://developers.facebook.com",
|
5
|
+
"username": "FacebookDevelopers",
|
6
|
+
"company_overview": "Facebook Platform enables anyone to build social apps on Facebook, mobile, and the web.\n\n",
|
7
|
+
"about": "Build and distribute amazing social apps on Facebook. https://developers.facebook.com/ ",
|
8
|
+
"talking_about_count": 17811,
|
9
|
+
"category": "Product/service",
|
10
|
+
"id": "19292868552",
|
11
|
+
"link": "https://www.facebook.com/FacebookDevelopers",
|
12
|
+
"likes": 237499,
|
13
|
+
"cover": {
|
14
|
+
"cover_id": "10151124971508553",
|
15
|
+
"source": "https://fbcdn-sphotos-f-a.akamaihd.net/hphotos-ak-ash4/s720x720/418043_10151124971508553_1379621833_n.png",
|
16
|
+
"offset_y": 0
|
17
|
+
}
|
14
18
|
}
|
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.9
|
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-12-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httpclient
|
@@ -285,6 +285,7 @@ files:
|
|
285
285
|
- lib/fb_graph/connections/user_likes.rb
|
286
286
|
- lib/fb_graph/connections/videos.rb
|
287
287
|
- lib/fb_graph/connections/votes.rb
|
288
|
+
- lib/fb_graph/cover.rb
|
288
289
|
- lib/fb_graph/debugger.rb
|
289
290
|
- lib/fb_graph/doc.rb
|
290
291
|
- lib/fb_graph/domain.rb
|
@@ -728,18 +729,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
728
729
|
- - ! '>='
|
729
730
|
- !ruby/object:Gem::Version
|
730
731
|
version: '0'
|
731
|
-
segments:
|
732
|
-
- 0
|
733
|
-
hash: -910629927856901231
|
734
732
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
735
733
|
none: false
|
736
734
|
requirements:
|
737
735
|
- - ! '>='
|
738
736
|
- !ruby/object:Gem::Version
|
739
737
|
version: '0'
|
740
|
-
segments:
|
741
|
-
- 0
|
742
|
-
hash: -910629927856901231
|
743
738
|
requirements: []
|
744
739
|
rubyforge_project:
|
745
740
|
rubygems_version: 1.8.24
|