mushikago-sdk 0.1.8 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +10 -17
- data/README.md +5 -3
- data/doc/Mushikago.html +7 -20
- data/doc/Mushikago/Auth.html +2 -4
- data/doc/Mushikago/Auth/Signature.html +8 -28
- data/doc/Mushikago/Auth/Signer.html +13 -37
- data/doc/Mushikago/Config.html +6 -16
- data/doc/Mushikago/Http.html +2 -4
- data/doc/Mushikago/Http/Client.html +15 -43
- data/doc/Mushikago/Http/Request.html +48 -124
- data/doc/Mushikago/Http/Response.html +23 -76
- data/doc/Mushikago/Tombo.html +2 -4
- data/doc/Mushikago/Tombo/CaptureRequest.html +11 -29
- data/doc/Mushikago/Tombo/CapturesRequest.html +10 -28
- data/doc/Mushikago/Tombo/Client.html +30 -88
- data/doc/Mushikago/Tombo/DeleteRequest.html +7 -17
- data/doc/Mushikago/Tombo/InfoRequest.html +5 -13
- data/doc/Mushikago/Tombo/Request.html +6 -16
- data/doc/_index.html +1 -1
- data/doc/file.README.html +8 -4
- data/doc/index.html +8 -4
- data/doc/method_list.html +24 -24
- data/doc/top-level-namespace.html +1 -1
- data/lib/mushikago/http/request.rb +16 -1
- data/lib/mushikago/tombo/capture_request.rb +1 -1
- data/lib/mushikago/tombo/delete_request.rb +1 -1
- data/lib/mushikago/version.rb +1 -1
- data/spec/mushikago/auth/signature_spec.rb +2 -2
- data/spec/mushikago/configuration_spec.rb +9 -9
- data/spec/mushikago/http/client_spec.rb +2 -2
- data/spec/mushikago/http/request_spec.rb +8 -8
- data/spec/mushikago/http/response_spec.rb +3 -3
- data/spec/mushikago/tombo/capture_request_spec.rb +11 -11
- data/spec/mushikago/tombo/captures_request_spec.rb +9 -9
- data/spec/mushikago/tombo/client_spec.rb +22 -22
- data/spec/mushikago/tombo/delete_request_spec.rb +4 -4
- data/spec/mushikago/tombo/info_request_spec.rb +3 -3
- data/spec/mushikago/tombo/request_spec.rb +3 -3
- metadata +4 -4
data/doc/_index.html
CHANGED
@@ -269,7 +269,7 @@
|
|
269
269
|
</div>
|
270
270
|
|
271
271
|
<div id="footer">
|
272
|
-
Generated on
|
272
|
+
Generated on Thu Sep 8 10:06:59 2011 by
|
273
273
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
274
274
|
0.7.2 (ruby-1.8.7).
|
275
275
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -63,11 +63,11 @@
|
|
63
63
|
|
64
64
|
<li><strong>Copyright</strong>: 2011</li>
|
65
65
|
|
66
|
-
<li><strong>License</strong>:
|
66
|
+
<li><strong>License</strong>: Apache License, Version 2.0</li>
|
67
67
|
|
68
|
-
<li><strong>Latest Version</strong>: 0.1
|
68
|
+
<li><strong>Latest Version</strong>: 0.2.1</li>
|
69
69
|
|
70
|
-
<li><strong>Release Date</strong>: September
|
70
|
+
<li><strong>Release Date</strong>: September 8th 2011</li>
|
71
71
|
</ul>
|
72
72
|
|
73
73
|
<h2 id='id6'>概要</h2>
|
@@ -168,6 +168,10 @@ $ export MUSHIKAGO_SECRET_KEY=<シークレットキー>
|
|
168
168
|
<h2 id='id10'>変更履歴</h2>
|
169
169
|
|
170
170
|
<ul>
|
171
|
+
<li>
|
172
|
+
<p><strong>Sep.8.11</strong>: 0.2.1 release - ライセンスをApache License, Version 2.0に変更</p>
|
173
|
+
</li>
|
174
|
+
|
171
175
|
<li>
|
172
176
|
<p><strong>Sep.6.11</strong>: 0.1.8 release</p>
|
173
177
|
|
@@ -180,7 +184,7 @@ $ export MUSHIKAGO_SECRET_KEY=<シークレットキー>
|
|
180
184
|
</ul></div></div>
|
181
185
|
|
182
186
|
<div id="footer">
|
183
|
-
Generated on
|
187
|
+
Generated on Thu Sep 8 10:06:59 2011 by
|
184
188
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
185
189
|
0.7.2 (ruby-1.8.7).
|
186
190
|
</div>
|
data/doc/index.html
CHANGED
@@ -63,11 +63,11 @@
|
|
63
63
|
|
64
64
|
<li><strong>Copyright</strong>: 2011</li>
|
65
65
|
|
66
|
-
<li><strong>License</strong>:
|
66
|
+
<li><strong>License</strong>: Apache License, Version 2.0</li>
|
67
67
|
|
68
|
-
<li><strong>Latest Version</strong>: 0.1
|
68
|
+
<li><strong>Latest Version</strong>: 0.2.1</li>
|
69
69
|
|
70
|
-
<li><strong>Release Date</strong>: September
|
70
|
+
<li><strong>Release Date</strong>: September 8th 2011</li>
|
71
71
|
</ul>
|
72
72
|
|
73
73
|
<h2 id='id1'>概要</h2>
|
@@ -168,6 +168,10 @@ $ export MUSHIKAGO_SECRET_KEY=<シークレットキー>
|
|
168
168
|
<h2 id='id5'>変更履歴</h2>
|
169
169
|
|
170
170
|
<ul>
|
171
|
+
<li>
|
172
|
+
<p><strong>Sep.8.11</strong>: 0.2.1 release - ライセンスをApache License, Version 2.0に変更</p>
|
173
|
+
</li>
|
174
|
+
|
171
175
|
<li>
|
172
176
|
<p><strong>Sep.6.11</strong>: 0.1.8 release</p>
|
173
177
|
|
@@ -180,7 +184,7 @@ $ export MUSHIKAGO_SECRET_KEY=<シークレットキー>
|
|
180
184
|
</ul></div></div>
|
181
185
|
|
182
186
|
<div id="footer">
|
183
|
-
Generated on
|
187
|
+
Generated on Thu Sep 8 10:06:59 2011 by
|
184
188
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
185
189
|
0.7.2 (ruby-1.8.7).
|
186
190
|
</div>
|
data/doc/method_list.html
CHANGED
@@ -145,17 +145,17 @@
|
|
145
145
|
|
146
146
|
|
147
147
|
<li class="r2 ">
|
148
|
-
<span class='object_link'><a href="Mushikago/Tombo/
|
148
|
+
<span class='object_link'><a href="Mushikago/Tombo/CapturesRequest.html#initialize-instance_method" title="Mushikago::Tombo::CapturesRequest#initialize (method)">#initialize</a></span>
|
149
149
|
|
150
|
-
<small>Mushikago::Tombo::
|
150
|
+
<small>Mushikago::Tombo::CapturesRequest</small>
|
151
151
|
|
152
152
|
</li>
|
153
153
|
|
154
154
|
|
155
155
|
<li class="r1 ">
|
156
|
-
<span class='object_link'><a href="Mushikago/Tombo/
|
156
|
+
<span class='object_link'><a href="Mushikago/Tombo/CaptureRequest.html#initialize-instance_method" title="Mushikago::Tombo::CaptureRequest#initialize (method)">#initialize</a></span>
|
157
157
|
|
158
|
-
<small>Mushikago::Tombo::
|
158
|
+
<small>Mushikago::Tombo::CaptureRequest</small>
|
159
159
|
|
160
160
|
</li>
|
161
161
|
|
@@ -169,17 +169,17 @@
|
|
169
169
|
|
170
170
|
|
171
171
|
<li class="r1 ">
|
172
|
-
<span class='object_link'><a href="Mushikago/
|
172
|
+
<span class='object_link'><a href="Mushikago/Tombo/DeleteRequest.html#initialize-instance_method" title="Mushikago::Tombo::DeleteRequest#initialize (method)">#initialize</a></span>
|
173
173
|
|
174
|
-
<small>Mushikago::
|
174
|
+
<small>Mushikago::Tombo::DeleteRequest</small>
|
175
175
|
|
176
176
|
</li>
|
177
177
|
|
178
178
|
|
179
179
|
<li class="r2 ">
|
180
|
-
<span class='object_link'><a href="Mushikago/Tombo/
|
180
|
+
<span class='object_link'><a href="Mushikago/Tombo/InfoRequest.html#initialize-instance_method" title="Mushikago::Tombo::InfoRequest#initialize (method)">#initialize</a></span>
|
181
181
|
|
182
|
-
<small>Mushikago::Tombo::
|
182
|
+
<small>Mushikago::Tombo::InfoRequest</small>
|
183
183
|
|
184
184
|
</li>
|
185
185
|
|
@@ -193,25 +193,25 @@
|
|
193
193
|
|
194
194
|
|
195
195
|
<li class="r2 ">
|
196
|
-
<span class='object_link'><a href="Mushikago/
|
196
|
+
<span class='object_link'><a href="Mushikago/Auth/Signer.html#initialize-instance_method" title="Mushikago::Auth::Signer#initialize (method)">#initialize</a></span>
|
197
197
|
|
198
|
-
<small>Mushikago::
|
198
|
+
<small>Mushikago::Auth::Signer</small>
|
199
199
|
|
200
200
|
</li>
|
201
201
|
|
202
202
|
|
203
203
|
<li class="r1 ">
|
204
|
-
<span class='object_link'><a href="Mushikago/
|
204
|
+
<span class='object_link'><a href="Mushikago/Http/Response.html#initialize-instance_method" title="Mushikago::Http::Response#initialize (method)">#initialize</a></span>
|
205
205
|
|
206
|
-
<small>Mushikago::
|
206
|
+
<small>Mushikago::Http::Response</small>
|
207
207
|
|
208
208
|
</li>
|
209
209
|
|
210
210
|
|
211
211
|
<li class="r2 ">
|
212
|
-
<span class='object_link'><a href="Mushikago/
|
212
|
+
<span class='object_link'><a href="Mushikago/Tombo/Request.html#initialize-instance_method" title="Mushikago::Tombo::Request#initialize (method)">#initialize</a></span>
|
213
213
|
|
214
|
-
<small>Mushikago::
|
214
|
+
<small>Mushikago::Tombo::Request</small>
|
215
215
|
|
216
216
|
</li>
|
217
217
|
|
@@ -241,9 +241,9 @@
|
|
241
241
|
|
242
242
|
|
243
243
|
<li class="r2 ">
|
244
|
-
<span class='object_link'><a href="Mushikago/Tombo/
|
244
|
+
<span class='object_link'><a href="Mushikago/Tombo/InfoRequest.html#method_name-instance_method" title="Mushikago::Tombo::InfoRequest#method_name (method)">#method_name</a></span>
|
245
245
|
|
246
|
-
<small>Mushikago::Tombo::
|
246
|
+
<small>Mushikago::Tombo::InfoRequest</small>
|
247
247
|
|
248
248
|
</li>
|
249
249
|
|
@@ -257,33 +257,33 @@
|
|
257
257
|
|
258
258
|
|
259
259
|
<li class="r2 ">
|
260
|
-
<span class='object_link'><a href="Mushikago/Tombo/
|
260
|
+
<span class='object_link'><a href="Mushikago/Tombo/CaptureRequest.html#method_name-instance_method" title="Mushikago::Tombo::CaptureRequest#method_name (method)">#method_name</a></span>
|
261
261
|
|
262
|
-
<small>Mushikago::Tombo::
|
262
|
+
<small>Mushikago::Tombo::CaptureRequest</small>
|
263
263
|
|
264
264
|
</li>
|
265
265
|
|
266
266
|
|
267
267
|
<li class="r1 ">
|
268
|
-
<span class='object_link'><a href="Mushikago/Tombo/
|
268
|
+
<span class='object_link'><a href="Mushikago/Tombo/CapturesRequest.html#method_name-instance_method" title="Mushikago::Tombo::CapturesRequest#method_name (method)">#method_name</a></span>
|
269
269
|
|
270
|
-
<small>Mushikago::Tombo::
|
270
|
+
<small>Mushikago::Tombo::CapturesRequest</small>
|
271
271
|
|
272
272
|
</li>
|
273
273
|
|
274
274
|
|
275
275
|
<li class="r2 ">
|
276
|
-
<span class='object_link'><a href="Mushikago/Tombo/
|
276
|
+
<span class='object_link'><a href="Mushikago/Tombo/DeleteRequest.html#new_http_request-instance_method" title="Mushikago::Tombo::DeleteRequest#new_http_request (method)">#new_http_request</a></span>
|
277
277
|
|
278
|
-
<small>Mushikago::Tombo::
|
278
|
+
<small>Mushikago::Tombo::DeleteRequest</small>
|
279
279
|
|
280
280
|
</li>
|
281
281
|
|
282
282
|
|
283
283
|
<li class="r1 ">
|
284
|
-
<span class='object_link'><a href="Mushikago/Tombo/
|
284
|
+
<span class='object_link'><a href="Mushikago/Tombo/CaptureRequest.html#new_http_request-instance_method" title="Mushikago::Tombo::CaptureRequest#new_http_request (method)">#new_http_request</a></span>
|
285
285
|
|
286
|
-
<small>Mushikago::Tombo::
|
286
|
+
<small>Mushikago::Tombo::CaptureRequest</small>
|
287
287
|
|
288
288
|
</li>
|
289
289
|
|
@@ -59,7 +59,7 @@ module Mushikago
|
|
59
59
|
# @return [Net::HTTPRequest] HTTPリクエスト
|
60
60
|
protected
|
61
61
|
def new_http_request
|
62
|
-
|
62
|
+
new_http_get_request("#{path}?#{url_encoded_params}")
|
63
63
|
end
|
64
64
|
|
65
65
|
# URLエンコードされた文字列を取得する
|
@@ -71,6 +71,21 @@ module Mushikago
|
|
71
71
|
CGI.escape(s).gsub('+', '%20')
|
72
72
|
end
|
73
73
|
|
74
|
+
private
|
75
|
+
def new_http_get_request(request_path)
|
76
|
+
Net::HTTP::Get.new(request_path)
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
def new_http_post_request(request_path)
|
81
|
+
Net::HTTP::Post.new(request_path)
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
def new_http_delete_request(request_path)
|
86
|
+
Net::HTTP::Delete.new(request_path)
|
87
|
+
end
|
88
|
+
|
74
89
|
class << self
|
75
90
|
# リクエストパラメータへのアクセサを定義する
|
76
91
|
# @param [String] name パラメータ名
|
data/lib/mushikago/version.rb
CHANGED
@@ -23,7 +23,7 @@ describe Mushikago::Auth::Signature do
|
|
23
23
|
before do
|
24
24
|
@request.add_signature!(Mushikago::Auth::Signer.new('secret_key'))
|
25
25
|
end
|
26
|
-
subject{ @request }
|
27
|
-
it{
|
26
|
+
subject{ @request.get_param('signature') }
|
27
|
+
it{ should == 'sJSFFQREYbNPd2kJK3kuAR3uSgvcbuWtxGFjan+R3w8=' }
|
28
28
|
end
|
29
29
|
end
|
@@ -24,9 +24,9 @@ describe Mushikago::Config do
|
|
24
24
|
# Mushikago::Configはデフォルトの値を持っている
|
25
25
|
context 'has default value' do
|
26
26
|
subject{ Mushikago::Config.instance }
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
its(:api_key){ should == (ENV['MUSHIKAGO_API_KEY'] || ENV['MUSHIKAGO_API_KEY_ID']) }
|
28
|
+
its(:secret_key){ should == (ENV['MUSHIKAGO_SECRET_KEY'] || ENV['MUSHIKAGO_SECRET_ACCESS_KEY']) }
|
29
|
+
its(:tombo_endpoint){ should == 'tombo.mushikago.org' }
|
30
30
|
end
|
31
31
|
|
32
32
|
# Mushikago::Configは値をロードすることができる
|
@@ -40,9 +40,9 @@ describe Mushikago::Config do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
subject{ Mushikago::Config.instance }
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
its(:api_key){ should == 'api_key' }
|
44
|
+
its(:secret_key){ should == 'secret_key' }
|
45
|
+
its(:tombo_endpoint){ should == 'tombo.mushikago.org' }
|
46
46
|
|
47
47
|
# ロードする際のキーは文字列でもOK
|
48
48
|
context 'loading options key can be string' do
|
@@ -55,9 +55,9 @@ describe Mushikago::Config do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
subject{ Mushikago::Config.instance }
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
its(:api_key){ should == 'api_key' }
|
59
|
+
its(:secret_key){ should == 'secret_key' }
|
60
|
+
its(:tombo_endpoint){ should == 'tombo.mushikago.org' }
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -13,7 +13,7 @@ describe Mushikago::Http::Client do
|
|
13
13
|
|
14
14
|
subject{ @client }
|
15
15
|
|
16
|
-
|
16
|
+
its(:api_key){ should == Mushikago.config.api_key.to_s }
|
17
17
|
end
|
18
18
|
|
19
19
|
context 'construct with options' do
|
@@ -25,7 +25,7 @@ describe Mushikago::Http::Client do
|
|
25
25
|
|
26
26
|
subject{ @client }
|
27
27
|
|
28
|
-
|
28
|
+
its(:api_key){ should == 'mushikago api key' }
|
29
29
|
end
|
30
30
|
|
31
31
|
context 'send test request' do
|
@@ -28,11 +28,11 @@ describe Mushikago::Http::Request do
|
|
28
28
|
it{ should respond_to(:set_param) }
|
29
29
|
it{ should respond_to(:get_param) }
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
its(:http_method){ should == 'GET' }
|
32
|
+
its(:host){ should == 'tombo.ap-northeast-1.mushikago.org' }
|
33
|
+
its('port.to_i'){ should == 80 }
|
34
|
+
its(:path){ should == '/1/list.json' }
|
35
|
+
its(:headers){ should be_a_kind_of(Hash) }
|
36
36
|
it{ subject.headers['hoge'].should == 'fuga' }
|
37
37
|
it{ subject.get_param('param1').should == 'p1' }
|
38
38
|
it{ subject.get_param('param2').should == 'p2' }
|
@@ -58,9 +58,9 @@ describe Mushikago::Http::Request do
|
|
58
58
|
it{ should respond_to(:sample1, :sample1=) }
|
59
59
|
it{ should respond_to(:sample2, :sample2=) }
|
60
60
|
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
its(:sample1){ should == 'hoge' }
|
62
|
+
its(:sample2){ should == 20 }
|
63
|
+
its(:sample3){ should == 'sample3' }
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -21,9 +21,9 @@ describe Mushikago::Http::Response do
|
|
21
21
|
it{ should respond_to(:[]) }
|
22
22
|
|
23
23
|
it{ subject.meta[:status].should == 200 }
|
24
|
-
|
24
|
+
its(:status){ should == 200 }
|
25
25
|
it{ subject.meta[:message].should == 'OK' }
|
26
|
-
|
26
|
+
its(:message){ should == 'OK' }
|
27
27
|
it{ subject.response[:hello].should == 'world' }
|
28
|
-
|
28
|
+
its([:hello]){ should == 'world' }
|
29
29
|
end
|
@@ -27,16 +27,16 @@ describe Mushikago::Tombo::CaptureRequest do
|
|
27
27
|
|
28
28
|
subject{ @request }
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
30
|
+
its(:host){ should == Mushikago.config.tombo_endpoint }
|
31
|
+
its(:http_method){ should == 'POST' }
|
32
|
+
its(:path){ should == '/1/capture.json' }
|
33
|
+
its(:url){ should == 'http://www.mushikago.org/' }
|
34
|
+
its(:image_format){ should == 'png' }
|
35
|
+
its(:image_quality){ should == '20' }
|
36
|
+
its(:thumbnail){ should == '1' }
|
37
|
+
its(:tags){ should == 'hoge,fuga' }
|
38
38
|
it{ subject.headers['Content-type'].should == 'application/x-www-form-urlencoded; charset=utf-8' }
|
39
|
-
|
39
|
+
its(:url_encoded_params){ should == 'image_format=png&image_quality=20&tags=hoge%2Cfuga&thumbnail=1&url=http%3A%2F%2Fwww.mushikago.org%2F' }
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'tags can be array and thumbnail is false' do
|
@@ -49,7 +49,7 @@ describe Mushikago::Tombo::CaptureRequest do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
subject{ @request }
|
52
|
-
|
53
|
-
|
52
|
+
its(:thumbnail){ should == '0' }
|
53
|
+
its(:tags){ should == 'hoge,fuga' }
|
54
54
|
end
|
55
55
|
end
|
@@ -27,14 +27,14 @@ describe Mushikago::Tombo::CapturesRequest do
|
|
27
27
|
|
28
28
|
subject{ @request }
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
its(:host){ should == Mushikago.config.tombo_endpoint }
|
31
|
+
its(:http_method){ should == 'GET' }
|
32
|
+
its(:path){ should == '/1/captures.json' }
|
33
|
+
its(:id){ should == 'id' }
|
34
|
+
its(:limit){ should == '2' }
|
35
|
+
its(:offset){ should == '5' }
|
36
|
+
its(:domain){ should == 'hogehoge.com' }
|
37
|
+
its(:tag){ should == 'tag' }
|
38
|
+
its(:url_encoded_params){ should == 'domain=hogehoge.com&id=id&limit=2&offset=5&tag=tag' }
|
39
39
|
end
|
40
40
|
end
|