social_profile 0.2.2 → 0.3.0
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 +33 -5
- data/lib/social_profile/people/instagram.rb +21 -0
- data/lib/social_profile/people/vkontakte.rb +21 -0
- data/lib/social_profile/person.rb +1 -0
- data/lib/social_profile/version.rb +1 -1
- data/lib/social_profile.rb +1 -0
- data/social_profile.gemspec +2 -1
- data/spec/mock_json/facebook/mutual_friends.json +1008 -0
- data/spec/mock_json/instagram/last_posts.json +367 -0
- data/spec/mock_json/vkontakte/mutual_friends.json +3828 -0
- data/spec/mock_json/vkontakte/post.json +74 -0
- data/spec/people/facebook_spec.rb +13 -4
- data/spec/people/instagram_spec.rb +27 -0
- data/spec/people/vkontakte_spec.rb +15 -0
- metadata +46 -20
@@ -0,0 +1,74 @@
|
|
1
|
+
{
|
2
|
+
"response": {
|
3
|
+
"items": [
|
4
|
+
{
|
5
|
+
"id": 655,
|
6
|
+
"from_id": 2592709,
|
7
|
+
"owner_id": 2592709,
|
8
|
+
"date": 1349475107,
|
9
|
+
"post_type": "post",
|
10
|
+
"text": "",
|
11
|
+
"can_delete": 1,
|
12
|
+
"can_pin": 1,
|
13
|
+
"attachments": [
|
14
|
+
{
|
15
|
+
"type": "photo",
|
16
|
+
"photo": {
|
17
|
+
"id": 290498375,
|
18
|
+
"album_id": -7,
|
19
|
+
"owner_id": 2592709,
|
20
|
+
"photo_75": "https://pp.vk.me/...5/jM5ksRLZ110.jpg",
|
21
|
+
"photo_130": "https://pp.vk.me/...6/2RK71uZ-9mU.jpg",
|
22
|
+
"photo_604": "https://pp.vk.me/...7/9Q9mEfK7kQM.jpg",
|
23
|
+
"photo_807": "https://pp.vk.me/...8/Is3NFzEp0GU.jpg",
|
24
|
+
"photo_1280": "https://pp.vk.me/...9/UFIkcKtF_j0.jpg",
|
25
|
+
"width": 1280,
|
26
|
+
"height": 850,
|
27
|
+
"text": "Для тих, хто рідко нас бачить ;)",
|
28
|
+
"date": 1349475107,
|
29
|
+
"lat": 50.463954,
|
30
|
+
"long": 30.60247,
|
31
|
+
"access_key": "62ea232400459ba6d7"
|
32
|
+
}
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"type": "photos_list",
|
36
|
+
"photos_list": [
|
37
|
+
"2592709_290498375"
|
38
|
+
]
|
39
|
+
}
|
40
|
+
],
|
41
|
+
"post_source": {
|
42
|
+
"type": "vk"
|
43
|
+
},
|
44
|
+
"comments": {
|
45
|
+
"count": 3,
|
46
|
+
"can_post": 1
|
47
|
+
},
|
48
|
+
"likes": {
|
49
|
+
"count": 7,
|
50
|
+
"user_likes": 0,
|
51
|
+
"can_like": 1,
|
52
|
+
"can_publish": 0
|
53
|
+
},
|
54
|
+
"reposts": {
|
55
|
+
"count": 0,
|
56
|
+
"user_reposted": 0
|
57
|
+
}
|
58
|
+
}
|
59
|
+
],
|
60
|
+
"profiles": [
|
61
|
+
{
|
62
|
+
"id": 2592709,
|
63
|
+
"first_name": "Павел",
|
64
|
+
"last_name": "Галета",
|
65
|
+
"sex": 2,
|
66
|
+
"screen_name": "pavel.galeta",
|
67
|
+
"photo_50": "https://pp.vk.me/...09/e_a3716437.jpg",
|
68
|
+
"photo_100": "https://pp.vk.me/...09/d_847b328d.jpg",
|
69
|
+
"online": 1
|
70
|
+
}
|
71
|
+
],
|
72
|
+
"groups": []
|
73
|
+
}
|
74
|
+
}
|
@@ -28,21 +28,21 @@ describe SocialProfile::People::Facebook do
|
|
28
28
|
stub_request(:get, "https://graph.facebook.com/me/subscribers?access_token=abc&limit=1").
|
29
29
|
to_return(:status => 200, :body => fixture("facebook/followers.json"))
|
30
30
|
|
31
|
-
@user.followers_count.should ==
|
31
|
+
@user.followers_count.should == 0
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should response to followers without limits (without fetch_all)" do
|
35
35
|
stub_request(:get, "https://graph.facebook.com/me/subscribers?access_token=abc&limit=5000").
|
36
36
|
to_return(:status => 200, :body => fixture("facebook/followers.json"))
|
37
37
|
|
38
|
-
@user.followers.size.should ==
|
38
|
+
@user.followers.size.should == 0
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should response to followers without limits (with fetch_all)" do
|
42
42
|
stub_request(:get, "https://graph.facebook.com/me/subscribers?access_token=abc&limit=5000").
|
43
43
|
to_return(:status => 200, :body => fixture("facebook/followers.json"))
|
44
44
|
|
45
|
-
@user.followers(:fetch_all => true).size.should ==
|
45
|
+
@user.followers(:fetch_all => true).size.should == 0
|
46
46
|
end
|
47
47
|
|
48
48
|
it "should response to followers list with limits" do
|
@@ -53,7 +53,7 @@ describe SocialProfile::People::Facebook do
|
|
53
53
|
stub_request(:get, "https://graph.facebook.com/me/subscribers?access_token=abc&after=MTAwMDA0NDI3NDY3NjIx&limit=5").
|
54
54
|
to_return(:status => 200, :body => fixture("facebook/followers_5_15.json"))
|
55
55
|
|
56
|
-
@user.followers(:limit => 5, :fetch_all => true).size.should ==
|
56
|
+
@user.followers(:limit => 5, :fetch_all => true).size.should == 0
|
57
57
|
end
|
58
58
|
|
59
59
|
it "should response to first_post_exists?" do
|
@@ -120,5 +120,14 @@ describe SocialProfile::People::Facebook do
|
|
120
120
|
friends.should be_a(Array)
|
121
121
|
friends.size.should == 4343
|
122
122
|
end
|
123
|
+
|
124
|
+
it "should get mutual friends" do
|
125
|
+
mock_fql SocialProfile::People::Facebook::MUTUAL_FRIENDS, SocialProfile.root_path.join('spec/mock_json/facebook/mutual_friends.json'), :access_token => "abc" do
|
126
|
+
mutual_friends = @user.mutual_friends
|
127
|
+
|
128
|
+
mutual_friends.should be_a(Hash)
|
129
|
+
mutual_friends.size.should == 251
|
130
|
+
end
|
131
|
+
end
|
123
132
|
end
|
124
133
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SocialProfile::People::Instagram do
|
4
|
+
it "should be a Module" do
|
5
|
+
SocialProfile::People.should be_a(Module)
|
6
|
+
end
|
7
|
+
|
8
|
+
context "instagram" do
|
9
|
+
before(:each) do
|
10
|
+
@user = SocialProfile::Person.get(:instagram, "123456", "abc")
|
11
|
+
|
12
|
+
stub_request(:get, "https://api.instagram.com/v1/users/self/media/recent.json?access_token=abc&count=100").
|
13
|
+
to_return(:status => 200, :body => fixture('instagram/last_posts.json'))
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should be a instagram profile" do
|
17
|
+
@user.should be_a(SocialProfile::People::Instagram)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should response to last_posts" do
|
21
|
+
posts = @user.last_posts
|
22
|
+
|
23
|
+
posts.size.should == 4
|
24
|
+
posts.first.likes["count"].should == 6
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -29,6 +29,8 @@ describe SocialProfile::People::Vkontakte do
|
|
29
29
|
to_return(:status => 200, :body => fixture("vkontakte/followers.json"))
|
30
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
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").
|
33
|
+
to_return(:status => 200, :body => fixture("vkontakte/post.json"))
|
32
34
|
end
|
33
35
|
|
34
36
|
it "should be a vkontakte profile" do
|
@@ -111,5 +113,18 @@ describe SocialProfile::People::Vkontakte do
|
|
111
113
|
|
112
114
|
@user.followers(:count => 20).size.should == 30
|
113
115
|
end
|
116
|
+
|
117
|
+
it "should fetch post by id" do
|
118
|
+
response = @user.get_post("2592709_655")
|
119
|
+
response["items"].first["comments"]["count"].should == 3
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should get mutual_friends" do
|
123
|
+
stub_request(:get, /friends\.getMutual/).
|
124
|
+
to_return(:status => 200, :body => fixture("vkontakte/mutual_friends.json"))
|
125
|
+
|
126
|
+
_hash = @user.mutual_friends(:target_uids => "seperated_ids")
|
127
|
+
_hash.size.should == 206
|
128
|
+
end
|
114
129
|
end
|
115
130
|
end
|
metadata
CHANGED
@@ -1,111 +1,126 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social_profile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Galeta
|
8
|
+
- Pavel Galeta
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
16
17
|
requirements:
|
17
|
-
- - ~>
|
18
|
+
- - "~>"
|
18
19
|
- !ruby/object:Gem::Version
|
19
20
|
version: '1.3'
|
20
21
|
type: :development
|
21
22
|
prerelease: false
|
22
23
|
version_requirements: !ruby/object:Gem::Requirement
|
23
24
|
requirements:
|
24
|
-
- - ~>
|
25
|
+
- - "~>"
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '1.3'
|
27
28
|
- !ruby/object:Gem::Dependency
|
28
29
|
name: rake
|
29
30
|
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- -
|
32
|
+
- - ">="
|
32
33
|
- !ruby/object:Gem::Version
|
33
34
|
version: '0'
|
34
35
|
type: :development
|
35
36
|
prerelease: false
|
36
37
|
version_requirements: !ruby/object:Gem::Requirement
|
37
38
|
requirements:
|
38
|
-
- -
|
39
|
+
- - ">="
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
43
|
name: fb_graph
|
43
44
|
requirement: !ruby/object:Gem::Requirement
|
44
45
|
requirements:
|
45
|
-
- - ~>
|
46
|
+
- - "~>"
|
46
47
|
- !ruby/object:Gem::Version
|
47
48
|
version: 2.7.16
|
48
49
|
type: :runtime
|
49
50
|
prerelease: false
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
|
-
- - ~>
|
53
|
+
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: 2.7.16
|
55
56
|
- !ruby/object:Gem::Dependency
|
56
57
|
name: vkontakte
|
57
58
|
requirement: !ruby/object:Gem::Requirement
|
58
59
|
requirements:
|
59
|
-
- - ~>
|
60
|
+
- - "~>"
|
60
61
|
- !ruby/object:Gem::Version
|
61
62
|
version: 0.0.6
|
62
63
|
type: :runtime
|
63
64
|
prerelease: false
|
64
65
|
version_requirements: !ruby/object:Gem::Requirement
|
65
66
|
requirements:
|
66
|
-
- - ~>
|
67
|
+
- - "~>"
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: 0.0.6
|
69
70
|
- !ruby/object:Gem::Dependency
|
70
71
|
name: twitter
|
71
72
|
requirement: !ruby/object:Gem::Requirement
|
72
73
|
requirements:
|
73
|
-
- - ~>
|
74
|
+
- - "~>"
|
74
75
|
- !ruby/object:Gem::Version
|
75
76
|
version: 5.11.0
|
76
77
|
type: :runtime
|
77
78
|
prerelease: false
|
78
79
|
version_requirements: !ruby/object:Gem::Requirement
|
79
80
|
requirements:
|
80
|
-
- - ~>
|
81
|
+
- - "~>"
|
81
82
|
- !ruby/object:Gem::Version
|
82
83
|
version: 5.11.0
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: instagram
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.1.6
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.1.6
|
83
98
|
- !ruby/object:Gem::Dependency
|
84
99
|
name: httpclient
|
85
100
|
requirement: !ruby/object:Gem::Requirement
|
86
101
|
requirements:
|
87
|
-
- -
|
102
|
+
- - ">="
|
88
103
|
- !ruby/object:Gem::Version
|
89
104
|
version: '0'
|
90
105
|
type: :runtime
|
91
106
|
prerelease: false
|
92
107
|
version_requirements: !ruby/object:Gem::Requirement
|
93
108
|
requirements:
|
94
|
-
- -
|
109
|
+
- - ">="
|
95
110
|
- !ruby/object:Gem::Version
|
96
111
|
version: '0'
|
97
112
|
- !ruby/object:Gem::Dependency
|
98
113
|
name: multi_json
|
99
114
|
requirement: !ruby/object:Gem::Requirement
|
100
115
|
requirements:
|
101
|
-
- -
|
116
|
+
- - ">="
|
102
117
|
- !ruby/object:Gem::Version
|
103
118
|
version: '0'
|
104
119
|
type: :runtime
|
105
120
|
prerelease: false
|
106
121
|
version_requirements: !ruby/object:Gem::Requirement
|
107
122
|
requirements:
|
108
|
-
- -
|
123
|
+
- - ">="
|
109
124
|
- !ruby/object:Gem::Version
|
110
125
|
version: '0'
|
111
126
|
description: Wrapper for Omniauth profile hash, post photo to album
|
@@ -115,14 +130,15 @@ executables: []
|
|
115
130
|
extensions: []
|
116
131
|
extra_rdoc_files: []
|
117
132
|
files:
|
118
|
-
- .gitignore
|
119
|
-
- .rspec
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
120
135
|
- Gemfile
|
121
136
|
- LICENSE.txt
|
122
137
|
- README.md
|
123
138
|
- Rakefile
|
124
139
|
- lib/social_profile.rb
|
125
140
|
- lib/social_profile/people/facebook.rb
|
141
|
+
- lib/social_profile/people/instagram.rb
|
126
142
|
- lib/social_profile/people/twitter.rb
|
127
143
|
- lib/social_profile/people/vkontakte.rb
|
128
144
|
- lib/social_profile/person.rb
|
@@ -149,6 +165,8 @@ files:
|
|
149
165
|
- spec/mock_json/facebook/last_posts.json
|
150
166
|
- spec/mock_json/facebook/last_posts_big.json
|
151
167
|
- spec/mock_json/facebook/last_posts_big2.json
|
168
|
+
- spec/mock_json/facebook/mutual_friends.json
|
169
|
+
- spec/mock_json/instagram/last_posts.json
|
152
170
|
- spec/mock_json/twitter/auth.json
|
153
171
|
- spec/mock_json/twitter/last_posts.json
|
154
172
|
- spec/mock_json/twitter/token.json
|
@@ -164,8 +182,11 @@ files:
|
|
164
182
|
- spec/mock_json/vkontakte/last_posts_3.json
|
165
183
|
- spec/mock_json/vkontakte/likes_photo_290498375.json
|
166
184
|
- spec/mock_json/vkontakte/likes_post_655.json
|
185
|
+
- spec/mock_json/vkontakte/mutual_friends.json
|
186
|
+
- spec/mock_json/vkontakte/post.json
|
167
187
|
- spec/mock_json/vkontakte/shares_post_3675.json
|
168
188
|
- spec/people/facebook_spec.rb
|
189
|
+
- spec/people/instagram_spec.rb
|
169
190
|
- spec/people/twitter_spec.rb
|
170
191
|
- spec/people/vkontakte_spec.rb
|
171
192
|
- spec/providers/facebook_spec.rb
|
@@ -183,12 +204,12 @@ require_paths:
|
|
183
204
|
- lib
|
184
205
|
required_ruby_version: !ruby/object:Gem::Requirement
|
185
206
|
requirements:
|
186
|
-
- -
|
207
|
+
- - ">="
|
187
208
|
- !ruby/object:Gem::Version
|
188
209
|
version: '0'
|
189
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
211
|
requirements:
|
191
|
-
- -
|
212
|
+
- - ">="
|
192
213
|
- !ruby/object:Gem::Version
|
193
214
|
version: '0'
|
194
215
|
requirements: []
|
@@ -211,6 +232,8 @@ test_files:
|
|
211
232
|
- spec/mock_json/facebook/last_posts.json
|
212
233
|
- spec/mock_json/facebook/last_posts_big.json
|
213
234
|
- spec/mock_json/facebook/last_posts_big2.json
|
235
|
+
- spec/mock_json/facebook/mutual_friends.json
|
236
|
+
- spec/mock_json/instagram/last_posts.json
|
214
237
|
- spec/mock_json/twitter/auth.json
|
215
238
|
- spec/mock_json/twitter/last_posts.json
|
216
239
|
- spec/mock_json/twitter/token.json
|
@@ -226,8 +249,11 @@ test_files:
|
|
226
249
|
- spec/mock_json/vkontakte/last_posts_3.json
|
227
250
|
- spec/mock_json/vkontakte/likes_photo_290498375.json
|
228
251
|
- spec/mock_json/vkontakte/likes_post_655.json
|
252
|
+
- spec/mock_json/vkontakte/mutual_friends.json
|
253
|
+
- spec/mock_json/vkontakte/post.json
|
229
254
|
- spec/mock_json/vkontakte/shares_post_3675.json
|
230
255
|
- spec/people/facebook_spec.rb
|
256
|
+
- spec/people/instagram_spec.rb
|
231
257
|
- spec/people/twitter_spec.rb
|
232
258
|
- spec/people/vkontakte_spec.rb
|
233
259
|
- spec/providers/facebook_spec.rb
|