fb_graph 2.5.7 → 2.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +2 -2
- data/VERSION +1 -1
- data/lib/fb_graph.rb +1 -0
- data/lib/fb_graph/connections/promotable_posts.rb +14 -0
- data/lib/fb_graph/page.rb +1 -0
- data/lib/fb_graph/promotable_post.rb +34 -0
- data/spec/fb_graph/connections/promotable_posts_spec.rb +24 -0
- data/spec/fb_graph/promotable_post_spec.rb +57 -0
- data/spec/mock_json/pages/promotable_posts/sample.json +168 -0
- metadata +12 -4
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.8)
|
5
5
|
httpclient (>= 2.2.0.2)
|
6
6
|
json
|
7
7
|
rack-oauth2 (>= 0.14.4)
|
@@ -70,7 +70,7 @@ GEM
|
|
70
70
|
rack (~> 1.0)
|
71
71
|
tilt (~> 1.1, != 1.3.0)
|
72
72
|
tilt (1.3.3)
|
73
|
-
tzinfo (0.3.
|
73
|
+
tzinfo (0.3.35)
|
74
74
|
webmock (1.8.11)
|
75
75
|
addressable (>= 2.2.7)
|
76
76
|
crack (>= 0.1.7)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.8
|
data/lib/fb_graph.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module Connections
|
3
|
+
module PromotablePosts
|
4
|
+
def promotable_posts(options = {})
|
5
|
+
posts = self.connection :promotable_posts, options
|
6
|
+
posts.map! do |post|
|
7
|
+
PromotablePost.new post[:id], post.merge(
|
8
|
+
:access_token => options[:access_token] || self.access_token
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/fb_graph/page.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class PromotablePost < Post
|
3
|
+
attr_accessor :is_published, :scheduled_publish_time
|
4
|
+
|
5
|
+
def initialize(identifier, attributes = {})
|
6
|
+
super
|
7
|
+
@is_published = attributes[:is_published]
|
8
|
+
@scheduled_publish_time = if attributes[:scheduled_publish_time]
|
9
|
+
Time.at attributes[:scheduled_publish_time]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def publishable?
|
14
|
+
!@is_published
|
15
|
+
end
|
16
|
+
alias_method :schedulable?, :publishable?
|
17
|
+
|
18
|
+
def scheduled?
|
19
|
+
!!scheduled_publish_time
|
20
|
+
end
|
21
|
+
|
22
|
+
def publish!(options = {})
|
23
|
+
update options.merge(:is_published => true)
|
24
|
+
end
|
25
|
+
|
26
|
+
def schedule!(time, options = {})
|
27
|
+
update options.merge(:scheduled_publish_time => time.to_i)
|
28
|
+
end
|
29
|
+
|
30
|
+
def unschedule!(options = {})
|
31
|
+
schedule! nil, options
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph::Connections::PromotablePosts do
|
4
|
+
describe '#promotable_posts' do
|
5
|
+
it 'should return promotable posts the user created as FbGraph::Post' do
|
6
|
+
mock_graph :get, 'FbGraph/promotable_posts', 'pages/promotable_posts/sample', :access_token => 'access_token' do
|
7
|
+
posts = FbGraph::Page.new('FbGraph', :access_token => 'access_token').promotable_posts
|
8
|
+
posts.class.should == FbGraph::Connection
|
9
|
+
posts.count.should == 4
|
10
|
+
posts.each.with_index do |post, index|
|
11
|
+
post.should be_instance_of FbGraph::PromotablePost
|
12
|
+
case index
|
13
|
+
when 0
|
14
|
+
post.is_published.should be_false
|
15
|
+
post.scheduled_publish_time.should == Time.at(1352473200)
|
16
|
+
else
|
17
|
+
post.is_published.should be_true
|
18
|
+
post.scheduled_publish_time.should be_nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FbGraph::PromotablePost do
|
4
|
+
let(:published) { FbGraph::PromotablePost.new(12345, :is_published => true) }
|
5
|
+
let(:draft) { FbGraph::PromotablePost.new(12345, :is_published => false) }
|
6
|
+
let(:scheduled) { FbGraph::PromotablePost.new(12345, :is_published => false, :scheduled_publish_time => 2.days.from_now.to_i) }
|
7
|
+
|
8
|
+
context 'when published' do
|
9
|
+
subject { published }
|
10
|
+
its(:publishable?) { should be_false }
|
11
|
+
its(:scheduled?) { should be_false }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when draft' do
|
15
|
+
subject { draft }
|
16
|
+
its(:publishable?) { should be_true }
|
17
|
+
its(:scheduled?) { should be_false }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when scheduled' do
|
21
|
+
subject { scheduled }
|
22
|
+
its(:publishable?) { should be_true }
|
23
|
+
its(:scheduled?) { should be_true }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.publish!' do
|
27
|
+
it 'should post with is_published=true' do
|
28
|
+
mock_graph :post, '12345', 'true', :access_token => 'page_token', :params => {
|
29
|
+
:is_published => 'true'
|
30
|
+
} do
|
31
|
+
draft.publish!(:access_token => 'page_token').should be_true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.schedule!' do
|
37
|
+
it 'should post with scheduled_publish_time=timestamp' do
|
38
|
+
scheduled_at = 2.days.from_now
|
39
|
+
mock_graph :post, '12345', 'true', :access_token => 'page_token', :params => {
|
40
|
+
:scheduled_publish_time => scheduled_at.to_i.to_s
|
41
|
+
} do
|
42
|
+
draft.schedule!(scheduled_at, :access_token => 'page_token').should be_true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '.unschedule!' do
|
48
|
+
it 'should post with scheduled_publish_time=0' do
|
49
|
+
scheduled_at = 2.days.from_now
|
50
|
+
mock_graph :post, '12345', 'true', :access_token => 'page_token', :params => {
|
51
|
+
:scheduled_publish_time => '0'
|
52
|
+
} do
|
53
|
+
scheduled.unschedule!(:access_token => 'page_token').should be_true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
{
|
2
|
+
"data": [
|
3
|
+
{
|
4
|
+
"id": "117513961602338_485053824848348",
|
5
|
+
"from": {
|
6
|
+
"name": "FbGraph",
|
7
|
+
"category": "Software",
|
8
|
+
"id": "117513961602338"
|
9
|
+
},
|
10
|
+
"message": "Sample Scheduled Promotable Posts",
|
11
|
+
"actions": [
|
12
|
+
{
|
13
|
+
"name": "Comment",
|
14
|
+
"link": "https://www.facebook.com/117513961602338/posts/485053824848348"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"name": "Like",
|
18
|
+
"link": "https://www.facebook.com/117513961602338/posts/485053824848348"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"privacy": {
|
22
|
+
"description": "Public",
|
23
|
+
"value": "EVERYONE"
|
24
|
+
},
|
25
|
+
"type": "status",
|
26
|
+
"created_time": "2012-11-09T15:00:00+0000",
|
27
|
+
"updated_time": "2012-11-09T15:00:00+0000",
|
28
|
+
"comments": {
|
29
|
+
"count": 0
|
30
|
+
},
|
31
|
+
"is_published": false,
|
32
|
+
"scheduled_publish_time": 1352473200
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"id": "117513961602338_485050244848706",
|
36
|
+
"from": {
|
37
|
+
"name": "FbGraph",
|
38
|
+
"category": "Software",
|
39
|
+
"id": "117513961602338"
|
40
|
+
},
|
41
|
+
"message": "Sample Promotable Posts",
|
42
|
+
"actions": [
|
43
|
+
{
|
44
|
+
"name": "Comment",
|
45
|
+
"link": "https://www.facebook.com/117513961602338/posts/485050244848706"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"name": "Like",
|
49
|
+
"link": "https://www.facebook.com/117513961602338/posts/485050244848706"
|
50
|
+
}
|
51
|
+
],
|
52
|
+
"privacy": {
|
53
|
+
"description": "Public",
|
54
|
+
"value": "EVERYONE"
|
55
|
+
},
|
56
|
+
"type": "status",
|
57
|
+
"status_type": "mobile_status_update",
|
58
|
+
"created_time": "2012-11-07T02:04:16+0000",
|
59
|
+
"updated_time": "2012-11-07T02:04:16+0000",
|
60
|
+
"comments": {
|
61
|
+
"count": 0
|
62
|
+
},
|
63
|
+
"is_published": true
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"id": "117513961602338_274085326039445",
|
67
|
+
"from": {
|
68
|
+
"name": "FbGraph",
|
69
|
+
"category": "Software",
|
70
|
+
"id": "117513961602338"
|
71
|
+
},
|
72
|
+
"message": "I have no idea how to support this.\nArel for fb_graph??\nhttps://developers.facebook.com/docs/reference/api/field_expansion/",
|
73
|
+
"link": "https://developers.facebook.com/docs/reference/api/field_expansion/",
|
74
|
+
"name": "https://developers.facebook.com/docs/reference/api/field_expansion/",
|
75
|
+
"caption": "developers.facebook.com",
|
76
|
+
"icon": "https://s-static.ak.facebook.com/rsrc.php/v2/yD/r/aS8ecmYRys0.gif",
|
77
|
+
"actions": [
|
78
|
+
{
|
79
|
+
"name": "Comment",
|
80
|
+
"link": "https://www.facebook.com/117513961602338/posts/274085326039445"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"name": "Like",
|
84
|
+
"link": "https://www.facebook.com/117513961602338/posts/274085326039445"
|
85
|
+
}
|
86
|
+
],
|
87
|
+
"privacy": {
|
88
|
+
"description": "Public",
|
89
|
+
"value": "EVERYONE"
|
90
|
+
},
|
91
|
+
"type": "link",
|
92
|
+
"status_type": "shared_story",
|
93
|
+
"created_time": "2012-09-02T17:42:08+0000",
|
94
|
+
"updated_time": "2012-09-02T17:42:08+0000",
|
95
|
+
"likes": {
|
96
|
+
"data": [
|
97
|
+
{
|
98
|
+
"name": "Benny Lin",
|
99
|
+
"id": "1684542911"
|
100
|
+
}
|
101
|
+
],
|
102
|
+
"count": 1
|
103
|
+
},
|
104
|
+
"comments": {
|
105
|
+
"count": 0
|
106
|
+
},
|
107
|
+
"is_published": true
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"id": "117513961602338_270322719752153",
|
111
|
+
"from": {
|
112
|
+
"name": "FbGraph",
|
113
|
+
"category": "Software",
|
114
|
+
"id": "117513961602338"
|
115
|
+
},
|
116
|
+
"message": "You can send App Notifications using fb_graph v2.4.20.\nhttps://github.com/nov/fb_graph/wiki/notifications",
|
117
|
+
"picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQAQcwCcAz2hGLi8&w=90&h=90&url=https%3A%2F%2Fa248.e.akamai.net%2Fassets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png%3F1345673561",
|
118
|
+
"link": "https://github.com/nov/fb_graph/wiki/notifications",
|
119
|
+
"name": "fb_graph",
|
120
|
+
"caption": "github.com",
|
121
|
+
"description": "A full-stack Facebook Graph API wrapper in Ruby. Contribute to fb_graph development by creating an account on GitHub.",
|
122
|
+
"icon": "https://s-static.ak.facebook.com/rsrc.php/v2/yD/r/aS8ecmYRys0.gif",
|
123
|
+
"actions": [
|
124
|
+
{
|
125
|
+
"name": "Comment",
|
126
|
+
"link": "https://www.facebook.com/117513961602338/posts/270322719752153"
|
127
|
+
},
|
128
|
+
{
|
129
|
+
"name": "Like",
|
130
|
+
"link": "https://www.facebook.com/117513961602338/posts/270322719752153"
|
131
|
+
}
|
132
|
+
],
|
133
|
+
"privacy": {
|
134
|
+
"description": "Public",
|
135
|
+
"value": "EVERYONE"
|
136
|
+
},
|
137
|
+
"type": "link",
|
138
|
+
"status_type": "shared_story",
|
139
|
+
"created_time": "2012-09-02T17:33:59+0000",
|
140
|
+
"updated_time": "2012-09-02T17:33:59+0000",
|
141
|
+
"likes": {
|
142
|
+
"data": [
|
143
|
+
{
|
144
|
+
"name": "Benny Lin",
|
145
|
+
"id": "1684542911"
|
146
|
+
},
|
147
|
+
{
|
148
|
+
"name": "Arun Kumar",
|
149
|
+
"id": "100001286076940"
|
150
|
+
},
|
151
|
+
{
|
152
|
+
"name": "Ryan Felton",
|
153
|
+
"id": "697922812"
|
154
|
+
}
|
155
|
+
],
|
156
|
+
"count": 3
|
157
|
+
},
|
158
|
+
"comments": {
|
159
|
+
"count": 0
|
160
|
+
},
|
161
|
+
"is_published": true
|
162
|
+
}
|
163
|
+
],
|
164
|
+
"paging": {
|
165
|
+
"previous": "https://graph.facebook.com/117513961602338/promotable_posts?limit=25&since=1352473200",
|
166
|
+
"next": "https://graph.facebook.com/117513961602338/promotable_posts?limit=25&until=1346607238"
|
167
|
+
}
|
168
|
+
}
|
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.8
|
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-11-
|
12
|
+
date: 2012-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httpclient
|
@@ -263,6 +263,7 @@ files:
|
|
263
263
|
- lib/fb_graph/connections/picture.rb
|
264
264
|
- lib/fb_graph/connections/pokes.rb
|
265
265
|
- lib/fb_graph/connections/posts.rb
|
266
|
+
- lib/fb_graph/connections/promotable_posts.rb
|
266
267
|
- lib/fb_graph/connections/question_options.rb
|
267
268
|
- lib/fb_graph/connections/questions.rb
|
268
269
|
- lib/fb_graph/connections/reach_estimates.rb
|
@@ -318,6 +319,7 @@ files:
|
|
318
319
|
- lib/fb_graph/post.rb
|
319
320
|
- lib/fb_graph/privacy.rb
|
320
321
|
- lib/fb_graph/project.rb
|
322
|
+
- lib/fb_graph/promotable_post.rb
|
321
323
|
- lib/fb_graph/property.rb
|
322
324
|
- lib/fb_graph/query.rb
|
323
325
|
- lib/fb_graph/question.rb
|
@@ -426,6 +428,7 @@ files:
|
|
426
428
|
- spec/fb_graph/connections/picture_spec.rb
|
427
429
|
- spec/fb_graph/connections/pokes_spec.rb
|
428
430
|
- spec/fb_graph/connections/posts_spec.rb
|
431
|
+
- spec/fb_graph/connections/promotable_posts_spec.rb
|
429
432
|
- spec/fb_graph/connections/question_options_spec.rb
|
430
433
|
- spec/fb_graph/connections/questions_spec.rb
|
431
434
|
- spec/fb_graph/connections/reach_estimates_spec.rb
|
@@ -479,6 +482,7 @@ files:
|
|
479
482
|
- spec/fb_graph/post_spec.rb
|
480
483
|
- spec/fb_graph/privacy_spec.rb
|
481
484
|
- spec/fb_graph/project_spec.rb
|
485
|
+
- spec/fb_graph/promotable_post_spec.rb
|
482
486
|
- spec/fb_graph/qeustion_option_spec.rb
|
483
487
|
- spec/fb_graph/query_spec.rb
|
484
488
|
- spec/fb_graph/question_spec.rb
|
@@ -582,6 +586,7 @@ files:
|
|
582
586
|
- spec/mock_json/pages/notes/post_with_valid_access_token.json
|
583
587
|
- spec/mock_json/pages/platform_private.json
|
584
588
|
- spec/mock_json/pages/platform_public.json
|
589
|
+
- spec/mock_json/pages/promotable_posts/sample.json
|
585
590
|
- spec/mock_json/pages/search_fb_graph.json
|
586
591
|
- spec/mock_json/pages/search_google.json
|
587
592
|
- spec/mock_json/pages/settings/all_enabled.json
|
@@ -725,7 +730,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
725
730
|
version: '0'
|
726
731
|
segments:
|
727
732
|
- 0
|
728
|
-
hash:
|
733
|
+
hash: -910629927856901231
|
729
734
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
730
735
|
none: false
|
731
736
|
requirements:
|
@@ -734,7 +739,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
734
739
|
version: '0'
|
735
740
|
segments:
|
736
741
|
- 0
|
737
|
-
hash:
|
742
|
+
hash: -910629927856901231
|
738
743
|
requirements: []
|
739
744
|
rubyforge_project:
|
740
745
|
rubygems_version: 1.8.24
|
@@ -822,6 +827,7 @@ test_files:
|
|
822
827
|
- spec/fb_graph/connections/picture_spec.rb
|
823
828
|
- spec/fb_graph/connections/pokes_spec.rb
|
824
829
|
- spec/fb_graph/connections/posts_spec.rb
|
830
|
+
- spec/fb_graph/connections/promotable_posts_spec.rb
|
825
831
|
- spec/fb_graph/connections/question_options_spec.rb
|
826
832
|
- spec/fb_graph/connections/questions_spec.rb
|
827
833
|
- spec/fb_graph/connections/reach_estimates_spec.rb
|
@@ -875,6 +881,7 @@ test_files:
|
|
875
881
|
- spec/fb_graph/post_spec.rb
|
876
882
|
- spec/fb_graph/privacy_spec.rb
|
877
883
|
- spec/fb_graph/project_spec.rb
|
884
|
+
- spec/fb_graph/promotable_post_spec.rb
|
878
885
|
- spec/fb_graph/qeustion_option_spec.rb
|
879
886
|
- spec/fb_graph/query_spec.rb
|
880
887
|
- spec/fb_graph/question_spec.rb
|
@@ -978,6 +985,7 @@ test_files:
|
|
978
985
|
- spec/mock_json/pages/notes/post_with_valid_access_token.json
|
979
986
|
- spec/mock_json/pages/platform_private.json
|
980
987
|
- spec/mock_json/pages/platform_public.json
|
988
|
+
- spec/mock_json/pages/promotable_posts/sample.json
|
981
989
|
- spec/mock_json/pages/search_fb_graph.json
|
982
990
|
- spec/mock_json/pages/search_google.json
|
983
991
|
- spec/mock_json/pages/settings/all_enabled.json
|