fb_graph 2.7.1 → 2.7.2
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.
- checksums.yaml +4 -4
- data/README.rdoc +26 -1
- data/VERSION +1 -1
- data/lib/fb_graph/comment.rb +4 -1
- data/lib/fb_graph/connections/comments.rb +7 -0
- data/lib/fb_graph/node.rb +12 -1
- data/lib/fb_graph.rb +1 -0
- data/spec/fb_graph/comment_spec.rb +36 -0
- data/spec/fb_graph/connections/comments_spec.rb +34 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e660328032ffbc8b0baa0033cf3099345ff336e0
|
4
|
+
data.tar.gz: 167ec5d9906e89ce2ada0e468e600241fb07978b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fd73b3676e3b3b26c96ab0c1532f5bc41c9735f096991d154fe642ea365731fd942153221cfe555bb1b576673db0100a097b439e90948299d8ceb2b9bff6788
|
7
|
+
data.tar.gz: ed343eab7ee5fd8e682bb90e8ef85b0dee476130f8879cfb8cec76573f684cdefbbbf7afc82d9c3785ac3cffdb47f259b5617f2c0c2c2dc1c84498250472ae3f
|
data/README.rdoc
CHANGED
@@ -116,6 +116,16 @@ of the specific objects fields in the sidebar under "Objects".
|
|
116
116
|
results.klass.search(results.query, results.collection.next) # => same with results.next
|
117
117
|
results.klass.search(results.query, results.collection.previous) # => same with results.previous
|
118
118
|
|
119
|
+
|
120
|
+
==== Comments
|
121
|
+
|
122
|
+
# fetch comment replies
|
123
|
+
FbGraph::Comment.new("10151705618661509_29545180", :access_token => ACCESS_TOKEN).comments
|
124
|
+
|
125
|
+
# fetch if the comment accept replies
|
126
|
+
comment = FbGraph::Comment.fetch("10151705618661509_29545180", :access_token => ACCESS_TOKEN, :fields => "can_comment")
|
127
|
+
comment.can_comment
|
128
|
+
|
119
129
|
=== POST
|
120
130
|
|
121
131
|
==== Update status (wall post)
|
@@ -193,6 +203,14 @@ of the specific objects fields in the sidebar under "Objects".
|
|
193
203
|
:message => 'Hello, where is photo?'
|
194
204
|
)
|
195
205
|
|
206
|
+
==== Reply a comment
|
207
|
+
|
208
|
+
comment = FbGraph::Comment.fetch("10151705618661509_29545180")
|
209
|
+
comment.reply!(
|
210
|
+
:message => "Hello!",
|
211
|
+
:access_token => ACCESS_TOKEN
|
212
|
+
)
|
213
|
+
|
196
214
|
=== DELETE
|
197
215
|
|
198
216
|
==== Delete an object
|
@@ -209,6 +227,13 @@ of the specific objects fields in the sidebar under "Objects".
|
|
209
227
|
post.unlike!(:access_token => ACCESS_TOKEN)
|
210
228
|
post.destroy(:access_token => ACCESS_TOKEN)
|
211
229
|
|
230
|
+
==== Delete a comment reply
|
231
|
+
|
232
|
+
reply = comment.comment!( :access_token => ACCESS_TOKEN,
|
233
|
+
:message => "Hello!"
|
234
|
+
)
|
235
|
+
reply.destroy(:access_token => ACCESS_TOKEN)
|
236
|
+
|
212
237
|
=== Authentication
|
213
238
|
|
214
239
|
Both Facebook JavaScript SDK and normal OAuth2 flow is supported.
|
@@ -288,4 +313,4 @@ https://github.com/nov/fb_graph/wiki
|
|
288
313
|
|
289
314
|
== Copyright
|
290
315
|
|
291
|
-
Copyright (c) 2010 nov matake. See LICENSE for details.
|
316
|
+
Copyright (c) 2010 nov matake. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.7.
|
1
|
+
2.7.2
|
data/lib/fb_graph/comment.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module FbGraph
|
2
2
|
class Comment < Node
|
3
|
+
include Connections::Comments
|
3
4
|
include Connections::Likes
|
4
5
|
include Connections::Likes::Likable
|
5
6
|
|
6
|
-
attr_accessor :from, :message, :created_time, :like_count
|
7
|
+
attr_accessor :from, :message, :created_time, :like_count, :can_comment
|
7
8
|
|
8
9
|
def initialize(identifier, attributes = {})
|
9
10
|
super
|
@@ -16,6 +17,8 @@ module FbGraph
|
|
16
17
|
end
|
17
18
|
@message = attributes[:message]
|
18
19
|
@like_count = attributes[:likes]
|
20
|
+
@can_comment = attributes[:can_comment]
|
21
|
+
|
19
22
|
if attributes[:created_time]
|
20
23
|
@created_time = Time.parse(attributes[:created_time]).utc
|
21
24
|
end
|
@@ -16,6 +16,13 @@ module FbGraph
|
|
16
16
|
:access_token => options[:access_token] || self.access_token
|
17
17
|
)
|
18
18
|
end
|
19
|
+
|
20
|
+
def reply!(options = {})
|
21
|
+
comment_id = post options.merge(:connection => :comments)
|
22
|
+
Comment.new comment_id, options.merge(
|
23
|
+
:access_token => options[:access_token] || self.access_token
|
24
|
+
)
|
25
|
+
end
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
data/lib/fb_graph/node.rb
CHANGED
@@ -135,7 +135,18 @@ module FbGraph
|
|
135
135
|
when 'null'
|
136
136
|
nil
|
137
137
|
else
|
138
|
-
_response_ =
|
138
|
+
_response_ = if response.body =~ /^"/
|
139
|
+
# NOTE:
|
140
|
+
# Only for comment.reply!, which returns an identifier as String.
|
141
|
+
# Once the API spec changed (I guess FB will do so), we can call "with_indifferent_access" for all response.
|
142
|
+
# NOTE:
|
143
|
+
# When MultiJson.engine is JsonGem, parsing JSON String fails.
|
144
|
+
# You should handle this case without MultiJson.
|
145
|
+
response.body.gsub('"', '')
|
146
|
+
else
|
147
|
+
MultiJson.load(response.body).with_indifferent_access
|
148
|
+
end
|
149
|
+
|
139
150
|
if (200...300).include?(response.status)
|
140
151
|
_response_
|
141
152
|
else
|
data/lib/fb_graph.rb
CHANGED
@@ -28,4 +28,40 @@ describe FbGraph::Comment, '.new' do
|
|
28
28
|
page_comment.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
|
29
29
|
end
|
30
30
|
|
31
|
+
end
|
32
|
+
|
33
|
+
describe FbGraph::Comment, '#fetch' do
|
34
|
+
|
35
|
+
context 'when access_token given' do
|
36
|
+
it 'gets the comment message, attributes, and user object' do
|
37
|
+
mock_graph :get, 'comment_id', 'comments/comment', :access_token => 'access_token' do
|
38
|
+
comment = FbGraph::Comment.fetch("comment_id", :access_token => 'access_token')
|
39
|
+
comment.identifier.should == '10151705618661509_29545180'
|
40
|
+
comment.can_comment == nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it "gets the list of replies for the comment" do
|
45
|
+
mock_graph :get, 'comment_id/comments', 'comments/comments/with_cursor_paging_params', :access_token => 'access_token' do
|
46
|
+
replies = FbGraph::Comment.new("comment_id", :access_token => 'access_token').comments
|
47
|
+
replies.should be_instance_of FbGraph::Connection
|
48
|
+
replies.should be_a FbGraph::Collection
|
49
|
+
replies.collection.next.should include :limit, :after
|
50
|
+
replies.collection.previous.should include :limit, :before
|
51
|
+
replies.collection.cursors.should include :before, :after
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when can_comment is passed into the fields parameter' do
|
56
|
+
it 'gets the can_comment attribute' do
|
57
|
+
mock_graph :get, 'comment_id', 'comments/with_can_comment', :access_token => 'access_token', :params => { :fields => 'can_comment' } do
|
58
|
+
comment = FbGraph::Comment.fetch("comment_id", :access_token => 'access_token', :fields => 'can_comment')
|
59
|
+
comment.identifier.should == '10151705618661509_29545180'
|
60
|
+
comment.can_comment.should == true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
31
67
|
end
|
@@ -72,4 +72,38 @@ describe FbGraph::Connections::Comments, '#comment!' do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe FbGraph::Comment, '#reply!' do
|
78
|
+
context 'when included by FbGraph::Post' do
|
79
|
+
context 'when no access_token given' do
|
80
|
+
it 'should raise FbGraph::Exception' do
|
81
|
+
mock_graph :post, '12345/comments', 'comments/comments/post_without_access_token', :status => [500, 'Internal Server Error'] do
|
82
|
+
lambda do
|
83
|
+
FbGraph::Post.new('12345').reply!(:message => 'hello')
|
84
|
+
end.should raise_exception(FbGraph::Exception)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'when invalid access_token is given' do
|
90
|
+
it 'should raise FbGraph::Exception' do
|
91
|
+
mock_graph :post, '12345/comments', 'comments/comments/post_with_invalid_access_token', :status => [500, 'Internal Server Error'] do
|
92
|
+
lambda do
|
93
|
+
FbGraph::Post.new('12345', :access_token => 'invalid').reply!(:message => 'hello')
|
94
|
+
end.should raise_exception(FbGraph::Exception)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'when valid access_token is given' do
|
100
|
+
it 'should return generated comment' do
|
101
|
+
mock_graph :post, '12345/comments', 'comments/comments/post_with_valid_access_token' do
|
102
|
+
reply = FbGraph::Comment.new('12345', :access_token => 'valid').reply!(:message => 'hello')
|
103
|
+
reply.should be_instance_of FbGraph::Comment
|
104
|
+
reply.identifier.should == '10151705618661509_29549300'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
75
109
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nov matake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -509,7 +509,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
509
509
|
version: '0'
|
510
510
|
requirements: []
|
511
511
|
rubyforge_project:
|
512
|
-
rubygems_version: 2.0.
|
512
|
+
rubygems_version: 2.0.2
|
513
513
|
signing_key:
|
514
514
|
specification_version: 4
|
515
515
|
summary: A full-stack Facebook Graph API wrapper in Ruby.
|