social_profile 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/social_profile/people/facebook.rb +23 -4
- data/lib/social_profile/people/twitter.rb +50 -0
- data/lib/social_profile/people/vkontakte.rb +186 -0
- data/lib/social_profile/providers/odnoklassniki.rb +74 -0
- data/lib/social_profile/version.rb +1 -1
- data/lib/social_profile.rb +2 -0
- data/social_profile.gemspec +3 -3
- data/spec/mock_json/facebook/followers_5_0.json +34 -0
- data/spec/mock_json/facebook/followers_5_10.json +35 -0
- data/spec/mock_json/facebook/followers_5_15.json +26 -0
- data/spec/mock_json/twitter/auth.json +1 -1
- data/spec/mock_json/twitter/last_posts.json +4326 -0
- data/spec/mock_json/vkontakte/comments_photos.json +707 -0
- data/spec/mock_json/vkontakte/comments_post_655.json +42 -0
- data/spec/mock_json/vkontakte/followers.json +187 -0
- data/spec/mock_json/vkontakte/followers_20.json +127 -0
- data/spec/mock_json/vkontakte/followers_20_2.json +67 -0
- data/spec/mock_json/vkontakte/friends.json +1728 -0
- data/spec/mock_json/vkontakte/last_posts.json +4279 -0
- data/spec/mock_json/vkontakte/last_posts_2.json +2736 -0
- data/spec/mock_json/vkontakte/last_posts_3.json +533 -0
- data/spec/mock_json/vkontakte/likes_photo_290498375.json +24 -0
- data/spec/mock_json/vkontakte/likes_post_655.json +14 -0
- data/spec/mock_json/vkontakte/shares_post_3675.json +1373 -0
- data/spec/people/facebook_spec.rb +25 -0
- data/spec/people/twitter_spec.rb +21 -1
- data/spec/people/vkontakte_spec.rb +95 -3
- data/spec/spec_helper.rb +1 -1
- metadata +47 -14
@@ -31,6 +31,31 @@ describe SocialProfile::People::Facebook do
|
|
31
31
|
@user.followers_count.should == 14
|
32
32
|
end
|
33
33
|
|
34
|
+
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
|
+
@user.followers.size.should == 13
|
39
|
+
end
|
40
|
+
|
41
|
+
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
|
+
@user.followers(:fetch_all => true).size.should == 13
|
46
|
+
end
|
47
|
+
|
48
|
+
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
|
+
@user.followers(:limit => 5, :fetch_all => true).size.should == 13
|
57
|
+
end
|
58
|
+
|
34
59
|
it "should response to first_post_exists?" do
|
35
60
|
_sql = SocialProfile::People::Facebook::FIRST_POST_FQL.gsub('{date}', '1293832800')
|
36
61
|
|
data/spec/people/twitter_spec.rb
CHANGED
@@ -12,6 +12,8 @@ describe SocialProfile::People::Twitter do
|
|
12
12
|
to_return(:body => fixture("twitter/token.json"), :headers => {:content_type => 'application/json; charset=utf-8'})
|
13
13
|
stub_request(:get, "https://api.twitter.com/1.1/account/verify_credentials.json").
|
14
14
|
to_return(:body => fixture('twitter/auth.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
|
15
|
+
stub_request(:get, "https://api.twitter.com/1.1/statuses/user_timeline.json?count=200&exclude_replies=true&include_rts=false&screen_name=150587663&trim_user=true").
|
16
|
+
to_return(:status => 200, :body => fixture('twitter/last_posts.json'))
|
15
17
|
end
|
16
18
|
|
17
19
|
it "should be a twitter profile" do
|
@@ -19,7 +21,25 @@ describe SocialProfile::People::Twitter do
|
|
19
21
|
end
|
20
22
|
|
21
23
|
it "should response to friends_count" do
|
22
|
-
@user.friends_count.should ==
|
24
|
+
@user.friends_count.should == 69
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should response to last_posts" do
|
28
|
+
posts = @user.last_posts("150587663")
|
29
|
+
|
30
|
+
retweets_count = posts.sum(&:retweet_count)
|
31
|
+
retweets_count.should == 9
|
32
|
+
posts.size.should == 107
|
33
|
+
|
34
|
+
# average user reach
|
35
|
+
(@user.friends_count + (retweets_count * 100) / posts.size).should == 77
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should response to get_all_tweets" do
|
39
|
+
posts = @user.last_posts("150587663")
|
40
|
+
|
41
|
+
posts.sum(&:retweet_count).should == 9
|
42
|
+
posts.size.should == 107
|
23
43
|
end
|
24
44
|
end
|
25
45
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe SocialProfile::People::Vkontakte do
|
@@ -7,9 +9,26 @@ describe SocialProfile::People::Vkontakte do
|
|
7
9
|
|
8
10
|
context "vkontakte" do
|
9
11
|
before(:each) do
|
10
|
-
@user = SocialProfile::Person.get(:vkontakte, "
|
11
|
-
|
12
|
-
|
12
|
+
@user = SocialProfile::Person.get(:vkontakte, "2592709", "abc")
|
13
|
+
|
14
|
+
stub_request(:get, "https://api.vk.com/method/users.get?access_token=abc&fields=counters&uids=2592709").
|
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").
|
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").
|
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").
|
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").
|
23
|
+
to_return(:status => 200, :body => fixture("vkontakte/comments_post_655.json"))
|
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
|
+
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").
|
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").
|
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").
|
31
|
+
to_return(:status => 200, :body => fixture("vkontakte/shares_post_3675.json"))
|
13
32
|
end
|
14
33
|
|
15
34
|
it "should be a vkontakte profile" do
|
@@ -19,5 +38,78 @@ describe SocialProfile::People::Vkontakte do
|
|
19
38
|
it "should response to friends_count" do
|
20
39
|
@user.friends_count.should > 0
|
21
40
|
end
|
41
|
+
|
42
|
+
it "should response to last_posts" do
|
43
|
+
@user.last_posts.size.should == 100
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should response to last_post_by_days by 30 days" do
|
47
|
+
@user.last_post_by_days(30).size.should == 0
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should response to last_post_by_days by 30 days with date_end options" do
|
51
|
+
@user.last_post_by_days(30, :date_end => DateTime.new(2014, 5, 17)).size.should == 1
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should response to last_post_by_days by 2119 days" do
|
55
|
+
stub_request(:get, "https://api.vk.com/method/wall.get?access_token=abc&count=100&filter=owner&offset=100&owner_id=2592709").
|
56
|
+
to_return(:status => 200, :body => fixture("vkontakte/last_posts_2.json"))
|
57
|
+
|
58
|
+
posts = @user.last_post_by_days(2119, :date_end => DateTime.new(2014, 8, 19))
|
59
|
+
|
60
|
+
posts.size.should == 175
|
61
|
+
posts.last["text"].should == "хочеш узнать про меня побольше? введи в google ник super_p."
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should response to object_likes" do
|
65
|
+
@user.object_likes("655")["items"].size.should == 7
|
66
|
+
@user.object_likes("290498375", :type => "photo")["items"].size.should == 17
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should response to object_likes with fetch_all" do
|
70
|
+
@user.object_likes("655", :fetch_all => true).size.should == 7
|
71
|
+
@user.object_likes("290498375", :type => "photo", :fetch_all => true).size.should == 17
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should response to post_comments" do
|
75
|
+
@user.post_comments("655")["items"].size.should == 3
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should response to post_comments with fetch_all" do
|
79
|
+
@user.post_comments("655", :fetch_all => true).size.should == 3
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should response to post_shares" do
|
83
|
+
@user.post_shares("3675")["items"].size.should == 21
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should response to post_shares with fetch_all" do
|
87
|
+
@user.post_shares("3675", :fetch_all => true).size.should == 21
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should response to photos_comments" do
|
91
|
+
@user.photos_comments.size.should == 100
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should response to photos_comments with days" do
|
95
|
+
@user.photos_comments(:days => 30).size.should == 0
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should fetch all friends" do
|
99
|
+
@user.friends.size.should == 208
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should fetch all followers" do
|
103
|
+
@user.followers.size.should == 30
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should fetch all followers with iteration by 20 items in step" do
|
107
|
+
stub_request(:get, "https://api.vk.com/method/users.getFollowers?access_token=abc&count=20&fields=screen_name&offset=0&user_id=2592709").
|
108
|
+
to_return(:status => 200, :body => fixture("vkontakte/followers_20.json"))
|
109
|
+
stub_request(:get, "https://api.vk.com/method/users.getFollowers?access_token=abc&count=20&fields=screen_name&offset=20&user_id=2592709").
|
110
|
+
to_return(:status => 200, :body => fixture("vkontakte/followers_20_2.json"))
|
111
|
+
|
112
|
+
@user.followers(:count => 20).size.should == 30
|
113
|
+
end
|
22
114
|
end
|
23
115
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_profile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Galeta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,44 +42,44 @@ dependencies:
|
|
42
42
|
name: fb_graph
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.7.16
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.7.16
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: vkontakte
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.0.6
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.0.6
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: twitter
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 5.11.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 5.11.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: httpclient
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/social_profile/providers/base.rb
|
130
130
|
- lib/social_profile/providers/facebook.rb
|
131
131
|
- lib/social_profile/providers/instagram.rb
|
132
|
+
- lib/social_profile/providers/odnoklassniki.rb
|
132
133
|
- lib/social_profile/providers/twitter.rb
|
133
134
|
- lib/social_profile/providers/vkontakte.rb
|
134
135
|
- lib/social_profile/response.rb
|
@@ -137,6 +138,9 @@ files:
|
|
137
138
|
- social_profile.gemspec
|
138
139
|
- spec/mock_json/facebook/first_post.json
|
139
140
|
- spec/mock_json/facebook/followers.json
|
141
|
+
- spec/mock_json/facebook/followers_5_0.json
|
142
|
+
- spec/mock_json/facebook/followers_5_10.json
|
143
|
+
- spec/mock_json/facebook/followers_5_15.json
|
140
144
|
- spec/mock_json/facebook/friends.json
|
141
145
|
- spec/mock_json/facebook/friends_count.json
|
142
146
|
- spec/mock_json/facebook/last_5_posts.json
|
@@ -146,8 +150,21 @@ files:
|
|
146
150
|
- spec/mock_json/facebook/last_posts_big.json
|
147
151
|
- spec/mock_json/facebook/last_posts_big2.json
|
148
152
|
- spec/mock_json/twitter/auth.json
|
153
|
+
- spec/mock_json/twitter/last_posts.json
|
149
154
|
- spec/mock_json/twitter/token.json
|
155
|
+
- spec/mock_json/vkontakte/comments_photos.json
|
156
|
+
- spec/mock_json/vkontakte/comments_post_655.json
|
157
|
+
- spec/mock_json/vkontakte/followers.json
|
158
|
+
- spec/mock_json/vkontakte/followers_20.json
|
159
|
+
- spec/mock_json/vkontakte/followers_20_2.json
|
160
|
+
- spec/mock_json/vkontakte/friends.json
|
150
161
|
- spec/mock_json/vkontakte/friends_count.json
|
162
|
+
- spec/mock_json/vkontakte/last_posts.json
|
163
|
+
- spec/mock_json/vkontakte/last_posts_2.json
|
164
|
+
- spec/mock_json/vkontakte/last_posts_3.json
|
165
|
+
- spec/mock_json/vkontakte/likes_photo_290498375.json
|
166
|
+
- spec/mock_json/vkontakte/likes_post_655.json
|
167
|
+
- spec/mock_json/vkontakte/shares_post_3675.json
|
151
168
|
- spec/people/facebook_spec.rb
|
152
169
|
- spec/people/twitter_spec.rb
|
153
170
|
- spec/people/vkontakte_spec.rb
|
@@ -183,6 +200,9 @@ summary: Wrapper for Omniauth profile hash
|
|
183
200
|
test_files:
|
184
201
|
- spec/mock_json/facebook/first_post.json
|
185
202
|
- spec/mock_json/facebook/followers.json
|
203
|
+
- spec/mock_json/facebook/followers_5_0.json
|
204
|
+
- spec/mock_json/facebook/followers_5_10.json
|
205
|
+
- spec/mock_json/facebook/followers_5_15.json
|
186
206
|
- spec/mock_json/facebook/friends.json
|
187
207
|
- spec/mock_json/facebook/friends_count.json
|
188
208
|
- spec/mock_json/facebook/last_5_posts.json
|
@@ -192,8 +212,21 @@ test_files:
|
|
192
212
|
- spec/mock_json/facebook/last_posts_big.json
|
193
213
|
- spec/mock_json/facebook/last_posts_big2.json
|
194
214
|
- spec/mock_json/twitter/auth.json
|
215
|
+
- spec/mock_json/twitter/last_posts.json
|
195
216
|
- spec/mock_json/twitter/token.json
|
217
|
+
- spec/mock_json/vkontakte/comments_photos.json
|
218
|
+
- spec/mock_json/vkontakte/comments_post_655.json
|
219
|
+
- spec/mock_json/vkontakte/followers.json
|
220
|
+
- spec/mock_json/vkontakte/followers_20.json
|
221
|
+
- spec/mock_json/vkontakte/followers_20_2.json
|
222
|
+
- spec/mock_json/vkontakte/friends.json
|
196
223
|
- spec/mock_json/vkontakte/friends_count.json
|
224
|
+
- spec/mock_json/vkontakte/last_posts.json
|
225
|
+
- spec/mock_json/vkontakte/last_posts_2.json
|
226
|
+
- spec/mock_json/vkontakte/last_posts_3.json
|
227
|
+
- spec/mock_json/vkontakte/likes_photo_290498375.json
|
228
|
+
- spec/mock_json/vkontakte/likes_post_655.json
|
229
|
+
- spec/mock_json/vkontakte/shares_post_3675.json
|
197
230
|
- spec/people/facebook_spec.rb
|
198
231
|
- spec/people/twitter_spec.rb
|
199
232
|
- spec/people/vkontakte_spec.rb
|