fb_graph 1.8.1 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +9 -14
- data/VERSION +1 -1
- data/fb_graph.gemspec +3 -3
- data/lib/fb_graph/checkin.rb +9 -2
- data/lib/fb_graph/connections/insights.rb +1 -1
- data/spec/fb_graph/connections/checkins_spec.rb +131 -99
- data/spec/fb_graph/connections/insights_spec.rb +88 -80
- metadata +9 -3
data/Gemfile.lock
CHANGED
@@ -1,36 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fb_graph (1.8.
|
4
|
+
fb_graph (1.8.1)
|
5
5
|
httpclient (>= 2.2.0.2)
|
6
|
-
rack-oauth2 (>= 0.
|
6
|
+
rack-oauth2 (>= 0.8.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
11
|
activesupport (3.0.7)
|
12
|
-
addressable (2.2.
|
12
|
+
addressable (2.2.6)
|
13
13
|
attr_required (0.0.3)
|
14
14
|
crack (0.1.8)
|
15
15
|
diff-lcs (1.1.2)
|
16
16
|
httpclient (2.2.0.2)
|
17
17
|
i18n (0.5.0)
|
18
18
|
json (1.5.1)
|
19
|
-
mime-types (1.16)
|
20
19
|
rack (1.2.2)
|
21
|
-
rack-oauth2 (0.
|
20
|
+
rack-oauth2 (0.8.0)
|
22
21
|
activesupport (>= 2.3)
|
23
22
|
attr_required (>= 0.0.3)
|
23
|
+
httpclient (>= 2.2.0.2)
|
24
24
|
i18n
|
25
25
|
json (>= 1.4.3)
|
26
26
|
rack (>= 1.1)
|
27
|
-
restclient_with_cert
|
28
27
|
rake (0.8.7)
|
29
28
|
rcov (0.9.9)
|
30
|
-
rest-client (1.6.1)
|
31
|
-
mime-types (>= 1.16)
|
32
|
-
restclient_with_cert (0.0.7)
|
33
|
-
rest-client (>= 1.6)
|
34
29
|
rspec (2.5.0)
|
35
30
|
rspec-core (~> 2.5.0)
|
36
31
|
rspec-expectations (~> 2.5.0)
|
@@ -39,8 +34,8 @@ GEM
|
|
39
34
|
rspec-expectations (2.5.0)
|
40
35
|
diff-lcs (~> 1.1.2)
|
41
36
|
rspec-mocks (2.5.0)
|
42
|
-
webmock (1.6.
|
43
|
-
addressable (
|
37
|
+
webmock (1.6.4)
|
38
|
+
addressable (> 2.2.5, ~> 2.2)
|
44
39
|
crack (>= 0.1.7)
|
45
40
|
|
46
41
|
PLATFORMS
|
@@ -48,7 +43,7 @@ PLATFORMS
|
|
48
43
|
|
49
44
|
DEPENDENCIES
|
50
45
|
fb_graph!
|
51
|
-
rake (>= 0.8)
|
46
|
+
rake (< 0.9, >= 0.8)
|
52
47
|
rcov (>= 0.9)
|
53
|
-
rspec (>= 2)
|
48
|
+
rspec (< 2.6, >= 2)
|
54
49
|
webmock (>= 1.6.2)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.8.
|
1
|
+
1.8.2
|
data/fb_graph.gemspec
CHANGED
@@ -13,9 +13,9 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
15
|
s.add_runtime_dependency "httpclient", ">= 2.2.0.2"
|
16
|
-
s.add_runtime_dependency "rack-oauth2", ">= 0.
|
17
|
-
s.add_development_dependency "rake", ">= 0.8"
|
16
|
+
s.add_runtime_dependency "rack-oauth2", ">= 0.8.0"
|
17
|
+
s.add_development_dependency "rake", ">= 0.8", "< 0.9"
|
18
18
|
s.add_development_dependency "rcov", ">= 0.9"
|
19
|
-
s.add_development_dependency "rspec", ">= 2"
|
19
|
+
s.add_development_dependency "rspec", ">= 2", "< 2.6"
|
20
20
|
s.add_development_dependency "webmock", ">= 1.6.2"
|
21
21
|
end
|
data/lib/fb_graph/checkin.rb
CHANGED
@@ -11,8 +11,15 @@ module FbGraph
|
|
11
11
|
end
|
12
12
|
@tags = []
|
13
13
|
if (tags = attributes[:tags])
|
14
|
-
|
15
|
-
|
14
|
+
case tags
|
15
|
+
when Hash
|
16
|
+
Collection.new(tags).each do |user|
|
17
|
+
@tags << User.new(user[:id], user)
|
18
|
+
end
|
19
|
+
when String, Array
|
20
|
+
Array(tags).each do |user_id|
|
21
|
+
@tags << User.new(user_id)
|
22
|
+
end
|
16
23
|
end
|
17
24
|
end
|
18
25
|
if (place = attributes[:place])
|
@@ -1,121 +1,153 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe FbGraph::Connections::Checkins
|
4
|
-
|
5
|
-
context 'when
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
describe FbGraph::Connections::Checkins do
|
4
|
+
describe '#checkins' do
|
5
|
+
context 'when included by FbGraph::User' do
|
6
|
+
context 'when no access_token given' do
|
7
|
+
it 'should raise FbGraph::Unauthorized' do
|
8
|
+
mock_graph :get, 'mattt/checkins', 'users/checkins/mattt_public', :status => [401, 'Unauthorized'] do
|
9
|
+
lambda do
|
10
|
+
FbGraph::User.new('mattt').checkins
|
11
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
13
|
-
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
16
|
+
context 'when access_token is given' do
|
17
|
+
it 'should return checkins as FbGraph::Checkin' do
|
18
|
+
mock_graph :get, 'mattt/checkins', 'users/checkins/mattt_private', :access_token => 'access_token' do
|
19
|
+
checkins = FbGraph::User.new('mattt', :access_token => 'access_token').checkins
|
20
|
+
checkins.first.should == FbGraph::Checkin.new(
|
21
|
+
'696876187499',
|
22
|
+
:access_token => 'access_token',
|
23
|
+
:from => {
|
24
|
+
:id => '12820552',
|
25
|
+
:name => 'Roger Pincombe'
|
26
|
+
},
|
27
|
+
:tags => {
|
28
|
+
:data => [{
|
29
|
+
:id => '4810308',
|
30
|
+
:name => 'Mattt Thompson'
|
31
|
+
}]
|
32
|
+
},
|
33
|
+
:message => 'Checking out Austin, TX',
|
34
|
+
:place => {
|
35
|
+
:id => '120454134658381',
|
36
|
+
:name => 'Gowalla HQ',
|
37
|
+
:location => {
|
38
|
+
:latitude => 30.26876,
|
39
|
+
:longitude => -97.74962
|
40
|
+
}
|
41
|
+
},
|
42
|
+
:application => {
|
43
|
+
:id => '6628568379',
|
44
|
+
:name => 'Facebook for iPhone'
|
45
|
+
},
|
46
|
+
:created_time => '2010-09-08T00:09:25+0000'
|
47
|
+
)
|
48
|
+
checkins.each do |checkin|
|
49
|
+
checkin.should be_instance_of(FbGraph::Checkin)
|
50
|
+
end
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
52
54
|
end
|
53
|
-
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
56
|
+
context 'when included by FbGraph::Page' do
|
57
|
+
context 'when no access_token given' do
|
58
|
+
it 'should raise FbGraph::Unauthorized' do
|
59
|
+
mock_graph :get, 'gowalla/checkins', 'pages/checkins/gowalla_public', :status => [401, 'Unauthorized'] do
|
60
|
+
lambda do
|
61
|
+
FbGraph::Page.new('gowalla').checkins
|
62
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
63
|
+
end
|
62
64
|
end
|
63
65
|
end
|
64
|
-
end
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
67
|
+
context 'when access_token is given' do
|
68
|
+
it 'should return checkins as FbGraph::Checkin' do
|
69
|
+
mock_graph :get, 'gowalla/checkins', 'pages/checkins/gowalla_private', :access_token => 'access_token' do
|
70
|
+
checkins = FbGraph::Page.new('gowalla', :access_token => 'access_token').checkins
|
71
|
+
checkins.first.should == FbGraph::Checkin.new(
|
72
|
+
'696876187499',
|
73
|
+
:access_token => 'access_token',
|
74
|
+
:from => {
|
75
|
+
:id => '12820552',
|
76
|
+
:name => 'Roger Pincombe'
|
77
|
+
},
|
78
|
+
:tags => {
|
79
|
+
:data => [{
|
80
|
+
:id => '4810308',
|
81
|
+
:name => 'Mattt Thompson'
|
82
|
+
}]
|
83
|
+
},
|
84
|
+
:message => 'Checking out Austin, TX',
|
85
|
+
:place => {
|
86
|
+
:id => '120454134658381',
|
87
|
+
:name => 'Gowalla HQ',
|
88
|
+
:location => {
|
89
|
+
:latitude => 30.26876,
|
90
|
+
:longitude => -97.74962
|
91
|
+
}
|
92
|
+
},
|
93
|
+
:application => {
|
94
|
+
:id => '6628568379',
|
95
|
+
:name => 'Facebook for iPhone'
|
96
|
+
},
|
97
|
+
:created_time => '2010-09-08T00:09:25+0000'
|
98
|
+
)
|
99
|
+
checkins.each do |checkin|
|
100
|
+
checkin.should be_instance_of(FbGraph::Checkin)
|
101
|
+
end
|
100
102
|
end
|
101
103
|
end
|
102
104
|
end
|
103
105
|
end
|
104
106
|
end
|
105
|
-
end
|
106
107
|
|
107
|
-
describe
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
108
|
+
describe '#checkin!' do
|
109
|
+
it 'should POST :user_id/checkins' do
|
110
|
+
mock_graph :post, 'me/checkins', 'users/checkins/posted' do
|
111
|
+
checkin = FbGraph::User.me('token').checkin!(
|
112
|
+
:place => 'place_id',
|
113
|
+
:coordinates => {
|
114
|
+
:latitude => 30.26876,
|
115
|
+
:longitude => -97.74962
|
116
|
+
}.to_json
|
117
|
+
)
|
118
|
+
checkin.identifier.should == '10150090286117277'
|
119
|
+
checkin.place.should == FbGraph::Place.new('place_id')
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'when tags are given' do
|
124
|
+
it 'should allow single tag' do
|
125
|
+
mock_graph :post, 'me/checkins', 'users/checkins/posted' do
|
126
|
+
checkin = FbGraph::User.me('token').checkin!(
|
127
|
+
:place => 'place_id',
|
128
|
+
:coordinates => {
|
129
|
+
:latitude => 30.26876,
|
130
|
+
:longitude => -97.74962
|
131
|
+
}.to_json,
|
132
|
+
:tags => 'friend_1'
|
133
|
+
)
|
134
|
+
checkin.tags.should == [FbGraph::User.new('friend_1')]
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should allow multiple tags' do
|
139
|
+
mock_graph :post, 'me/checkins', 'users/checkins/posted' do
|
140
|
+
checkin = FbGraph::User.me('token').checkin!(
|
141
|
+
:place => 'place_id',
|
142
|
+
:coordinates => {
|
143
|
+
:latitude => 30.26876,
|
144
|
+
:longitude => -97.74962
|
145
|
+
}.to_json,
|
146
|
+
:tags => ['friend_1', 'friend_2']
|
147
|
+
)
|
148
|
+
checkin.tags.should == [FbGraph::User.new('friend_1'), FbGraph::User.new('friend_2')]
|
149
|
+
end
|
150
|
+
end
|
119
151
|
end
|
120
152
|
end
|
121
153
|
end
|
@@ -1,96 +1,104 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe FbGraph::Connections::Insights
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
describe FbGraph::Connections::Insights do
|
4
|
+
describe '#insights' do
|
5
|
+
context 'when included by FbGraph::Page' do
|
6
|
+
context 'when no access_token given' do
|
7
|
+
it 'should raise FbGraph::Unauthorized' do
|
8
|
+
mock_graph :get, 'FbGraph/insights', 'pages/insights/FbGraph_public', :status => [401, 'Unauthorized'] do
|
9
|
+
lambda do
|
10
|
+
FbGraph::Page.new('FbGraph').insights
|
11
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
12
|
+
end
|
12
13
|
end
|
13
14
|
end
|
14
|
-
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
16
|
+
context 'when access_token is given' do
|
17
|
+
it 'should return insights as FbGraph::Insight' do
|
18
|
+
mock_graph :get, 'FbGraph/insights', 'pages/insights/FbGraph_private', :access_token => 'access_token' do
|
19
|
+
insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token')
|
20
|
+
insights.class.should == FbGraph::Connection
|
21
|
+
insights.first.should == FbGraph::Insight.new(
|
22
|
+
'117513961602338/insights/page_fan_adds_unique/day',
|
23
|
+
:access_token => 'access_token',
|
24
|
+
:name => 'page_fan_adds_unique',
|
25
|
+
:description => 'Daily New Likes of your Page (Unique Users)',
|
26
|
+
:period => 'day',
|
27
|
+
:values => [{
|
28
|
+
:value => 1,
|
29
|
+
:end_time => '2010-11-27T08:00:00+0000'
|
30
|
+
}]
|
31
|
+
)
|
32
|
+
insights.each do |insight|
|
33
|
+
insight.should be_instance_of(FbGraph::Insight)
|
34
|
+
end
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
37
|
-
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
39
|
+
context 'when metrics is given' do
|
40
|
+
it 'should treat metrics as connection scope' do
|
41
|
+
mock_graph :get, 'FbGraph/insights/page_like_adds', 'pages/insights/page_like_adds/FbGraph_private', :access_token => 'access_token' do
|
42
|
+
insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token', :metrics => :page_like_adds)
|
43
|
+
insights.options.should == {
|
44
|
+
:connection_scope => 'page_like_adds',
|
45
|
+
:access_token => 'access_token'
|
46
|
+
}
|
47
|
+
insights.first.should == FbGraph::Insight.new(
|
48
|
+
'117513961602338/insights/page_like_adds/day',
|
49
|
+
:access_token => 'access_token',
|
50
|
+
:name => 'page_like_adds',
|
51
|
+
:description => 'Daily Likes of your Page\'s content (Total Count)',
|
52
|
+
:period => 'day',
|
53
|
+
:values => [{
|
54
|
+
:value => 0,
|
55
|
+
:end_time => '2010-12-09T08:00:00+0000'
|
56
|
+
}, {
|
57
|
+
:value => 0,
|
58
|
+
:end_time => '2010-12-10T08:00:00+0000'
|
59
|
+
}, {
|
60
|
+
:value => 0,
|
61
|
+
:end_time => '2010-12-11T08:00:00+0000'
|
62
|
+
}]
|
63
|
+
)
|
64
|
+
end
|
64
65
|
end
|
65
|
-
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
67
|
+
it 'should support period also' do
|
68
|
+
mock_graph :get, 'FbGraph/insights/page_like_adds/day', 'pages/insights/page_like_adds/day/FbGraph_private', :access_token => 'access_token' do
|
69
|
+
insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token', :metrics => :page_like_adds, :period => :day)
|
70
|
+
insights.options.should == {
|
71
|
+
:connection_scope => 'page_like_adds/day',
|
72
|
+
:access_token => 'access_token'
|
73
|
+
}
|
74
|
+
insights.first.should == FbGraph::Insight.new(
|
75
|
+
'117513961602338/insights/page_like_adds/day',
|
76
|
+
:access_token => 'access_token',
|
77
|
+
:name => 'page_like_adds',
|
78
|
+
:description => 'Daily Likes of your Page\'s content (Total Count)',
|
79
|
+
:period => 'day',
|
80
|
+
:values => [{
|
81
|
+
:value => 1,
|
82
|
+
:end_time => '2010-12-09T08:00:00+0000'
|
83
|
+
}, {
|
84
|
+
:value => 1,
|
85
|
+
:end_time => '2010-12-10T08:00:00+0000'
|
86
|
+
}, {
|
87
|
+
:value => 1,
|
88
|
+
:end_time => '2010-12-11T08:00:00+0000'
|
89
|
+
}]
|
90
|
+
)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should used for pagination' do
|
95
|
+
mock_graph :get, 'FbGraph/insights/page_like_adds/day', 'pages/insights/page_like_adds/day/FbGraph_private', :access_token => 'access_token' do
|
96
|
+
insights = FbGraph::Page.new('FbGraph').insights(:access_token => 'access_token', :metrics => :page_like_adds, :period => :day)
|
97
|
+
expect { insights.next }.should request_to 'FbGraph/insights/page_like_adds/day?oauth_token=access_token&since=1292065709&until=1292324909'
|
98
|
+
expect { insights.previous }.should request_to 'FbGraph/insights/page_like_adds/day?oauth_token=access_token&since=1291547309&until=1291806509'
|
99
|
+
end
|
91
100
|
end
|
92
101
|
end
|
93
102
|
end
|
94
103
|
end
|
95
|
-
|
96
104
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: fb_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.8.
|
5
|
+
version: 1.8.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- nov matake
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-22 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httpclient
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.
|
34
|
+
version: 0.8.0
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id002
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -43,6 +43,9 @@ dependencies:
|
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: "0.8"
|
46
|
+
- - <
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0.9"
|
46
49
|
type: :development
|
47
50
|
version_requirements: *id003
|
48
51
|
- !ruby/object:Gem::Dependency
|
@@ -65,6 +68,9 @@ dependencies:
|
|
65
68
|
- - ">="
|
66
69
|
- !ruby/object:Gem::Version
|
67
70
|
version: "2"
|
71
|
+
- - <
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "2.6"
|
68
74
|
type: :development
|
69
75
|
version_requirements: *id005
|
70
76
|
- !ruby/object:Gem::Dependency
|