croudia 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/croudia/api/account.rb +11 -0
- data/lib/croudia/api/friendships.rb +14 -0
- data/lib/croudia/api/statuses.rb +12 -0
- data/lib/croudia/api/users.rb +11 -0
- data/lib/croudia/api/utils.rb +16 -4
- data/lib/croudia/client.rb +0 -1
- data/lib/croudia/default.rb +5 -2
- data/lib/croudia/relationship.rb +20 -0
- data/lib/croudia/request/multipart_with_file.rb +37 -0
- data/lib/croudia/user.rb +4 -0
- data/lib/croudia/version.rb +1 -1
- data/spec/croudia/api/account_spec.rb +19 -0
- data/spec/croudia/api/friendships_spec.rb +43 -0
- data/spec/croudia/api/statuses_spec.rb +28 -0
- data/spec/croudia/api/users_spec.rb +155 -0
- data/spec/fixtures/friendship.json +20 -0
- data/spec/fixtures/image.jpg +0 -0
- data/spec/fixtures/users.json +1 -0
- metadata +12 -4
- data/spec/croudia/api/user_spec.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35e3879bf61ffee0163b39e54634e1a8d9991813
|
4
|
+
data.tar.gz: cf39c427d33d8f07d54a50b1cf9622499f08ce40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c88dc315377489afa9fafa63cf8041c5df7e1559b254bfa7e68e6e34d30ac6dd6caa438353abd3a3786afe235855f87549132188cdd68a7d735cc5f97ad80c94
|
7
|
+
data.tar.gz: 51e113458a23c95d517f85b67dd5cce947713ec1db00acf5300e323a063e2fb4756b2c7bb6894e6c6b29aab0ca6844b30263c38d75275b3568d0898995b48d8b
|
data/lib/croudia/api/account.rb
CHANGED
@@ -12,6 +12,17 @@ module Croudia
|
|
12
12
|
Croudia::User.new(resp)
|
13
13
|
end
|
14
14
|
alias current_user verify_credentials
|
15
|
+
|
16
|
+
# Update profile image
|
17
|
+
#
|
18
|
+
# @param image [File] New profile image
|
19
|
+
# @param params [Hash]
|
20
|
+
# @return [Croudia::User] Authenticated user object with new image
|
21
|
+
def update_profile_image(image, params={})
|
22
|
+
merge_file!(params, image, :image)
|
23
|
+
resp = post('/account/update_profile_image.json', params)
|
24
|
+
Croudia::User.new(resp)
|
25
|
+
end
|
15
26
|
end
|
16
27
|
end
|
17
28
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'croudia/relationship'
|
1
2
|
require 'croudia/user'
|
2
3
|
|
3
4
|
module Croudia
|
@@ -25,6 +26,19 @@ module Croudia
|
|
25
26
|
Croudia::User.new(resp)
|
26
27
|
end
|
27
28
|
|
29
|
+
# Show relationship between two users
|
30
|
+
#
|
31
|
+
# @param source [String, Integer, Croudia::User]
|
32
|
+
# @param target [String, Integer, Croudia::User]
|
33
|
+
# @param params [Hash]
|
34
|
+
# @return [Croudia::Relationship]
|
35
|
+
def friendship(source, target={}, params={})
|
36
|
+
merge_user!(params, source, :source_screen_name, :source_id)
|
37
|
+
merge_user!(params, target, :target_screen_name, :target_id)
|
38
|
+
resp = get('/friendships/show.json', params)
|
39
|
+
Croudia::Relationship.new(resp)
|
40
|
+
end
|
41
|
+
|
28
42
|
# Lookup Friendships
|
29
43
|
#
|
30
44
|
# @param *users [String, Integer, Croudia::User]
|
data/lib/croudia/api/statuses.rb
CHANGED
@@ -15,6 +15,18 @@ module Croudia
|
|
15
15
|
Croudia::Status.new(resp)
|
16
16
|
end
|
17
17
|
|
18
|
+
# Update status with media
|
19
|
+
#
|
20
|
+
# @param status [String] Status text
|
21
|
+
# @param media [File] Image to upload with
|
22
|
+
# @return [Croudia::Status]
|
23
|
+
def update_with_media(status, media={}, params={})
|
24
|
+
merge_text!(params, status)
|
25
|
+
merge_file!(params, media, :media)
|
26
|
+
resp = post('/statuses/update_with_media.json', params)
|
27
|
+
Croudia::Status.new(resp)
|
28
|
+
end
|
29
|
+
|
18
30
|
# Destroy a status
|
19
31
|
#
|
20
32
|
# @param status_id [String, Integer, Croudia::Status] Status to delete
|
data/lib/croudia/api/users.rb
CHANGED
@@ -13,6 +13,17 @@ module Croudia
|
|
13
13
|
resp = get('/users/show.json', params)
|
14
14
|
Croudia::User.new(resp)
|
15
15
|
end
|
16
|
+
|
17
|
+
# Lookup Users
|
18
|
+
#
|
19
|
+
# @param *users [String, Integer, Croudia::User]
|
20
|
+
# @param params [Hash]
|
21
|
+
# @return [Array<Croudia::User>]
|
22
|
+
def users(*args)
|
23
|
+
merge_users!(params = {}, args)
|
24
|
+
resp = post('/users/lookup.json', params)
|
25
|
+
objects(Croudia::User, resp)
|
26
|
+
end
|
16
27
|
end
|
17
28
|
end
|
18
29
|
end
|
data/lib/croudia/api/utils.rb
CHANGED
@@ -15,16 +15,28 @@ module Croudia
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def merge_file!(params, file, key=:file)
|
19
|
+
case file
|
20
|
+
when Hash
|
21
|
+
params.merge!(file)
|
22
|
+
when File
|
23
|
+
params[key] = file
|
24
|
+
else
|
25
|
+
raise ArgumentError, "#{key} must be a File"
|
26
|
+
end
|
27
|
+
params
|
28
|
+
end
|
29
|
+
|
30
|
+
def merge_user!(params, user, sn_key=:screen_name, user_key=:user_id)
|
19
31
|
case user
|
20
32
|
when Hash
|
21
33
|
params.merge!(user)
|
22
34
|
when String
|
23
|
-
params[
|
35
|
+
params[sn_key] = user
|
24
36
|
when Integer
|
25
|
-
params[
|
37
|
+
params[user_key] = user
|
26
38
|
when Croudia::User
|
27
|
-
params[
|
39
|
+
params[user_key] = user.id_str
|
28
40
|
else
|
29
41
|
raise ArgumentError, 'user must be a String, Integer or User'
|
30
42
|
end
|
data/lib/croudia/client.rb
CHANGED
@@ -60,7 +60,6 @@ module Croudia
|
|
60
60
|
def request(method, path, params={})
|
61
61
|
connection.send(method.to_sym, path, params) do |request|
|
62
62
|
request.headers[:authorization] = "Bearer #{@access_token}" if @access_token
|
63
|
-
request.headers[:content_type] = 'application/x-www-form-urlencoded; charset=utf-8'
|
64
63
|
end.body
|
65
64
|
end
|
66
65
|
|
data/lib/croudia/default.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'faraday_middleware'
|
3
3
|
require 'croudia/configurable'
|
4
|
+
require 'croudia/request/multipart_with_file'
|
4
5
|
require 'croudia/version'
|
5
6
|
|
6
7
|
module Croudia
|
@@ -13,19 +14,21 @@ module Croudia
|
|
13
14
|
},
|
14
15
|
request: {
|
15
16
|
open_timeout: 5,
|
16
|
-
timeout:
|
17
|
+
timeout: 20,
|
17
18
|
},
|
18
19
|
ssl: {
|
19
20
|
verify: true,
|
20
21
|
},
|
21
22
|
} unless defined? Croudia::Default::CONNECTION_OPTIONS
|
22
23
|
MIDDLEWARE = Faraday::Builder.new do |builder|
|
24
|
+
builder.request :multipart_with_file
|
25
|
+
builder.request :multipart
|
23
26
|
builder.request :url_encoded
|
24
27
|
|
25
28
|
builder.response :json
|
26
29
|
builder.response :raise_error
|
27
30
|
|
28
|
-
builder.adapter
|
31
|
+
builder.adapter Faraday.default_adapter
|
29
32
|
end unless defined? Croudia::Default::MIDDLEWARE
|
30
33
|
|
31
34
|
class << self
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'croudia/base'
|
2
|
+
|
3
|
+
class Croudia::Relationship < Croudia::Base
|
4
|
+
KEYS = [
|
5
|
+
:souorce,
|
6
|
+
:target,
|
7
|
+
]
|
8
|
+
|
9
|
+
def relationship
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def source
|
14
|
+
@source ||= Croudia::User.new(@attrs['relationship']['source'])
|
15
|
+
end
|
16
|
+
|
17
|
+
def target
|
18
|
+
@target ||= Croudia::User.new(@attrs['relationship']['target'])
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module Croudia
|
4
|
+
module Request
|
5
|
+
class MultipartWithFile < Faraday::Middleware
|
6
|
+
CONTENT_TYPE = 'Content-Type'
|
7
|
+
|
8
|
+
def call(env)
|
9
|
+
env[:body].each do |key, value|
|
10
|
+
if value.respond_to?(:to_io)
|
11
|
+
env[:body][key] = Faraday::UploadIO.new(value, mime_type(value.path))
|
12
|
+
end
|
13
|
+
end if env[:body].is_a?(::Hash)
|
14
|
+
@app.call(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def mime_type(path)
|
20
|
+
case path
|
21
|
+
when /\.jpe?g\z/i
|
22
|
+
'image/jpeg'
|
23
|
+
when /\.gif\z/i
|
24
|
+
'image/gif'
|
25
|
+
when /\.png\z/i
|
26
|
+
'image/png'
|
27
|
+
else
|
28
|
+
'application/octet-stream'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Faraday.register_middleware :request,
|
37
|
+
:multipart_with_file => lambda { Croudia::Request::MultipartWithFile }
|
data/lib/croudia/user.rb
CHANGED
@@ -7,15 +7,19 @@ module Croudia
|
|
7
7
|
|
8
8
|
KEYS = [
|
9
9
|
:id_str,
|
10
|
+
:blocking,
|
10
11
|
:connections,
|
11
12
|
:description,
|
12
13
|
:favorites_count,
|
13
14
|
:follow_request_sent,
|
15
|
+
:followed_by,
|
16
|
+
:following,
|
14
17
|
:followers_count,
|
15
18
|
:friends_count,
|
16
19
|
:location,
|
17
20
|
:name,
|
18
21
|
:profile_image_url_https,
|
22
|
+
:protected,
|
19
23
|
:screen_name,
|
20
24
|
:statuses_count,
|
21
25
|
:url,
|
data/lib/croudia/version.rb
CHANGED
@@ -22,4 +22,23 @@ describe Croudia::API::Account do
|
|
22
22
|
expect(@client.verify_credentials).to be_a Croudia::User
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
describe '#update_profile_image' do
|
27
|
+
before do
|
28
|
+
stub_post('/account/update_profile_image.json').to_return(
|
29
|
+
body: fixture(:user),
|
30
|
+
headers: { content_type: 'application/json; charset=utf-8' }
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'requests the correct resource' do
|
35
|
+
@client.update_profile_image(fixture('image.jpg'))
|
36
|
+
expect(a_post('/account/update_profile_image.json')).to have_been_made
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns a Croudia::User' do
|
40
|
+
subject = @client.update_profile_image(fixture('image.jpg'))
|
41
|
+
expect(subject).to be_a Croudia::User
|
42
|
+
end
|
43
|
+
end
|
25
44
|
end
|
@@ -85,6 +85,49 @@ describe Croudia::API::Friendships do
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
describe '#friendship' do
|
89
|
+
before do
|
90
|
+
stub_get('/friendships/show.json').with(
|
91
|
+
query: {
|
92
|
+
source_id: '1234',
|
93
|
+
target_id: '3456',
|
94
|
+
}
|
95
|
+
).to_return(
|
96
|
+
body: fixture(:friendship),
|
97
|
+
headers: { content_type: 'appplication/json; charset=utf-8' }
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when passing a Hash' do
|
102
|
+
it 'requests the correct resource' do
|
103
|
+
@client.friendship(source_id: 1234, target_id: 3456)
|
104
|
+
expect(a_get('/friendships/show.json').with(
|
105
|
+
query: {
|
106
|
+
source_id: '1234',
|
107
|
+
target_id: '3456',
|
108
|
+
}
|
109
|
+
)).to have_been_made
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context 'when passing each argument' do
|
114
|
+
it 'requests the correct resource' do
|
115
|
+
@client.friendship(1234, 3456)
|
116
|
+
expect(a_get('/friendships/show.json').with(
|
117
|
+
query: {
|
118
|
+
source_id: '1234',
|
119
|
+
target_id: '3456',
|
120
|
+
}
|
121
|
+
)).to have_been_made
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'returns a Relationship' do
|
126
|
+
subject = @client.friendship(1234, 3456)
|
127
|
+
expect(subject).to be_a Croudia::Relationship
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
88
131
|
describe '#friendships' do
|
89
132
|
context 'when String is passed' do
|
90
133
|
before do
|
@@ -49,6 +49,34 @@ describe Croudia::API::Statuses do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
describe '#update_with_media' do
|
53
|
+
before do
|
54
|
+
stub_post('/statuses/update_with_media.json').to_return(
|
55
|
+
body: fixture(:status),
|
56
|
+
headers: { content_type: 'application/json; charset=utf-8' }
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when passing each argument' do
|
61
|
+
it 'requests the correct resource' do
|
62
|
+
@client.update_with_media('Hi', fixture('image.jpg'))
|
63
|
+
expect(a_post('/statuses/update_with_media.json')).to have_been_made
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when passing a Hash' do
|
68
|
+
it 'requests the correct resource' do
|
69
|
+
@client.update_with_media(status: 'Hi', media: fixture('image.jpg'))
|
70
|
+
expect(a_post('/statuses/update_with_media.json')).to have_been_made
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'returns a Croudia::Status' do
|
75
|
+
subject = @client.update_with_media('Hi', fixture('image.jpg'))
|
76
|
+
expect(subject).to be_a Croudia::Status
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
52
80
|
describe '#destroy_status' do
|
53
81
|
before do
|
54
82
|
stub_post('/statuses/destroy/1234.json').to_return(
|
@@ -0,0 +1,155 @@
|
|
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
|
+
|
57
|
+
describe '#users' do
|
58
|
+
context 'when String is passed' do
|
59
|
+
before do
|
60
|
+
stub_post('/users/lookup.json').with(
|
61
|
+
body: {
|
62
|
+
screen_name: 'wktk',
|
63
|
+
}
|
64
|
+
).to_return(
|
65
|
+
body: fixture(:users),
|
66
|
+
headers: { content_type: 'application/json; charset=utf-8' }
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'requests the correct resource' do
|
71
|
+
@client.users('wktk')
|
72
|
+
expect(a_post('/users/lookup.json')).to have_been_made
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'returns array of Croudia::User' do
|
76
|
+
subject = @client.users('wktk')
|
77
|
+
expect(subject).to be_an Array
|
78
|
+
subject.each { |u| expect(u).to be_a Croudia::User }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when Integer is passed' do
|
83
|
+
before do
|
84
|
+
stub_post('/users/lookup.json').with(
|
85
|
+
body: {
|
86
|
+
user_id: '1234',
|
87
|
+
}
|
88
|
+
).to_return(
|
89
|
+
body: fixture(:users),
|
90
|
+
headers: { content_type: 'application/json; charset=utf-8' }
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'requests the correct resource' do
|
95
|
+
@client.users(1234)
|
96
|
+
expect(a_post('/users/lookup.json')).to have_been_made
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'when multiple Strings are passed' do
|
101
|
+
before do
|
102
|
+
stub_post('/users/lookup.json').with(
|
103
|
+
body: {
|
104
|
+
screen_name: 'wktk,croudia',
|
105
|
+
}
|
106
|
+
).to_return(
|
107
|
+
body: fixture(:users),
|
108
|
+
headers: { content_type: 'application/json; charset=utf-8' }
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'requests the correct resource' do
|
113
|
+
@client.users('wktk', 'croudia')
|
114
|
+
expect(a_post('/users/lookup.json')).to have_been_made
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'when multiple Integers are passed' do
|
119
|
+
before do
|
120
|
+
stub_post('/users/lookup.json').with(
|
121
|
+
body: {
|
122
|
+
user_id: '1234,4567',
|
123
|
+
}
|
124
|
+
).to_return(
|
125
|
+
body: fixture(:users),
|
126
|
+
headers: { content_type: 'application/json; charset=utf-8' }
|
127
|
+
)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'requests the correct resource' do
|
131
|
+
@client.users(1234, 4567)
|
132
|
+
expect(a_post('/users/lookup.json')).to have_been_made
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
context 'when multiple String and Integer are passed' do
|
137
|
+
before do
|
138
|
+
stub_post('/users/lookup.json').with(
|
139
|
+
body: {
|
140
|
+
user_id: '1234,4567',
|
141
|
+
screen_name: 'wktk,croudia',
|
142
|
+
}
|
143
|
+
).to_return(
|
144
|
+
body: fixture(:users),
|
145
|
+
headers: { content_type: 'application/json; charset=utf-8' }
|
146
|
+
)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'requests the correct resource' do
|
150
|
+
@client.users('wktk', 1234, 'croudia', 4567)
|
151
|
+
expect(a_post('/users/lookup.json')).to have_been_made
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"relationship": {
|
3
|
+
"source": {
|
4
|
+
"blocking": null,
|
5
|
+
"followed_by": true,
|
6
|
+
"following": false,
|
7
|
+
"id": 1234,
|
8
|
+
"id_str": "1234",
|
9
|
+
"screen_name": "wktk"
|
10
|
+
},
|
11
|
+
"target": {
|
12
|
+
"blocking": null,
|
13
|
+
"followed_by": true,
|
14
|
+
"following": false,
|
15
|
+
"id": 3456,
|
16
|
+
"id_str": "3456",
|
17
|
+
"screen_name": "croudia"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
[{"id":7987,"id_str":"7987","name":"wktk","screen_name":"wktk","profile_image_url_https":"https://croudia.com/testimages/download/9423","created_at":"Sun, 29 Jul 2012 19:21:21 +0900","description":"気軽に fav ります。Twitter でも @wktk です。 \r\nhttps://twitter.com/wktk\r\nhttps://github.com/wktk","favorites_count":68,"follow_request_sent":"underdevelopment","followers_count":12,"following":"underdevelopment","friends_count":11,"location":"Japan","statuses_count":26,"protected":false,"url":"http://wktk.jp/"},{"id":7987,"id_str":"7987","name":"wktk","screen_name":"wktk","profile_image_url_https":"https://croudia.com/testimages/download/9423","created_at":"Sun, 29 Jul 2012 19:21:21 +0900","description":"気軽に fav ります。Twitter でも @wktk です。 \r\nhttps://twitter.com/wktk\r\nhttps://github.com/wktk","favorites_count":68,"follow_request_sent":"underdevelopment","followers_count":12,"following":"underdevelopment","friends_count":11,"location":"Japan","statuses_count":26,"protected":false,"url":"http://wktk.jp/"}]
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wktk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -126,6 +126,8 @@ files:
|
|
126
126
|
- lib/croudia/default.rb
|
127
127
|
- lib/croudia/ext/openssl.rb
|
128
128
|
- lib/croudia/identity.rb
|
129
|
+
- lib/croudia/relationship.rb
|
130
|
+
- lib/croudia/request/multipart_with_file.rb
|
129
131
|
- lib/croudia/secret_mail.rb
|
130
132
|
- lib/croudia/source.rb
|
131
133
|
- lib/croudia/status.rb
|
@@ -138,7 +140,7 @@ files:
|
|
138
140
|
- spec/croudia/api/secret_mails_spec.rb
|
139
141
|
- spec/croudia/api/statuses_spec.rb
|
140
142
|
- spec/croudia/api/timelines_spec.rb
|
141
|
-
- spec/croudia/api/
|
143
|
+
- spec/croudia/api/users_spec.rb
|
142
144
|
- spec/croudia/base_spec.rb
|
143
145
|
- spec/croudia/client_spec.rb
|
144
146
|
- spec/croudia/identity_spec.rb
|
@@ -148,12 +150,15 @@ files:
|
|
148
150
|
- spec/croudia/user_spec.rb
|
149
151
|
- spec/croudia_spec.rb
|
150
152
|
- spec/fixtures/access_token.json
|
153
|
+
- spec/fixtures/friendship.json
|
151
154
|
- spec/fixtures/friendships.json
|
155
|
+
- spec/fixtures/image.jpg
|
152
156
|
- spec/fixtures/secret_mail.json
|
153
157
|
- spec/fixtures/secret_mails.json
|
154
158
|
- spec/fixtures/status.json
|
155
159
|
- spec/fixtures/timeline.json
|
156
160
|
- spec/fixtures/user.json
|
161
|
+
- spec/fixtures/users.json
|
157
162
|
- spec/helper.rb
|
158
163
|
homepage: https://github.com/wktk/croudia-gem
|
159
164
|
licenses:
|
@@ -187,7 +192,7 @@ test_files:
|
|
187
192
|
- spec/croudia/api/secret_mails_spec.rb
|
188
193
|
- spec/croudia/api/statuses_spec.rb
|
189
194
|
- spec/croudia/api/timelines_spec.rb
|
190
|
-
- spec/croudia/api/
|
195
|
+
- spec/croudia/api/users_spec.rb
|
191
196
|
- spec/croudia/base_spec.rb
|
192
197
|
- spec/croudia/client_spec.rb
|
193
198
|
- spec/croudia/identity_spec.rb
|
@@ -197,10 +202,13 @@ test_files:
|
|
197
202
|
- spec/croudia/user_spec.rb
|
198
203
|
- spec/croudia_spec.rb
|
199
204
|
- spec/fixtures/access_token.json
|
205
|
+
- spec/fixtures/friendship.json
|
200
206
|
- spec/fixtures/friendships.json
|
207
|
+
- spec/fixtures/image.jpg
|
201
208
|
- spec/fixtures/secret_mail.json
|
202
209
|
- spec/fixtures/secret_mails.json
|
203
210
|
- spec/fixtures/status.json
|
204
211
|
- spec/fixtures/timeline.json
|
205
212
|
- spec/fixtures/user.json
|
213
|
+
- spec/fixtures/users.json
|
206
214
|
- spec/helper.rb
|
@@ -1,56 +0,0 @@
|
|
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
|