fb_graph 2.1.11 → 2.1.12
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.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/fb_graph/checkin.rb +2 -0
- data/lib/fb_graph/connections/comments.rb +0 -11
- data/lib/fb_graph/connections/likes.rb +5 -4
- data/lib/fb_graph/connections/user_likes.rb +19 -0
- data/lib/fb_graph/user.rb +1 -1
- data/spec/fb_graph/connections/comments_spec.rb +0 -40
- data/spec/fb_graph/connections/likes_spec.rb +31 -42
- data/spec/fb_graph/connections/user_likes_spec.rb +55 -0
- metadata +6 -46
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.12
|
data/lib/fb_graph/checkin.rb
CHANGED
@@ -20,17 +20,6 @@ module FbGraph
|
|
20
20
|
:access_token => options[:access_token] || self.access_token
|
21
21
|
))
|
22
22
|
end
|
23
|
-
|
24
|
-
# NOTE:
|
25
|
-
# the context of getting likes is User, but the context of posting like is not user.
|
26
|
-
# posting like is always in same context with comment!
|
27
|
-
def like!(options = {})
|
28
|
-
post(options.merge(:connection => :likes))
|
29
|
-
end
|
30
|
-
|
31
|
-
def unlike!(options = {})
|
32
|
-
destroy(options.merge(:connection => :likes))
|
33
|
-
end
|
34
23
|
end
|
35
24
|
end
|
36
25
|
end
|
@@ -19,12 +19,13 @@ module FbGraph
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def like
|
23
|
-
|
24
|
-
like.present?
|
22
|
+
def like!(options = {})
|
23
|
+
post(options.merge(:connection => :likes))
|
25
24
|
end
|
26
25
|
|
27
|
-
|
26
|
+
def unlike!(options = {})
|
27
|
+
destroy(options.merge(:connection => :likes))
|
28
|
+
end
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module Connections
|
3
|
+
module UserLikes
|
4
|
+
def likes(options = {})
|
5
|
+
likes = self.connection(:likes, options)
|
6
|
+
likes.map! do |like|
|
7
|
+
Page.new(like[:id], like.merge!(
|
8
|
+
:access_token => options[:access_token] || self.access_token
|
9
|
+
))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def like?(page, options = {})
|
14
|
+
like = self.connection :likes, options.merge(:connection_scope => page.identifier)
|
15
|
+
like.present?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/fb_graph/user.rb
CHANGED
@@ -18,7 +18,6 @@ module FbGraph
|
|
18
18
|
include Connections::Home
|
19
19
|
include Connections::Inbox
|
20
20
|
include Connections::Interests
|
21
|
-
include Connections::Likes
|
22
21
|
include Connections::Links
|
23
22
|
include Connections::Movies
|
24
23
|
include Connections::Music
|
@@ -35,6 +34,7 @@ module FbGraph
|
|
35
34
|
include Connections::Television
|
36
35
|
include Connections::Threads
|
37
36
|
include Connections::UserAchievements
|
37
|
+
include Connections::UserLikes
|
38
38
|
include Connections::Videos
|
39
39
|
extend Searchable
|
40
40
|
|
@@ -60,44 +60,4 @@ describe FbGraph::Connections::Comments, '#comment!' do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe FbGraph::Connections::Comments, '#like!' do
|
66
|
-
context 'when included by FbGraph::Post' do
|
67
|
-
context 'when no access_token given' do
|
68
|
-
it 'should raise FbGraph::Exception' do
|
69
|
-
mock_graph :post, '12345/likes', 'posts/likes/post_without_access_token', :status => [500, 'Internal Server Error'] do
|
70
|
-
lambda do
|
71
|
-
FbGraph::Post.new('12345').like!
|
72
|
-
end.should raise_exception(FbGraph::Exception)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'when invalid access_token is given' do
|
78
|
-
it 'should raise FbGraph::Exception' do
|
79
|
-
mock_graph :post, '12345/likes', 'posts/likes/post_with_invalid_access_token', :status => [500, 'Internal Server Error'] do
|
80
|
-
lambda do
|
81
|
-
FbGraph::Post.new('12345', :access_token => 'invalid').like!
|
82
|
-
end.should raise_exception(FbGraph::Exception)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
context 'when valid access_token is given' do
|
88
|
-
it 'should return true' do
|
89
|
-
mock_graph :post, '12345/likes', 'posts/likes/post_with_valid_access_token' do
|
90
|
-
FbGraph::Post.new('12345', :access_token => 'valid').like!.should be_true
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe FbGraph::Connections::Comments, '#unlike!' do
|
98
|
-
it 'should DELETE /:object_id/likes' do
|
99
|
-
mock_graph :delete, '12345/likes', 'true', :access_token => 'valid' do
|
100
|
-
FbGraph::Post.new('12345', :access_token => 'valid').unlike!
|
101
|
-
end
|
102
|
-
end
|
103
63
|
end
|
@@ -3,35 +3,6 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe FbGraph::Connections::Likes do
|
5
5
|
describe '#likes' do
|
6
|
-
context 'when included by FbGraph::User' do
|
7
|
-
context 'when no access_token given' do
|
8
|
-
it 'should raise FbGraph::Unauthorized' do
|
9
|
-
mock_graph :get, 'arjun/likes', 'users/likes/arjun_public', :status => [401, 'Unauthorized'] do
|
10
|
-
lambda do
|
11
|
-
FbGraph::User.new('arjun').likes
|
12
|
-
end.should raise_exception(FbGraph::Unauthorized)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'when access_token is given' do
|
18
|
-
it 'should return liked pages as FbGraph::Page' do
|
19
|
-
mock_graph :get, 'arjun/likes', 'users/likes/arjun_private', :access_token => 'access_token' do
|
20
|
-
likes = FbGraph::User.new('arjun', :access_token => 'access_token').likes
|
21
|
-
likes.first.should == FbGraph::Page.new(
|
22
|
-
'378209722137',
|
23
|
-
:access_token => 'access_token',
|
24
|
-
:name => 'Doing Things at the Last Minute',
|
25
|
-
:category => '活動'
|
26
|
-
)
|
27
|
-
likes.each do |like|
|
28
|
-
like.should be_instance_of(FbGraph::Page)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
6
|
context 'when included by FbGraph::Status' do
|
36
7
|
context 'when cached collection exists' do
|
37
8
|
before do
|
@@ -73,25 +44,43 @@ describe FbGraph::Connections::Likes do
|
|
73
44
|
end
|
74
45
|
end
|
75
46
|
|
76
|
-
describe '#like
|
77
|
-
|
78
|
-
|
79
|
-
|
47
|
+
describe '#like!' do
|
48
|
+
context 'when included by FbGraph::Post' do
|
49
|
+
context 'when no access_token given' do
|
50
|
+
it 'should raise FbGraph::Exception' do
|
51
|
+
mock_graph :post, '12345/likes', 'posts/likes/post_without_access_token', :status => [500, 'Internal Server Error'] do
|
52
|
+
lambda do
|
53
|
+
FbGraph::Post.new('12345').like!
|
54
|
+
end.should raise_exception(FbGraph::Exception)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
80
58
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
59
|
+
context 'when invalid access_token is given' do
|
60
|
+
it 'should raise FbGraph::Exception' do
|
61
|
+
mock_graph :post, '12345/likes', 'posts/likes/post_with_invalid_access_token', :status => [500, 'Internal Server Error'] do
|
62
|
+
lambda do
|
63
|
+
FbGraph::Post.new('12345', :access_token => 'invalid').like!
|
64
|
+
end.should raise_exception(FbGraph::Exception)
|
65
|
+
end
|
85
66
|
end
|
86
67
|
end
|
87
|
-
end
|
88
68
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
69
|
+
context 'when valid access_token is given' do
|
70
|
+
it 'should return true' do
|
71
|
+
mock_graph :post, '12345/likes', 'posts/likes/post_with_valid_access_token' do
|
72
|
+
FbGraph::Post.new('12345', :access_token => 'valid').like!.should be_true
|
73
|
+
end
|
93
74
|
end
|
94
75
|
end
|
95
76
|
end
|
96
77
|
end
|
78
|
+
|
79
|
+
describe '#unlike!' do
|
80
|
+
it 'should DELETE /:object_id/likes' do
|
81
|
+
mock_graph :delete, '12345/likes', 'true', :access_token => 'valid' do
|
82
|
+
FbGraph::Post.new('12345', :access_token => 'valid').unlike!
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
97
86
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe FbGraph::Connections::Likes do
|
5
|
+
describe '#likes' do
|
6
|
+
context 'when no access_token given' do
|
7
|
+
it 'should raise FbGraph::Unauthorized' do
|
8
|
+
mock_graph :get, 'arjun/likes', 'users/likes/arjun_public', :status => [401, 'Unauthorized'] do
|
9
|
+
lambda do
|
10
|
+
FbGraph::User.new('arjun').likes
|
11
|
+
end.should raise_exception(FbGraph::Unauthorized)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when access_token is given' do
|
17
|
+
it 'should return liked pages as FbGraph::Page' do
|
18
|
+
mock_graph :get, 'arjun/likes', 'users/likes/arjun_private', :access_token => 'access_token' do
|
19
|
+
likes = FbGraph::User.new('arjun', :access_token => 'access_token').likes
|
20
|
+
likes.first.should == FbGraph::Page.new(
|
21
|
+
'378209722137',
|
22
|
+
:access_token => 'access_token',
|
23
|
+
:name => 'Doing Things at the Last Minute',
|
24
|
+
:category => '活動'
|
25
|
+
)
|
26
|
+
likes.each do |like|
|
27
|
+
like.should be_instance_of(FbGraph::Page)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#like?' do
|
35
|
+
let(:user) { FbGraph::User.new(579612276, :access_token => 'access_token') }
|
36
|
+
let(:fb_graph) { FbGraph::Page.new(117513961602338) }
|
37
|
+
let(:poken) { FbGraph::Page.new(1234567890) }
|
38
|
+
|
39
|
+
context 'when liked' do
|
40
|
+
it 'should retrun true' do
|
41
|
+
mock_graph :get, '579612276/likes/117513961602338', 'users/likes/fb_graph', :access_token => 'access_token' do
|
42
|
+
user.like?(fb_graph).should be_true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'otherwise' do
|
48
|
+
it 'should retrun true' do
|
49
|
+
mock_graph :get, '579612276/likes/1234567890', 'users/likes/poken', :access_token => 'access_token' do
|
50
|
+
user.like?(poken).should be_false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 29
|
5
4
|
prerelease:
|
6
|
-
|
7
|
-
- 2
|
8
|
-
- 1
|
9
|
-
- 11
|
10
|
-
version: 2.1.11
|
5
|
+
version: 2.1.12
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- nov matake
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-10-
|
13
|
+
date: 2011-10-25 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: httpclient
|
@@ -25,12 +20,6 @@ dependencies:
|
|
25
20
|
requirements:
|
26
21
|
- - ">="
|
27
22
|
- !ruby/object:Gem::Version
|
28
|
-
hash: 123
|
29
|
-
segments:
|
30
|
-
- 2
|
31
|
-
- 2
|
32
|
-
- 0
|
33
|
-
- 2
|
34
23
|
version: 2.2.0.2
|
35
24
|
type: :runtime
|
36
25
|
version_requirements: *id001
|
@@ -42,11 +31,6 @@ dependencies:
|
|
42
31
|
requirements:
|
43
32
|
- - ">="
|
44
33
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 51
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 9
|
49
|
-
- 4
|
50
34
|
version: 0.9.4
|
51
35
|
type: :runtime
|
52
36
|
version_requirements: *id002
|
@@ -58,10 +42,6 @@ dependencies:
|
|
58
42
|
requirements:
|
59
43
|
- - ">="
|
60
44
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 27
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
- 8
|
65
45
|
version: "0.8"
|
66
46
|
type: :development
|
67
47
|
version_requirements: *id003
|
@@ -73,10 +53,6 @@ dependencies:
|
|
73
53
|
requirements:
|
74
54
|
- - ">="
|
75
55
|
- !ruby/object:Gem::Version
|
76
|
-
hash: 25
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
- 9
|
80
56
|
version: "0.9"
|
81
57
|
type: :development
|
82
58
|
version_requirements: *id004
|
@@ -88,9 +64,6 @@ dependencies:
|
|
88
64
|
requirements:
|
89
65
|
- - ">="
|
90
66
|
- !ruby/object:Gem::Version
|
91
|
-
hash: 7
|
92
|
-
segments:
|
93
|
-
- 2
|
94
67
|
version: "2"
|
95
68
|
type: :development
|
96
69
|
version_requirements: *id005
|
@@ -102,11 +75,6 @@ dependencies:
|
|
102
75
|
requirements:
|
103
76
|
- - ">="
|
104
77
|
- !ruby/object:Gem::Version
|
105
|
-
hash: 11
|
106
|
-
segments:
|
107
|
-
- 1
|
108
|
-
- 6
|
109
|
-
- 2
|
110
78
|
version: 1.6.2
|
111
79
|
type: :development
|
112
80
|
version_requirements: *id006
|
@@ -118,11 +86,6 @@ dependencies:
|
|
118
86
|
requirements:
|
119
87
|
- - ">="
|
120
88
|
- !ruby/object:Gem::Version
|
121
|
-
hash: 11
|
122
|
-
segments:
|
123
|
-
- 3
|
124
|
-
- 0
|
125
|
-
- 6
|
126
89
|
version: 3.0.6
|
127
90
|
type: :development
|
128
91
|
version_requirements: *id007
|
@@ -239,6 +202,7 @@ files:
|
|
239
202
|
- lib/fb_graph/connections/test_users.rb
|
240
203
|
- lib/fb_graph/connections/threads.rb
|
241
204
|
- lib/fb_graph/connections/user_achievements.rb
|
205
|
+
- lib/fb_graph/connections/user_likes.rb
|
242
206
|
- lib/fb_graph/connections/videos.rb
|
243
207
|
- lib/fb_graph/debugger.rb
|
244
208
|
- lib/fb_graph/doc.rb
|
@@ -368,6 +332,7 @@ files:
|
|
368
332
|
- spec/fb_graph/connections/test_users_spec.rb
|
369
333
|
- spec/fb_graph/connections/threads_spec.rb
|
370
334
|
- spec/fb_graph/connections/user_achievements_spec.rb
|
335
|
+
- spec/fb_graph/connections/user_likes_spec.rb
|
371
336
|
- spec/fb_graph/connections/videos_spec.rb
|
372
337
|
- spec/fb_graph/debugger_spec.rb
|
373
338
|
- spec/fb_graph/doc_spec.rb
|
@@ -591,23 +556,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
591
556
|
requirements:
|
592
557
|
- - ">="
|
593
558
|
- !ruby/object:Gem::Version
|
594
|
-
hash: 3
|
595
|
-
segments:
|
596
|
-
- 0
|
597
559
|
version: "0"
|
598
560
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
599
561
|
none: false
|
600
562
|
requirements:
|
601
563
|
- - ">="
|
602
564
|
- !ruby/object:Gem::Version
|
603
|
-
hash: 3
|
604
|
-
segments:
|
605
|
-
- 0
|
606
565
|
version: "0"
|
607
566
|
requirements: []
|
608
567
|
|
609
568
|
rubyforge_project:
|
610
|
-
rubygems_version: 1.8.
|
569
|
+
rubygems_version: 1.8.10
|
611
570
|
signing_key:
|
612
571
|
specification_version: 3
|
613
572
|
summary: A full-stack Facebook Graph API wrapper in Ruby.
|
@@ -695,6 +654,7 @@ test_files:
|
|
695
654
|
- spec/fb_graph/connections/test_users_spec.rb
|
696
655
|
- spec/fb_graph/connections/threads_spec.rb
|
697
656
|
- spec/fb_graph/connections/user_achievements_spec.rb
|
657
|
+
- spec/fb_graph/connections/user_likes_spec.rb
|
698
658
|
- spec/fb_graph/connections/videos_spec.rb
|
699
659
|
- spec/fb_graph/debugger_spec.rb
|
700
660
|
- spec/fb_graph/doc_spec.rb
|