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.
@@ -1,36 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fb_graph (1.8.0)
4
+ fb_graph (1.8.1)
5
5
  httpclient (>= 2.2.0.2)
6
- rack-oauth2 (>= 0.6.9)
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.5)
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.6.9)
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.2)
43
- addressable (>= 2.2.2)
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
+ 1.8.2
@@ -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.6.9"
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
@@ -11,8 +11,15 @@ module FbGraph
11
11
  end
12
12
  @tags = []
13
13
  if (tags = attributes[:tags])
14
- Collection.new(tags).each do |user|
15
- @tags << User.new(user[:id], user)
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])
@@ -16,7 +16,7 @@ module FbGraph
16
16
  if metrics = options.delete(:metrics)
17
17
  File.join([metrics, options.delete(:period)].compact.collect(&:to_s))
18
18
  else
19
- nil
19
+ options[:connection_scope]
20
20
  end
21
21
  end
22
22
  end
@@ -1,121 +1,153 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe FbGraph::Connections::Checkins, '#checkins' do
4
- context 'when included by FbGraph::User' do
5
- context 'when no access_token given' do
6
- it 'should raise FbGraph::Unauthorized' do
7
- mock_graph :get, 'mattt/checkins', 'users/checkins/mattt_public', :status => [401, 'Unauthorized'] do
8
- lambda do
9
- FbGraph::User.new('mattt').checkins
10
- end.should raise_exception(FbGraph::Unauthorized)
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
- context 'when access_token is given' do
16
- it 'should return checkins as FbGraph::Checkin' do
17
- mock_graph :get, 'mattt/checkins', 'users/checkins/mattt_private', :access_token => 'access_token' do
18
- checkins = FbGraph::User.new('mattt', :access_token => 'access_token').checkins
19
- checkins.first.should == FbGraph::Checkin.new(
20
- '696876187499',
21
- :access_token => 'access_token',
22
- :from => {
23
- :id => '12820552',
24
- :name => 'Roger Pincombe'
25
- },
26
- :tags => {
27
- :data => [{
28
- :id => '4810308',
29
- :name => 'Mattt Thompson'
30
- }]
31
- },
32
- :message => 'Checking out Austin, TX',
33
- :place => {
34
- :id => '120454134658381',
35
- :name => 'Gowalla HQ',
36
- :location => {
37
- :latitude => 30.26876,
38
- :longitude => -97.74962
39
- }
40
- },
41
- :application => {
42
- :id => '6628568379',
43
- :name => 'Facebook for iPhone'
44
- },
45
- :created_time => '2010-09-08T00:09:25+0000'
46
- )
47
- checkins.each do |checkin|
48
- checkin.should be_instance_of(FbGraph::Checkin)
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
- context 'when included by FbGraph::Page' do
56
- context 'when no access_token given' do
57
- it 'should raise FbGraph::Unauthorized' do
58
- mock_graph :get, 'gowalla/checkins', 'pages/checkins/gowalla_public', :status => [401, 'Unauthorized'] do
59
- lambda do
60
- FbGraph::Page.new('gowalla').checkins
61
- end.should raise_exception(FbGraph::Unauthorized)
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
- context 'when access_token is given' do
67
- it 'should return checkins as FbGraph::Checkin' do
68
- mock_graph :get, 'gowalla/checkins', 'pages/checkins/gowalla_private', :access_token => 'access_token' do
69
- checkins = FbGraph::Page.new('gowalla', :access_token => 'access_token').checkins
70
- checkins.first.should == FbGraph::Checkin.new(
71
- '696876187499',
72
- :access_token => 'access_token',
73
- :from => {
74
- :id => '12820552',
75
- :name => 'Roger Pincombe'
76
- },
77
- :tags => {
78
- :data => [{
79
- :id => '4810308',
80
- :name => 'Mattt Thompson'
81
- }]
82
- },
83
- :message => 'Checking out Austin, TX',
84
- :place => {
85
- :id => '120454134658381',
86
- :name => 'Gowalla HQ',
87
- :location => {
88
- :latitude => 30.26876,
89
- :longitude => -97.74962
90
- }
91
- },
92
- :application => {
93
- :id => '6628568379',
94
- :name => 'Facebook for iPhone'
95
- },
96
- :created_time => '2010-09-08T00:09:25+0000'
97
- )
98
- checkins.each do |checkin|
99
- checkin.should be_instance_of(FbGraph::Checkin)
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 FbGraph::Connections::Checkins, '#checkin!' do
108
- it 'should POST :user_id/checkins' do
109
- mock_graph :post, 'me/checkins', 'users/checkins/posted' do
110
- checkin = FbGraph::User.me('token').checkin!(
111
- :place => 'place_id',
112
- :coordinates => {
113
- :latitude => 30.26876,
114
- :longitude => -97.74962
115
- }.to_json
116
- )
117
- checkin.identifier.should == '10150090286117277'
118
- checkin.place.should == FbGraph::Place.new('place_id')
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, '#insights' do
4
-
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)
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
- 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)
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
- 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
- )
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
- 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
- )
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.1
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-16 00:00:00 Z
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.6.9
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