croudia 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/README.md +2 -0
- data/lib/croudia/api/friendships.rb +53 -0
- data/lib/croudia/api/users.rb +30 -0
- data/lib/croudia/client.rb +4 -0
- data/lib/croudia/status.rb +4 -2
- data/lib/croudia/version.rb +1 -1
- data/spec/croudia/api/friendships_spec.rb +87 -0
- data/spec/croudia/api/user_spec.rb +56 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33f2b6ec843db67e93166dc5c052cc1e647f183b
|
4
|
+
data.tar.gz: ed05284c38fcc8c4e756ee76d25e0397b7de8b90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d48722bc4ac4a6586cf5e5c23420df6bdf16c7223e483fd3ae2a155dada39303cbec7cf97cbe0c05fc22e02201517135fa959d1bfd4f144c5e65d2544f713cf0
|
7
|
+
data.tar.gz: 136c18d8db07087a89137faed53c5e11009e85ddf4fa331ca16235e88d6c279ae6ea6b2196b1957d3c9f6d0a82705ba4a9527c11dc2589ab0bc65eb178b90d4d
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'croudia/user'
|
2
|
+
|
3
|
+
module Croudia
|
4
|
+
module API
|
5
|
+
module Friendships
|
6
|
+
# Follow a user
|
7
|
+
#
|
8
|
+
# @param user [String. Integer, Croudia::User]
|
9
|
+
# @param params [Hash] Optional params
|
10
|
+
# @return [Croudia::User] Followed user
|
11
|
+
def follow(user, params={})
|
12
|
+
case user
|
13
|
+
when Hash
|
14
|
+
params.merge!(user)
|
15
|
+
when String
|
16
|
+
params[:screen_name] = user
|
17
|
+
when Integer
|
18
|
+
params[:user_id] = user
|
19
|
+
when Croudia::User
|
20
|
+
params[:user_id] = user.id_str
|
21
|
+
else
|
22
|
+
raise ArgumentError, 'user must be a String, Integer or User'
|
23
|
+
end
|
24
|
+
|
25
|
+
resp = post('/friendships/create.json', params)
|
26
|
+
Croudia::User.new(resp)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Unfollow a user
|
30
|
+
#
|
31
|
+
# @param user [String, Integer, Croudia::User]
|
32
|
+
# @param params
|
33
|
+
# @return [Croudia::User] Unfollowed user
|
34
|
+
def unfollow(user, params={})
|
35
|
+
case user
|
36
|
+
when Hash
|
37
|
+
params.merge!(user)
|
38
|
+
when String
|
39
|
+
params[:screen_name] = user
|
40
|
+
when Integer
|
41
|
+
params[:user_id] = user
|
42
|
+
when Croudia::user
|
43
|
+
params[:user_id] = user.id_str
|
44
|
+
else
|
45
|
+
raise ArgumentError, 'user must be a String, Integer or User'
|
46
|
+
end
|
47
|
+
|
48
|
+
resp = post('/friendships/destroy.json', params)
|
49
|
+
Croudia::User.new(resp)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'croudia/user'
|
2
|
+
|
3
|
+
module Croudia
|
4
|
+
module API
|
5
|
+
module Users
|
6
|
+
# Retrieve a user
|
7
|
+
#
|
8
|
+
# @param user [String, Integer, Croudia::User]
|
9
|
+
# @param params [Hash] Optional params
|
10
|
+
# @return [Croudia::User]
|
11
|
+
def user(user, params={})
|
12
|
+
case user
|
13
|
+
when Hash
|
14
|
+
params.merge!(user)
|
15
|
+
when String
|
16
|
+
params[:screen_name] = user
|
17
|
+
when Integer
|
18
|
+
params[:user_id] = user
|
19
|
+
when Croudia::User
|
20
|
+
params[:user_id] = user.id_str
|
21
|
+
else
|
22
|
+
raise ArgumentError, 'user must be a String, Integer or User'
|
23
|
+
end
|
24
|
+
|
25
|
+
resp = get('/users/show.json', params)
|
26
|
+
Croudia::User.new(resp)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/croudia/client.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'croudia/api/account'
|
2
2
|
require 'croudia/api/favorites'
|
3
|
+
require 'croudia/api/friendships'
|
3
4
|
require 'croudia/api/oauth'
|
4
5
|
require 'croudia/api/statuses'
|
5
6
|
require 'croudia/api/timelines'
|
7
|
+
require 'croudia/api/users'
|
6
8
|
require 'croudia/configurable'
|
7
9
|
require 'croudia/ext/openssl'
|
8
10
|
require 'croudia/version'
|
@@ -12,9 +14,11 @@ module Croudia
|
|
12
14
|
class Client
|
13
15
|
include Croudia::API::Account
|
14
16
|
include Croudia::API::Favorites
|
17
|
+
include Croudia::API::Friendships
|
15
18
|
include Croudia::API::OAuth
|
16
19
|
include Croudia::API::Statuses
|
17
20
|
include Croudia::API::Timelines
|
21
|
+
include Croudia::API::Users
|
18
22
|
include Croudia::Configurable
|
19
23
|
|
20
24
|
# Initialize a new Client object
|
data/lib/croudia/status.rb
CHANGED
@@ -6,10 +6,10 @@ module Croudia
|
|
6
6
|
class Status < Croudia::Identity
|
7
7
|
include Croudia::Creatable
|
8
8
|
|
9
|
-
attr_reader :favorited, :
|
9
|
+
attr_reader :favorited, :favorited_count,
|
10
10
|
:in_reply_to_screen_name, :in_reply_to_status_id_str,
|
11
11
|
:in_reply_to_status_id, :in_reply_to_user_id_str,
|
12
|
-
:in_reply_to_user_id, :spread_count,
|
12
|
+
:in_reply_to_user_id, :spread, :spread_count, :spread_status,
|
13
13
|
:play_spread, :play_spread_status, :reply_status, :source,
|
14
14
|
:text, :user
|
15
15
|
|
@@ -17,10 +17,12 @@ module Croudia
|
|
17
17
|
user = attrs.delete('user')
|
18
18
|
pss = attrs.delete('play_spread_status')
|
19
19
|
reply_status = attrs.delete('reply_status')
|
20
|
+
spread_status = attrs.delete('spread_status')
|
20
21
|
super(attrs)
|
21
22
|
@attrs['user'] = Croudia::User.new(user) if user
|
22
23
|
@attrs['play_spread_status'] = Croudia::Status.new(pss) if pss
|
23
24
|
@attrs['reply_status'] = Croudia::Status.new(reply_status) if reply_status
|
25
|
+
@attrs['spread_status'] = Croudia::Status.new(spread_status) if spread_status
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
data/lib/croudia/version.rb
CHANGED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Croudia::API::Friendships do
|
4
|
+
before do
|
5
|
+
@client = Croudia::Client.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#follow' do
|
9
|
+
before do
|
10
|
+
stub_post('/friendships/create.json').to_return(
|
11
|
+
body: fixture(:user),
|
12
|
+
headers: { content_type: 'application/json; chrset=utf-8' }
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'when string is passed' do
|
17
|
+
it 'requests the correct resource' do
|
18
|
+
@client.follow('wktk')
|
19
|
+
expect(a_post('/friendships/create.json').with(
|
20
|
+
body: { screen_name: 'wktk' }
|
21
|
+
)).to have_been_made
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when integer is passed' do
|
26
|
+
it 'requests the correct resource' do
|
27
|
+
@client.follow(1234)
|
28
|
+
expect(a_post('/friendships/create.json').with(
|
29
|
+
body: { user_id: '1234' }
|
30
|
+
)).to have_been_made
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when hash is passed' do
|
35
|
+
it 'requests the correct resource' do
|
36
|
+
@client.follow(screen_name: 'wktk')
|
37
|
+
expect(a_post('/friendships/create.json').with(
|
38
|
+
body: { screen_name: 'wktk' }
|
39
|
+
)).to have_been_made
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns User object' do
|
44
|
+
expect(@client.follow('wktk')).to be_a Croudia::User
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#unfollow' do
|
49
|
+
before do
|
50
|
+
stub_post('/friendships/destroy.json').to_return(
|
51
|
+
body: fixture(:user),
|
52
|
+
headers: { content_type: 'application/json; charset=utf-8' }
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when string is passed' do
|
57
|
+
it 'requests the correct resource' do
|
58
|
+
@client.unfollow('wktk')
|
59
|
+
expect(a_post('/friendships/destroy.json').with(
|
60
|
+
body: { screen_name: 'wktk' }
|
61
|
+
)).to have_been_made
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'when integer is passed' do
|
66
|
+
it 'requests the correct resource' do
|
67
|
+
@client.unfollow(1234)
|
68
|
+
expect(a_post('/friendships/destroy.json').with(
|
69
|
+
body: { user_id: '1234' }
|
70
|
+
)).to have_been_made
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when hash is passed' do
|
75
|
+
it 'requests the correct resource' do
|
76
|
+
@client.unfollow(screen_name: 'wktk')
|
77
|
+
expect(a_post('/friendships/destroy.json').with(
|
78
|
+
body: { screen_name: 'wktk' }
|
79
|
+
)).to have_been_made
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'returns User object' do
|
84
|
+
expect(@client.unfollow('wktk')).to be_a Croudia::User
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Croudia::API::Users do
|
4
|
+
before do
|
5
|
+
@client = Croudia::Client.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#user' do
|
9
|
+
before do
|
10
|
+
stub_get('/users/show.json').with(
|
11
|
+
query: { screen_name: 'wktk' }
|
12
|
+
).to_return(
|
13
|
+
body: fixture(:user),
|
14
|
+
headers: { content_type: 'application/json; chrset=utf-8' }
|
15
|
+
)
|
16
|
+
|
17
|
+
stub_get('/users/show.json').with(
|
18
|
+
query: { user_id: 1234 }
|
19
|
+
).to_return(
|
20
|
+
body: fixture(:user),
|
21
|
+
headers: { content_type: 'application/json; chrset=utf-8' }
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'when string is passed' do
|
26
|
+
it 'requests the correct resource' do
|
27
|
+
@client.user('wktk')
|
28
|
+
expect(a_get('/users/show.json').with(
|
29
|
+
query: { screen_name: 'wktk' }
|
30
|
+
)).to have_been_made
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when integer is passed' do
|
35
|
+
it 'requests the correct resource' do
|
36
|
+
@client.user(1234)
|
37
|
+
expect(a_get('/users/show.json').with(
|
38
|
+
query: { user_id: 1234 }
|
39
|
+
)).to have_been_made
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'when hash is passed' do
|
44
|
+
it 'requests the correct resource' do
|
45
|
+
@client.user(screen_name: 'wktk')
|
46
|
+
expect(a_get('/users/show.json').with(
|
47
|
+
query: { screen_name: 'wktk' }
|
48
|
+
)).to have_been_made
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'returns User object' do
|
53
|
+
expect(@client.user('wktk')).to be_a Croudia::User
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: croudia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wktk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -102,6 +102,7 @@ extensions: []
|
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
104
|
- .gitignore
|
105
|
+
- .travis.yml
|
105
106
|
- Gemfile
|
106
107
|
- LICENSE
|
107
108
|
- README.md
|
@@ -111,9 +112,11 @@ files:
|
|
111
112
|
- lib/croudia/access_token.rb
|
112
113
|
- lib/croudia/api/account.rb
|
113
114
|
- lib/croudia/api/favorites.rb
|
115
|
+
- lib/croudia/api/friendships.rb
|
114
116
|
- lib/croudia/api/oauth.rb
|
115
117
|
- lib/croudia/api/statuses.rb
|
116
118
|
- lib/croudia/api/timelines.rb
|
119
|
+
- lib/croudia/api/users.rb
|
117
120
|
- lib/croudia/base.rb
|
118
121
|
- lib/croudia/client.rb
|
119
122
|
- lib/croudia/configurable.rb
|
@@ -126,9 +129,11 @@ files:
|
|
126
129
|
- lib/croudia/version.rb
|
127
130
|
- spec/croudia/api/account_spec.rb
|
128
131
|
- spec/croudia/api/favorites_spec.rb
|
132
|
+
- spec/croudia/api/friendships_spec.rb
|
129
133
|
- spec/croudia/api/oauth_spec.rb
|
130
134
|
- spec/croudia/api/statuses_spec.rb
|
131
135
|
- spec/croudia/api/timelines_spec.rb
|
136
|
+
- spec/croudia/api/user_spec.rb
|
132
137
|
- spec/croudia/base_spec.rb
|
133
138
|
- spec/croudia/client_spec.rb
|
134
139
|
- spec/croudia/identity_spec.rb
|
@@ -167,9 +172,11 @@ summary: Croudia API
|
|
167
172
|
test_files:
|
168
173
|
- spec/croudia/api/account_spec.rb
|
169
174
|
- spec/croudia/api/favorites_spec.rb
|
175
|
+
- spec/croudia/api/friendships_spec.rb
|
170
176
|
- spec/croudia/api/oauth_spec.rb
|
171
177
|
- spec/croudia/api/statuses_spec.rb
|
172
178
|
- spec/croudia/api/timelines_spec.rb
|
179
|
+
- spec/croudia/api/user_spec.rb
|
173
180
|
- spec/croudia/base_spec.rb
|
174
181
|
- spec/croudia/client_spec.rb
|
175
182
|
- spec/croudia/identity_spec.rb
|