social_profile 0.3.0 → 0.3.1
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/Gemfile +4 -1
- data/lib/social_profile/people/facebook.rb +15 -38
- data/lib/social_profile/version.rb +1 -1
- data/social_profile.gemspec +1 -1
- data/spec/mock_json/facebook/friends_count.json +245 -3
- data/spec/people/facebook_spec.rb +16 -37
- data/spec/people/vkontakte_spec.rb +14 -14
- data/spec/spec_helper.rb +2 -4
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c21a840a30743393c5db4e6b8c50324eb8b85cfd
|
4
|
+
data.tar.gz: 75ed734e1adabffcd3900538b7dd0cfec0bf963f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 855914fce8f44a41e16b7c6ac685b9a0ebcfbcef4de0d4a9c1f5495359f522347d067fc910b1e7ea640453acb76159ee6885f5c04093bd27fcaf978b4dfa5ab0
|
7
|
+
data.tar.gz: df514b0f3f5dba7be28a6d17b483053a8f9bdc080625389956f382833f376e481b14ccdf444290fce83014b8edadc4366a1eb8c2e6ff2b57d6737ee63e8d9879
|
data/Gemfile
CHANGED
@@ -1,29 +1,26 @@
|
|
1
|
-
require "
|
1
|
+
require "fb_graph2"
|
2
2
|
|
3
3
|
module SocialProfile
|
4
4
|
module People
|
5
5
|
class Facebook < Person
|
6
|
-
FRIENDS_FQL = "SELECT friend_count FROM user WHERE uid=me()"
|
7
|
-
FIRST_POST_FQL = "SELECT created_time FROM stream WHERE source_id = me() AND created_time < {date} limit 1"
|
8
6
|
LAST_POSTS_FIELDS = [
|
9
|
-
"comments.fields(created_time).limit(1).summary(true)",
|
7
|
+
"comments.fields(created_time).limit(1).summary(true)",
|
10
8
|
"likes.limit(1).fields(id).summary(true)",
|
11
9
|
"created_time",
|
12
10
|
"shares"
|
13
11
|
]
|
14
12
|
POST_FIELDS = [
|
15
|
-
"comments.fields(created_time).limit(1).summary(true)",
|
13
|
+
"comments.fields(created_time).limit(1).summary(true)",
|
16
14
|
"likes.limit(1).fields(id).summary(true)",
|
17
15
|
"created_time",
|
18
16
|
"shares"
|
19
17
|
]
|
20
|
-
MUTUAL_FRIENDS = "SELECT uid, mutual_friend_count FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1=me()) ORDER BY mutual_friend_count"
|
21
18
|
|
22
19
|
# Find album by id
|
23
20
|
def fetch_album(album_id)
|
24
|
-
::
|
21
|
+
::FbGraph2::Album.fetch(album_id, :access_token => access_token)
|
25
22
|
end
|
26
|
-
|
23
|
+
|
27
24
|
# Create new album id
|
28
25
|
def album!(options = {})
|
29
26
|
user.album!(options)
|
@@ -32,7 +29,7 @@ module SocialProfile
|
|
32
29
|
# Get friends count
|
33
30
|
#
|
34
31
|
def friends_count
|
35
|
-
@friends_count ||=
|
32
|
+
@friends_count ||= friends(limit: 1).summary['total_count']
|
36
33
|
end
|
37
34
|
|
38
35
|
# Get followers count
|
@@ -41,27 +38,11 @@ module SocialProfile
|
|
41
38
|
@followers_count ||= followers(:limit => 1).size
|
42
39
|
end
|
43
40
|
|
44
|
-
|
45
|
-
response = FbGraph::Query.new(FRIENDS_FQL).fetch(:access_token => access_token)
|
46
|
-
|
47
|
-
response = response.first if response.is_a?(Array)
|
48
|
-
return nil if response.is_a?(Hash) && response["friend_count"].blank?
|
49
|
-
|
50
|
-
response["friend_count"].to_i
|
51
|
-
end
|
52
|
-
|
53
|
-
# Check if exists any post before current year
|
41
|
+
# Check if exists any post before current year
|
54
42
|
#
|
55
43
|
def first_post_exists?(year)
|
56
|
-
|
57
|
-
|
58
|
-
_sql = FIRST_POST_FQL.gsub('{date}', timestamp.to_s)
|
59
|
-
response = FbGraph::Query.new(_sql).fetch(:access_token => access_token)
|
60
|
-
|
61
|
-
response = response.first if response.is_a?(Array)
|
62
|
-
return nil if response.nil? || (response.is_a?(Hash) && response["created_time"].blank?)
|
63
|
-
|
64
|
-
response["created_time"].to_i
|
44
|
+
# TODO
|
45
|
+
return nil
|
65
46
|
end
|
66
47
|
|
67
48
|
# Get last limited posts from feed with comments, shares and likes counters
|
@@ -69,7 +50,7 @@ module SocialProfile
|
|
69
50
|
def last_posts(limit, options = {})
|
70
51
|
fields = options[:fields] || LAST_POSTS_FIELDS
|
71
52
|
|
72
|
-
user.feed(:fields => fields.join(","), :limit => limit)
|
53
|
+
user.feed(:fields => fields.join(","), :limit => limit)
|
73
54
|
end
|
74
55
|
|
75
56
|
# Get last post by days from feed with comments, shares and likes counters
|
@@ -82,7 +63,7 @@ module SocialProfile
|
|
82
63
|
|
83
64
|
posts = collection = last_posts(limit, options)
|
84
65
|
return [] if posts.blank? || posts.last.created_time.nil?
|
85
|
-
|
66
|
+
|
86
67
|
last_created_time = posts.last.created_time
|
87
68
|
|
88
69
|
while !last_created_time.blank? && last_created_time > date && iteration < max_iteration
|
@@ -131,23 +112,19 @@ module SocialProfile
|
|
131
112
|
def fetch_post(post_uid, options = {})
|
132
113
|
fields = options[:fields] || POST_FIELDS
|
133
114
|
|
134
|
-
::
|
115
|
+
::FbGraph2::Post.fetch(post_uid, :fields => fields.join(","), :access_token => access_token)
|
135
116
|
end
|
136
117
|
|
137
118
|
# Get friends list with mutual friends counter
|
138
119
|
#
|
139
120
|
def mutual_friends(options={})
|
140
|
-
|
141
|
-
|
142
|
-
return {} unless response.is_a?(Array)
|
143
|
-
|
144
|
-
response.inject({}) {|h, a| h.merge!(a["uid"] => a["mutual_friend_count"]) }
|
121
|
+
return {}
|
145
122
|
end
|
146
123
|
|
147
124
|
protected
|
148
|
-
|
125
|
+
|
149
126
|
def user
|
150
|
-
@user ||= ::
|
127
|
+
@user ||= ::FbGraph2::User.me(access_token)
|
151
128
|
end
|
152
129
|
end
|
153
130
|
end
|
data/social_profile.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
|
24
|
-
spec.add_dependency "
|
24
|
+
spec.add_dependency "fb_graph2", '~> 0.7.9'
|
25
25
|
spec.add_dependency "vkontakte", '~> 0.0.6'
|
26
26
|
spec.add_dependency "twitter", '~> 5.11.0'
|
27
27
|
spec.add_dependency "instagram", '~> 1.1.6'
|
@@ -1,7 +1,249 @@
|
|
1
1
|
{
|
2
2
|
"data": [
|
3
3
|
{
|
4
|
-
"
|
4
|
+
"name": "Eugene Koshevoy",
|
5
|
+
"id": "545778644"
|
6
|
+
},
|
7
|
+
{
|
8
|
+
"name": "Sasha Yatsenko",
|
9
|
+
"id": "547332829"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"name": "Borisov Kirill",
|
13
|
+
"id": "10153093142651662"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"name": "Kos Chekanov",
|
17
|
+
"id": "582680904"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"name": "Anna Petrova",
|
21
|
+
"id": "634769245"
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"name": "Andrew Volovyk",
|
25
|
+
"id": "665885244"
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"name": "Maksym Paraska",
|
29
|
+
"id": "682378737"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"name": "Andriy Yaroshenko",
|
33
|
+
"id": "685815706"
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"name": "Mike Podgorniy",
|
37
|
+
"id": "694308193"
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"name": "Dima Shvets",
|
41
|
+
"id": "815127247"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"name": "Sasha Chervonnaya",
|
45
|
+
"id": "844948619"
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"name": "Dmitrij Odnokoz",
|
49
|
+
"id": "1061020626"
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"name": "Maxim Balter",
|
53
|
+
"id": "1087671204"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"name": "Pavlo Pedenko",
|
57
|
+
"id": "1101865920"
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"name": "Iurii Gladkyi",
|
61
|
+
"id": "1110428611"
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"name": "Ivan Kucherenko",
|
65
|
+
"id": "1154110218"
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"name": "Yuri Babich",
|
69
|
+
"id": "1259841049"
|
70
|
+
},
|
71
|
+
{
|
72
|
+
"name": "Juriy Kolomiyets",
|
73
|
+
"id": "1261927378"
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"name": "Юджин Власов",
|
77
|
+
"id": "10206834744172225"
|
78
|
+
},
|
79
|
+
{
|
80
|
+
"name": "Dmitriy Pustovalov",
|
81
|
+
"id": "10206562048040150"
|
82
|
+
},
|
83
|
+
{
|
84
|
+
"name": "Yuriy Kachkarda",
|
85
|
+
"id": "1570795596"
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"name": "Yuriy Romanyukha",
|
89
|
+
"id": "1671304176"
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"name": "Yaroslav Korets",
|
93
|
+
"id": "10202827068552546"
|
94
|
+
},
|
95
|
+
{
|
96
|
+
"name": "Marat Tyncherov",
|
97
|
+
"id": "1702527121"
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"name": "Galya Fesenko",
|
101
|
+
"id": "100000034524504"
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"name": "Olga Polyakh",
|
105
|
+
"id": "100000079483665"
|
106
|
+
},
|
107
|
+
{
|
108
|
+
"name": "Dima Nikulin",
|
109
|
+
"id": "100000313477419"
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"name": "Valentine Hrytsenko",
|
113
|
+
"id": "100000387894888"
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"name": "Vadym Dzekunov",
|
117
|
+
"id": "100000389469252"
|
118
|
+
},
|
119
|
+
{
|
120
|
+
"name": "Yura Glushakov",
|
121
|
+
"id": "100000398199408"
|
122
|
+
},
|
123
|
+
{
|
124
|
+
"name": "Anna Kalinina",
|
125
|
+
"id": "100000595299107"
|
126
|
+
},
|
127
|
+
{
|
128
|
+
"name": "Vitaly Tkach",
|
129
|
+
"id": "100000639477252"
|
130
|
+
},
|
131
|
+
{
|
132
|
+
"name": "Dmytro Yevdokymov",
|
133
|
+
"id": "1113230018709990"
|
134
|
+
},
|
135
|
+
{
|
136
|
+
"name": "Natalie Vasylchenko",
|
137
|
+
"id": "100000744252267"
|
138
|
+
},
|
139
|
+
{
|
140
|
+
"name": "Kostya Alekseev",
|
141
|
+
"id": "100000820303483"
|
142
|
+
},
|
143
|
+
{
|
144
|
+
"name": "Renat Ziganshyn",
|
145
|
+
"id": "828323723871639"
|
146
|
+
},
|
147
|
+
{
|
148
|
+
"name": "Taras Parandii",
|
149
|
+
"id": "100001171241046"
|
150
|
+
},
|
151
|
+
{
|
152
|
+
"name": "Ana Prykhodko",
|
153
|
+
"id": "100001174874311"
|
154
|
+
},
|
155
|
+
{
|
156
|
+
"name": "Artem Pochepetsky",
|
157
|
+
"id": "100001415232830"
|
158
|
+
},
|
159
|
+
{
|
160
|
+
"name": "Slava Balbek",
|
161
|
+
"id": "877359342324659"
|
162
|
+
},
|
163
|
+
{
|
164
|
+
"name": "Eugene Zingerman",
|
165
|
+
"id": "836922379708720"
|
166
|
+
},
|
167
|
+
{
|
168
|
+
"name": "Dmitry Kornilov",
|
169
|
+
"id": "100001743198982"
|
170
|
+
},
|
171
|
+
{
|
172
|
+
"name": "Сергей Червонопильский",
|
173
|
+
"id": "792831290785009"
|
174
|
+
},
|
175
|
+
{
|
176
|
+
"name": "Stas Matviyenko",
|
177
|
+
"id": "100001747086412"
|
178
|
+
},
|
179
|
+
{
|
180
|
+
"name": "Игорь Шороп",
|
181
|
+
"id": "100001804116923"
|
182
|
+
},
|
183
|
+
{
|
184
|
+
"name": "Vitalii Malets",
|
185
|
+
"id": "100001853105079"
|
186
|
+
},
|
187
|
+
{
|
188
|
+
"name": "Pavel Matvienko",
|
189
|
+
"id": "100001869376766"
|
190
|
+
},
|
191
|
+
{
|
192
|
+
"name": "Евгений Красник",
|
193
|
+
"id": "100001871265273"
|
194
|
+
},
|
195
|
+
{
|
196
|
+
"name": "Kate Alexeyeva",
|
197
|
+
"id": "100001930447129"
|
198
|
+
},
|
199
|
+
{
|
200
|
+
"name": "Serhiy Matchuk",
|
201
|
+
"id": "840706946007392"
|
202
|
+
},
|
203
|
+
{
|
204
|
+
"name": "Andrew Litvin",
|
205
|
+
"id": "100002236334033"
|
206
|
+
},
|
207
|
+
{
|
208
|
+
"name": "Dasha Samoilenko",
|
209
|
+
"id": "100002296845982"
|
210
|
+
},
|
211
|
+
{
|
212
|
+
"name": "Pavlo Kuznetsov",
|
213
|
+
"id": "100002854099899"
|
214
|
+
},
|
215
|
+
{
|
216
|
+
"name": "Andrey Solopchuk",
|
217
|
+
"id": "100002858024403"
|
218
|
+
},
|
219
|
+
{
|
220
|
+
"name": "Alesya Karpuk",
|
221
|
+
"id": "100003959264633"
|
222
|
+
},
|
223
|
+
{
|
224
|
+
"name": "Anna Polishchuk",
|
225
|
+
"id": "100004485101723"
|
226
|
+
},
|
227
|
+
{
|
228
|
+
"name": "Maryna Tyshkevych",
|
229
|
+
"id": "100008037484267"
|
230
|
+
},
|
231
|
+
{
|
232
|
+
"name": "Дмитрий Миняйло",
|
233
|
+
"id": "196593574005953"
|
234
|
+
},
|
235
|
+
{
|
236
|
+
"name": "Supsay Ivan",
|
237
|
+
"id": "170045356726370"
|
238
|
+
}
|
239
|
+
],
|
240
|
+
"paging": {
|
241
|
+
"cursors": {
|
242
|
+
"before": "QVFIUndSUHZArRWVtbERubUV4LVByRm9uaE5Sa0VqaW4yYnNDQnJGQ05SRm1nSW0zVWNRZAUQ5dWRGOWxLWEhGVTJsR0QZD",
|
243
|
+
"after": "QVFIUjRIOXN3WWFYQVVZAcllkRUNGOWZAFRlQ2Rk1pRHlvaW1wX0xxMU0ya3lyeXNDSkVYSEd2TUoxQ1lKMzBLYXg5V0x4V0otaFp2OExFZA1Bwa0FmSjFvOTVR"
|
5
244
|
}
|
6
|
-
|
7
|
-
|
245
|
+
},
|
246
|
+
"summary": {
|
247
|
+
"total_count": 328
|
248
|
+
}
|
249
|
+
}
|
@@ -6,7 +6,7 @@ describe SocialProfile::People::Facebook do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
context "facebook" do
|
9
|
-
before :all do
|
9
|
+
before :all do
|
10
10
|
# FbGraph.debug!
|
11
11
|
end
|
12
12
|
|
@@ -19,55 +19,36 @@ describe SocialProfile::People::Facebook do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should response to friends_count" do
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
stub_request(:get, "https://graph.facebook.com/v2.3/me/friends?limit=1").
|
23
|
+
to_return(:status => 200, :body => fixture("facebook/friends_count.json"))
|
24
|
+
|
25
|
+
@user.friends_count.should == 328
|
25
26
|
end
|
26
27
|
|
27
28
|
it "should response to followers_count" do
|
28
|
-
stub_request(:get, "https://graph.facebook.com/me/subscribers?access_token=abc&limit=1").
|
29
|
-
to_return(:status => 200, :body => fixture("facebook/followers.json"))
|
30
|
-
|
31
29
|
@user.followers_count.should == 0
|
32
30
|
end
|
33
31
|
|
34
32
|
it "should response to followers without limits (without fetch_all)" do
|
35
|
-
stub_request(:get, "https://graph.facebook.com/me/subscribers?access_token=abc&limit=5000").
|
36
|
-
to_return(:status => 200, :body => fixture("facebook/followers.json"))
|
37
|
-
|
38
33
|
@user.followers.size.should == 0
|
39
34
|
end
|
40
35
|
|
41
36
|
it "should response to followers without limits (with fetch_all)" do
|
42
|
-
stub_request(:get, "https://graph.facebook.com/me/subscribers?access_token=abc&limit=5000").
|
43
|
-
to_return(:status => 200, :body => fixture("facebook/followers.json"))
|
44
|
-
|
45
37
|
@user.followers(:fetch_all => true).size.should == 0
|
46
38
|
end
|
47
39
|
|
48
40
|
it "should response to followers list with limits" do
|
49
|
-
stub_request(:get, "https://graph.facebook.com/me/subscribers?access_token=abc&limit=5").
|
50
|
-
to_return(:status => 200, :body => fixture("facebook/followers_5_0.json"))
|
51
|
-
stub_request(:get, "https://graph.facebook.com/me/subscribers?access_token=abc&after=MTE5ODU0NDEzNQ==&limit=5").
|
52
|
-
to_return(:status => 200, :body => fixture("facebook/followers_5_10.json"))
|
53
|
-
stub_request(:get, "https://graph.facebook.com/me/subscribers?access_token=abc&after=MTAwMDA0NDI3NDY3NjIx&limit=5").
|
54
|
-
to_return(:status => 200, :body => fixture("facebook/followers_5_15.json"))
|
55
|
-
|
56
41
|
@user.followers(:limit => 5, :fetch_all => true).size.should == 0
|
57
42
|
end
|
58
43
|
|
59
44
|
it "should response to first_post_exists?" do
|
60
|
-
|
61
|
-
|
62
|
-
mock_fql _sql, SocialProfile.root_path.join('spec/mock_json/facebook/first_post.json'), :access_token => "abc" do
|
63
|
-
@user.first_post_exists?(2011).should > 0
|
64
|
-
end
|
45
|
+
@user.first_post_exists?(2011).should == nil
|
65
46
|
end
|
66
47
|
|
67
48
|
it "should response to last_posts" do
|
68
49
|
fields = SocialProfile::People::Facebook::LAST_POSTS_FIELDS.join(",")
|
69
50
|
|
70
|
-
stub_request(:get, "https://graph.facebook.com/me/feed?
|
51
|
+
stub_request(:get, "https://graph.facebook.com/v2.3/me/feed?fields=#{fields}&limit=600").
|
71
52
|
to_return(:status => 200, :body => fixture("facebook/last_posts.json"))
|
72
53
|
|
73
54
|
posts = @user.last_posts(600)
|
@@ -80,11 +61,11 @@ describe SocialProfile::People::Facebook do
|
|
80
61
|
fields = SocialProfile::People::Facebook::LAST_POSTS_FIELDS.join(",")
|
81
62
|
fields2 = fields.gsub('.fields(created_time)', '')
|
82
63
|
|
83
|
-
stub_request(:get, "https://graph.facebook.com/me/feed?
|
64
|
+
stub_request(:get, "https://graph.facebook.com/v2.3/me/feed?fields=#{fields}&limit=5").
|
84
65
|
to_return(:status => 200, :body => fixture("facebook/last_5_posts.json"))
|
85
|
-
stub_request(:get, "https://graph.facebook.com/me/feed?
|
66
|
+
stub_request(:get, "https://graph.facebook.com/v2.3/me/feed?fields=#{fields2}&limit=5&until=1394475325").
|
86
67
|
to_return(:status => 200, :body => fixture("facebook/last_5_posts_page_2.json"))
|
87
|
-
stub_request(:get, "https://graph.facebook.com/me/feed?
|
68
|
+
stub_request(:get, "https://graph.facebook.com/v2.3/me/feed?fields=#{fields2}&limit=5&until=1394439420").
|
88
69
|
to_return(:status => 200, :body => fixture("facebook/last_5_posts_page_3.json"))
|
89
70
|
|
90
71
|
posts = @user.last_post_by_days(10, :limit => 5, :date_end => DateTime.new(2014, 3, 15))
|
@@ -99,9 +80,9 @@ describe SocialProfile::People::Facebook do
|
|
99
80
|
"shares",
|
100
81
|
"status_type"]
|
101
82
|
|
102
|
-
stub_request(:get, "https://graph.facebook.com/me/feed?
|
83
|
+
stub_request(:get, "https://graph.facebook.com/v2.3/me/feed?fields=#{fields.join(',')}&limit=1000").
|
103
84
|
to_return(:status => 200, :body => fixture("facebook/last_posts_big.json"))
|
104
|
-
stub_request(:get, "https://graph.facebook.com/me/feed?
|
85
|
+
stub_request(:get, "https://graph.facebook.com/v2.3/me/feed?fields=#{fields.join(',')}&limit=1000&until=1394789304").
|
105
86
|
to_return(:status => 200, :body => fixture("facebook/last_posts_big2.json"))
|
106
87
|
|
107
88
|
posts = @user.last_post_by_days(30, :limit => 1000, :date_end => DateTime.new(2014, 4, 6), :fields => fields)
|
@@ -112,7 +93,7 @@ describe SocialProfile::People::Facebook do
|
|
112
93
|
end
|
113
94
|
|
114
95
|
it "should get friends list" do
|
115
|
-
stub_request(:get, "https://graph.facebook.com/me/friends?
|
96
|
+
stub_request(:get, "https://graph.facebook.com/v2.3/me/friends?limit=100000").
|
116
97
|
to_return(:status => 200, :body => fixture("facebook/friends.json"))
|
117
98
|
|
118
99
|
friends = @user.friends(:limit => 100000)
|
@@ -122,12 +103,10 @@ describe SocialProfile::People::Facebook do
|
|
122
103
|
end
|
123
104
|
|
124
105
|
it "should get mutual friends" do
|
125
|
-
|
126
|
-
mutual_friends = @user.mutual_friends
|
106
|
+
mutual_friends = @user.mutual_friends
|
127
107
|
|
128
|
-
|
129
|
-
|
130
|
-
end
|
108
|
+
mutual_friends.should be_a(Hash)
|
109
|
+
mutual_friends.size.should == 0
|
131
110
|
end
|
132
111
|
end
|
133
112
|
end
|
@@ -11,25 +11,25 @@ describe SocialProfile::People::Vkontakte do
|
|
11
11
|
before(:each) do
|
12
12
|
@user = SocialProfile::Person.get(:vkontakte, "2592709", "abc")
|
13
13
|
|
14
|
-
stub_request(:get, "https://api.vk.com/method/users.get?access_token=abc&fields=counters&
|
14
|
+
stub_request(:get, "https://api.vk.com/method/users.get?access_token=abc&fields=counters&user_ids=2592709&v=5.24").
|
15
15
|
to_return(:status => 200, :body => fixture('vkontakte/friends_count.json'))
|
16
|
-
stub_request(:get, "https://api.vk.com/method/wall.get?access_token=abc&count=100&filter=owner&offset=0&owner_id=2592709").
|
16
|
+
stub_request(:get, "https://api.vk.com/method/wall.get?access_token=abc&count=100&filter=owner&offset=0&owner_id=2592709&v=5.24").
|
17
17
|
to_return(:status => 200, :body => fixture("vkontakte/last_posts.json"))
|
18
|
-
stub_request(:get, "https://api.vk.com/method/likes.getList?access_token=abc&count=1000&item_id=655&offset=0&owner_id=2592709&type=post").
|
18
|
+
stub_request(:get, "https://api.vk.com/method/likes.getList?access_token=abc&count=1000&item_id=655&offset=0&owner_id=2592709&type=post&v=5.24").
|
19
19
|
to_return(:status => 200, :body => fixture("vkontakte/likes_post_655.json"))
|
20
|
-
stub_request(:get, "https://api.vk.com/method/likes.getList?access_token=abc&count=1000&item_id=290498375&offset=0&owner_id=2592709&type=photo").
|
20
|
+
stub_request(:get, "https://api.vk.com/method/likes.getList?access_token=abc&count=1000&item_id=290498375&offset=0&owner_id=2592709&type=photo&v=5.24").
|
21
21
|
to_return(:status => 200, :body => fixture("vkontakte/likes_photo_290498375.json"))
|
22
|
-
stub_request(:get, "https://api.vk.com/method/wall.getComments?access_token=abc&count=100&need_likes=1&offset=0&owner_id=2592709&post_id=655&preview_length=0").
|
22
|
+
stub_request(:get, "https://api.vk.com/method/wall.getComments?access_token=abc&count=100&need_likes=1&offset=0&owner_id=2592709&post_id=655&preview_length=0&v=5.24").
|
23
23
|
to_return(:status => 200, :body => fixture("vkontakte/comments_post_655.json"))
|
24
24
|
stub_request(:get, "https://api.vk.com/method/photos.getAllComments?access_token=abc&count=100&need_likes=1&offset=0&owner_id=2592709&uid=2592709").
|
25
25
|
to_return(:status => 200, :body => fixture("vkontakte/comments_photos.json"))
|
26
|
-
stub_request(:get, "https://api.vk.com/method/friends.get?access_token=abc&count=5000&fields=domain&offset=0&user_id=2592709").
|
26
|
+
stub_request(:get, "https://api.vk.com/method/friends.get?access_token=abc&count=5000&fields=domain&offset=0&user_id=2592709&v=5.24").
|
27
27
|
to_return(:status => 200, :body => fixture("vkontakte/friends.json"))
|
28
|
-
stub_request(:get, "https://api.vk.com/method/users.getFollowers?access_token=abc&count=1000&fields=screen_name&offset=0&user_id=2592709").
|
28
|
+
stub_request(:get, "https://api.vk.com/method/users.getFollowers?access_token=abc&count=1000&fields=screen_name&offset=0&user_id=2592709&v=5.24").
|
29
29
|
to_return(:status => 200, :body => fixture("vkontakte/followers.json"))
|
30
|
-
stub_request(:get, "https://api.vk.com/method/wall.getReposts?access_token=abc&count=1000&offset=0&owner_id=2592709&post_id=3675").
|
30
|
+
stub_request(:get, "https://api.vk.com/method/wall.getReposts?access_token=abc&count=1000&offset=0&owner_id=2592709&post_id=3675&v=5.24").
|
31
31
|
to_return(:status => 200, :body => fixture("vkontakte/shares_post_3675.json"))
|
32
|
-
stub_request(:get, "https://api.vk.com/method/wall.getById?access_token=abc&extended=1&posts=2592709_655").
|
32
|
+
stub_request(:get, "https://api.vk.com/method/wall.getById?access_token=abc&extended=1&posts=2592709_655&v=5.24").
|
33
33
|
to_return(:status => 200, :body => fixture("vkontakte/post.json"))
|
34
34
|
end
|
35
35
|
|
@@ -54,7 +54,7 @@ describe SocialProfile::People::Vkontakte do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should response to last_post_by_days by 2119 days" do
|
57
|
-
stub_request(:get, "https://api.vk.com/method/wall.get?access_token=abc&count=100&filter=owner&offset=100&owner_id=2592709").
|
57
|
+
stub_request(:get, "https://api.vk.com/method/wall.get?access_token=abc&count=100&filter=owner&offset=100&owner_id=2592709&v=5.24").
|
58
58
|
to_return(:status => 200, :body => fixture("vkontakte/last_posts_2.json"))
|
59
59
|
|
60
60
|
posts = @user.last_post_by_days(2119, :date_end => DateTime.new(2014, 8, 19))
|
@@ -106,11 +106,11 @@ describe SocialProfile::People::Vkontakte do
|
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should fetch all followers with iteration by 20 items in step" do
|
109
|
-
stub_request(:get, "https://api.vk.com/method/users.getFollowers?access_token=abc&count=20&fields=screen_name&offset=0&user_id=2592709").
|
109
|
+
stub_request(:get, "https://api.vk.com/method/users.getFollowers?access_token=abc&count=20&fields=screen_name&offset=0&user_id=2592709&v=5.24").
|
110
110
|
to_return(:status => 200, :body => fixture("vkontakte/followers_20.json"))
|
111
|
-
stub_request(:get, "https://api.vk.com/method/users.getFollowers?access_token=abc&count=20&fields=screen_name&offset=20&user_id=2592709").
|
111
|
+
stub_request(:get, "https://api.vk.com/method/users.getFollowers?access_token=abc&count=20&fields=screen_name&offset=20&user_id=2592709&v=5.24").
|
112
112
|
to_return(:status => 200, :body => fixture("vkontakte/followers_20_2.json"))
|
113
|
-
|
113
|
+
|
114
114
|
@user.followers(:count => 20).size.should == 30
|
115
115
|
end
|
116
116
|
|
@@ -122,7 +122,7 @@ describe SocialProfile::People::Vkontakte do
|
|
122
122
|
it "should get mutual_friends" do
|
123
123
|
stub_request(:get, /friends\.getMutual/).
|
124
124
|
to_return(:status => 200, :body => fixture("vkontakte/mutual_friends.json"))
|
125
|
-
|
125
|
+
|
126
126
|
_hash = @user.mutual_friends(:target_uids => "seperated_ids")
|
127
127
|
_hash.size.should == 206
|
128
128
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require "rspec"
|
2
2
|
require "social_profile"
|
3
|
-
require '
|
4
|
-
|
5
|
-
include FbGraph::Mock
|
3
|
+
require 'webmock/rspec'
|
6
4
|
|
7
5
|
# Load support files
|
8
6
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
@@ -24,4 +22,4 @@ end
|
|
24
22
|
|
25
23
|
def fixture(file)
|
26
24
|
File.read(SocialProfile.root_path.join('spec/mock_json', file))
|
27
|
-
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_profile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Galeta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-08-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -40,19 +40,19 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: fb_graph2
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version:
|
48
|
+
version: 0.7.9
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 0.7.9
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: vkontakte
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
requirements: []
|
216
216
|
rubyforge_project:
|
217
|
-
rubygems_version: 2.
|
217
|
+
rubygems_version: 2.4.8
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Wrapper for Omniauth profile hash
|
@@ -261,3 +261,4 @@ test_files:
|
|
261
261
|
- spec/providers/twitter_spec.rb
|
262
262
|
- spec/providers/vkontakte_spec.rb
|
263
263
|
- spec/spec_helper.rb
|
264
|
+
has_rdoc:
|