croudia 1.3.0 → 1.4.0

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWQ5NmY1NTk4MWFkOWQ0OTE3OWNjODM3NTBkYzI1NzcxZDdkYzNmNQ==
4
+ MmU2ZDc5NjMxNmJjMTkxNGY4NTc5MzY2NzMxYjI5Mzk5ZTc4YWJiMA==
5
5
  data.tar.gz: !binary |-
6
- OGY0Y2I1NTRjYzFiYzU0ZWFjZjg0NDdkM2Y2NWIxZTZiMjQ2ZjA3Zg==
6
+ NTYyMWRlMjZkMGU0MzRkM2RmYTRiNmJmNmU5OGNiNTdmOWNkYjY0MQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTllMDhhYTEyMzQ2Mjg3OTYzZGZmOTgxNDAzZGM4YWI0Mzk0MTQ0MDc5ZmNj
10
- MjA1ODM2M2M5NmVmMDU1YmJjZDBlNzU5ZDZmYjgyOTM0MTY1YTMwOWYzNGYx
11
- M2YxYmZhODcyYjNkYTk5M2MyOWRhNzA4NTU3Yzc0MmVhMzVmOGM=
9
+ ZTRiZTkyMDRmMmJlZTE5OTE4MWUyNTIwMDVjYTQyZTc4NWE0MjNmYTFiZTIw
10
+ NGViODgzMTAwZWIyYzFmZTkxMGNjY2ZmOWYwYjY3NDA2MDhiNGVjNGNmOWUy
11
+ YzJkODNlZTQ1NDAwZjZkYmZkMzY5ZWUzOGQ3MjAwNTFlMjYwMTk=
12
12
  data.tar.gz: !binary |-
13
- Njk1NDI1ZDZkODY0MmRkNjBkMzllZGZlZTlkMmExYmRlN2ZjMjZmM2JiODQ0
14
- N2MwZDRjM2U3YWU1Nzg2YjUwNTc3NzQ4MTRhOTcyMDJmOThlMzM0OWI5M2Vk
15
- ZmRjMmE3YmFjZTM3M2FiYWIyNDg5M2FjYzZmNzRmOWVkODliYzQ=
13
+ YmRhZTQ0M2ZlMzA2ODNkNDUzYzM1N2Y1MDViMjVhYTBkYjkyNGVmZjIzZTVi
14
+ NzFiZDFmOWU5NzQ1NmE4MTdiMzY2MDRmZGM1OTc1OWE1MDFlZWFlODA0MjRm
15
+ ZmVlZDQ1NWUwZTY0ZmZhODI3MTc4NmYzOTMzZmYzN2JjMWE1MDk=
data/.gitignore CHANGED
@@ -4,6 +4,7 @@
4
4
  .config
5
5
  .env
6
6
  .rbenv-vars
7
+ .ruby-version
7
8
  .yardoc
8
9
  Gemfile.lock
9
10
  InstalledFiles
data/.travis.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.1.0
3
4
  - 2.0.0
4
5
  - 1.9.3
5
6
  deploy:
@@ -10,13 +10,11 @@ module Croudia
10
10
  # @param [String] status Status text
11
11
  # @param [Hash] params Additional query parameters
12
12
  # @option params [String, Integer] :in_reply_to_status_id
13
- # @option params [String] :in_reply_with_quote Set true if quote
14
13
  # @option params [String] :include_entities Set false to exclude entities
15
14
  # @option params [String] :trim_user Set true to return compact user objects
16
15
  # @overload update(params={})
17
16
  # @param [Hash] params Query parameters
18
17
  # @option params [String, Integer] :in_reply_to_status_id
19
- # @option params [String] :in_reply_with_quote Set true if quote
20
18
  # @option params [String] :include_entities Set false to exclude entities
21
19
  # @option params [String] :status Status text
22
20
  # @option params [String] :trim_user Set true to return compact user objects
@@ -37,13 +35,11 @@ module Croudia
37
35
  # @param [File, #to_io] media Image to upload with
38
36
  # @param [Hash] params Additional query parameters
39
37
  # @option params [String, Integer] :in_reply_to_status_id
40
- # @option params [String] :in_reply_with_quote Set true if quote
41
38
  # @option params [String] :include_entities Set false to exclude entities
42
39
  # @option params [String] :trim_user Set true to return compact user objects
43
40
  # @overload update_with_media(params={})
44
41
  # @param [Hash] params Query parameters
45
42
  # @option params [String, Integer] :in_reply_to_status_id
46
- # @option params [String] :in_reply_with_quote Set true if quote
47
43
  # @option params [String] :include_entities Set false to exclude entities
48
44
  # @option params [File, #to_io] :media Image to upload with
49
45
  # @option params [String] :status Status text
@@ -97,6 +93,57 @@ module Croudia
97
93
  resp = post("/statuses/spread/#{status_id}.json", params)
98
94
  Croudia::Status.new(resp)
99
95
  end
96
+
97
+ # Share (formerly reply with quote) a status
98
+ #
99
+ # @see https://developer.croudia.com/docs/110_statuses_share
100
+ # @overload share(id, status, params={})
101
+ # @param [String, Integer, Croudia::Status] id Post to share
102
+ # @param [String] status Status text
103
+ # @param [Hash] params Additional query parameters
104
+ # @option params [String] :include_entities Set false to exclude entities
105
+ # @option params [String] :trim_user Set true to return compact user objects
106
+ # @overload share(params={})
107
+ # @param [Hash] params Query parameters
108
+ # @option params [String, Integer, Croudia::Status] :id Post to share
109
+ # @option params [String] :status Status text
110
+ # @option params [String] :include_entities Set false to exclude entities
111
+ # @option params [String] :trim_user Set true to return compact user objects
112
+ # @return [Croudia::Status] Posted status
113
+ def share(id, status={}, params={})
114
+ merge_id!(params, id)
115
+ merge_text!(params, status)
116
+ resp = post('/statuses/share.json', params)
117
+ Croudia::Status.new(resp)
118
+ end
119
+
120
+ # Share (formerly reply with quote) a status with media
121
+ #
122
+ # @see https://developer.croudia.com/docs/111_statuses_share_with_media
123
+ # @note Currently only PNG, JPG, and GIF are supported
124
+ # @overload share_with_media(id, status, media, params={})
125
+ # @param [String, Integer, Croudia::Status] id Post to share
126
+ # @param [String] status Status text
127
+ # @param [File, #to_io] media Image to upload with
128
+ # @param [Hash] params Additional query parameters
129
+ # @option params [String] :include_entities Set false to exclude entities
130
+ # @option params [String] :trim_user Set true to return compact user objects
131
+ # @overload share_with_media(params={})
132
+ # @param [Hash] params Query parameters
133
+ # @option params [String, Integer, Croudia::Status] :id Post to share
134
+ # @option params [String] :include_entities Set false to exclude entities
135
+ # @option params [File, #to_io] :media Image to upload with
136
+ # @option params [String] :status Status text
137
+ # @option params [String] :trim_user Set true to return compact user objects
138
+ # @return [Croudia::Status]
139
+ def share_with_media(id, status={}, media={}, params={})
140
+ merge_id!(params, id)
141
+ merge_text!(params, status)
142
+ merge_file!(params, media, :media)
143
+ resp = post('/statuses/share_with_media.json', params)
144
+ Croudia::Status.new(resp)
145
+ end
146
+
100
147
  end
101
148
  end
102
149
  end
@@ -91,6 +91,17 @@ module Croudia
91
91
  params
92
92
  end
93
93
 
94
+ def merge_id!(params, id, key=:id)
95
+ case id
96
+ when Hash
97
+ params.merge!(id)
98
+ else
99
+ params[key] = get_id(id)
100
+ end
101
+
102
+ params
103
+ end
104
+
94
105
  def objects(klass, array)
95
106
  array.map { |hash| klass.new(hash) }
96
107
  end
data/lib/croudia/base.rb CHANGED
@@ -65,7 +65,7 @@ module Croudia
65
65
  alias to_hash attrs
66
66
 
67
67
  def inspect
68
- "#<#{self.class}:0x#{__id__.abs.to_s(16)} #{@attrs.inspect}>"
68
+ "#<#{self.class} #{@attrs.inspect}>"
69
69
  end
70
70
  end
71
71
  end
@@ -1,3 +1,3 @@
1
1
  module Croudia
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
@@ -130,4 +130,65 @@ describe Croudia::API::Statuses do
130
130
  expect(@client.spread(1234)).to be_a Croudia::Status
131
131
  end
132
132
  end
133
+
134
+ describe '#share' do
135
+ before do
136
+ stub_post('/statuses/share.json').with(
137
+ body: { id: '1234', status: 'Hello' }
138
+ ).to_return(
139
+ body: fixture(:status),
140
+ headers: { content_type: 'application/json; charset=utf-8' }
141
+ )
142
+ end
143
+
144
+ context 'when text is passed as a string' do
145
+ it 'requests the correct resource' do
146
+ @client.share('1234', 'Hello')
147
+ expect(a_post('/statuses/share.json').with(
148
+ body: { id: '1234', status: 'Hello' }
149
+ )).to have_been_made
150
+ end
151
+ end
152
+
153
+ context 'when text is passed as a value of hash' do
154
+ it 'requests the correct resource' do
155
+ @client.share(status: 'Hello', id: 1234)
156
+ expect(a_post('/statuses/share.json').with(
157
+ body: { id: '1234', status: 'Hello' }
158
+ )).to have_been_made
159
+ end
160
+ end
161
+
162
+ it 'returns a Status object' do
163
+ expect(@client.share(1234, 'Hello')).to be_a Croudia::Status
164
+ end
165
+ end
166
+
167
+ describe '#share_with_media' do
168
+ before do
169
+ stub_post('/statuses/share_with_media.json').to_return(
170
+ body: fixture(:status),
171
+ headers: { content_type: 'application/json; charset=utf-8' }
172
+ )
173
+ end
174
+
175
+ context 'when passing each argument' do
176
+ it 'requests the correct resource' do
177
+ @client.share_with_media(1234, 'Hi', fixture('image.jpg'))
178
+ expect(a_post('/statuses/share_with_media.json')).to have_been_made
179
+ end
180
+ end
181
+
182
+ context 'when passing a Hash' do
183
+ it 'requests the correct resource' do
184
+ @client.share_with_media(id: 1234, status: 'Hi', media: fixture('image.jpg'))
185
+ expect(a_post('/statuses/share_with_media.json')).to have_been_made
186
+ end
187
+ end
188
+
189
+ it 'returns a Croudia::Status' do
190
+ subject = @client.share_with_media(1234, 'Hi', fixture('image.jpg'))
191
+ expect(subject).to be_a Croudia::Status
192
+ end
193
+ end
133
194
  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.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - wktk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-02 00:00:00.000000000 Z
11
+ date: 2014-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  version: '0'
203
203
  requirements: []
204
204
  rubyforge_project:
205
- rubygems_version: 2.2.1
205
+ rubygems_version: 2.2.2
206
206
  signing_key:
207
207
  specification_version: 4
208
208
  summary: Croudia API