mushikago-sdk 0.3.6 → 0.3.7

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.
Files changed (40) hide show
  1. data/README.md +3 -1
  2. data/lib/mushikago/configuration.rb +1 -0
  3. data/lib/mushikago/http.rb +7 -1
  4. data/lib/mushikago/http/client.rb +5 -1
  5. data/lib/mushikago/http/{multipart_request.rb → multipart.rb} +0 -2
  6. data/lib/mushikago/http/request.rb +6 -7
  7. data/lib/mushikago/http/request/delete.rb +17 -0
  8. data/lib/mushikago/http/request/get.rb +16 -0
  9. data/lib/mushikago/http/request/multipart_post.rb +18 -0
  10. data/lib/mushikago/http/request/multipart_put.rb +19 -0
  11. data/lib/mushikago/http/request/post.rb +17 -0
  12. data/lib/mushikago/http/request/put.rb +18 -0
  13. data/lib/mushikago/mitsubachi.rb +0 -2
  14. data/lib/mushikago/mitsubachi/http_fetch_request.rb +2 -6
  15. data/lib/mushikago/mitsubachi/http_push_request.rb +2 -6
  16. data/lib/mushikago/mitsubachi/project_create_request.rb +2 -6
  17. data/lib/mushikago/mitsubachi/project_delete_request.rb +2 -6
  18. data/lib/mushikago/mitsubachi/project_discontinue_request.rb +2 -6
  19. data/lib/mushikago/mitsubachi/project_info_request.rb +2 -2
  20. data/lib/mushikago/mitsubachi/project_list_request.rb +2 -2
  21. data/lib/mushikago/mitsubachi/project_queues_request.rb +2 -2
  22. data/lib/mushikago/mitsubachi/project_update_request.rb +2 -6
  23. data/lib/mushikago/mitsubachi/resource_delete_request.rb +2 -6
  24. data/lib/mushikago/mitsubachi/resource_get_request.rb +2 -2
  25. data/lib/mushikago/mitsubachi/resource_list_request.rb +2 -2
  26. data/lib/mushikago/mitsubachi/resource_store_request.rb +2 -6
  27. data/lib/mushikago/mitsubachi/script_delete_request.rb +2 -6
  28. data/lib/mushikago/mitsubachi/script_deploy_request.rb +2 -6
  29. data/lib/mushikago/mitsubachi/script_get_request.rb +2 -2
  30. data/lib/mushikago/mitsubachi/script_list_request.rb +2 -2
  31. data/lib/mushikago/tombo.rb +0 -1
  32. data/lib/mushikago/tombo/capture_request.rb +8 -13
  33. data/lib/mushikago/tombo/captures_request.rb +7 -7
  34. data/lib/mushikago/tombo/delete_request.rb +3 -8
  35. data/lib/mushikago/tombo/info_request.rb +2 -2
  36. data/lib/mushikago/version.rb +1 -1
  37. metadata +25 -22
  38. data/lib/mushikago/mitsubachi/multipart_request.rb +0 -33
  39. data/lib/mushikago/mitsubachi/request.rb +0 -32
  40. data/lib/mushikago/tombo/request.rb +0 -32
data/README.md CHANGED
@@ -5,7 +5,7 @@ Mushikago SDK for Ruby.
5
5
  - **Author**: Toru Matsuoka
6
6
  - **Copyright**: 2011
7
7
  - **License**: Apache License, Version 2.0
8
- - **Latest Version**: 0.3.6
8
+ - **Latest Version**: 0.3.7
9
9
  - **Release Date**: January 27th 2012
10
10
 
11
11
 
@@ -151,6 +151,8 @@ $ export MUSHIKAGO_SECRET_KEY=<シークレットキー>
151
151
  変更履歴
152
152
  --------
153
153
 
154
+ - **Feb.14.12**: 0.3.7 release
155
+ - Multipartでアップロードするファイルの最後に改行が付与される件修正
154
156
  - **Jan.27.12**: 0.3.6 release
155
157
  - resource_get,script_getに:with_bodyオプション追加
156
158
  - **Jan.27.12**: 0.3.4 release
@@ -40,6 +40,7 @@ module Mushikago
40
40
  add_option :api_key, ENV['MUSHIKAGO_API_KEY'] || ENV['MUSHIKAGO_API_KEY_ID']
41
41
  add_option :secret_key, ENV['MUSHIKAGO_SECRET_KEY'] || ENV['MUSHIKAGO_SECRET_ACCESS_KEY']
42
42
  add_option :endpoint, 'api.mushikago.org'
43
+ add_option :use_ssl, true
43
44
 
44
45
  # @private
45
46
  private
@@ -4,8 +4,14 @@ module Mushikago
4
4
  module Http
5
5
  autoload :Client, 'mushikago/http/client'
6
6
  autoload :Request, 'mushikago/http/request'
7
- autoload :MultipartRequest, 'mushikago/http/multipart_request'
7
+ autoload :MultipartRequest, 'mushikago/http/multipart'
8
8
  autoload :Response, 'mushikago/http/response'
9
+ autoload :GetRequest, 'mushikago/http/request/get'
10
+ autoload :PostRequest, 'mushikago/http/request/post'
11
+ autoload :PutRequest, 'mushikago/http/request/put'
12
+ autoload :DeleteRequest, 'mushikago/http/request/delete'
13
+ autoload :MultipartPostRequest, 'mushikago/http/request/multipart_post'
14
+ autoload :MultipartPutRequest, 'mushikago/http/request/multipart_put'
9
15
  end
10
16
  end
11
17
 
@@ -11,12 +11,16 @@ module Mushikago
11
11
  # @return [Signer] signer
12
12
  attr_reader :signer
13
13
 
14
+ # @return [Boolean] use_ssl
15
+ attr_reader :use_ssl
16
+
14
17
  # @param [Hash] options
15
18
  # @option options [String] :api_key(Configured value) APIキー
16
19
  # @option options [String] :secret_key(Configured value) 秘密鍵
17
20
  def initialize options={}
18
21
  @api_key = (options[:api_key] || Mushikago.config.api_key).to_s
19
22
  @signer = Mushikago::Auth::Signer.new((options[:secret_key] || Mushikago.config.secret_key).to_s)
23
+ @use_ssl = options.has_key?(:use_ssl) ? options[:use_ssl] : Mushikago.config.use_ssl
20
24
  end
21
25
 
22
26
  # @param [Mushikago::Http::Request] request
@@ -28,7 +32,7 @@ module Mushikago
28
32
  request.add_signature!(signer)
29
33
 
30
34
  # send request
31
- Net::HTTP.start(request.host, request.port) do |http|
35
+ Net::HTTP.start(request.host, request.port, :use_ssl => use_ssl) do |http|
32
36
  http_request = request.to_http_request
33
37
  http_response = http.request(http_request)
34
38
  return Mushikago::Http::Response.new(JSON.parse(http_response.body))
@@ -49,9 +49,7 @@ module Mushikago
49
49
  %Q||,
50
50
  %Q|#{v.read}|
51
51
  ].join(EOL)
52
- content << EOL
53
52
  end
54
- content << EOL
55
53
  content << %Q|--#{boundary}--|
56
54
  content << EOL
57
55
  return content
@@ -7,8 +7,6 @@ module Mushikago
7
7
  class Request
8
8
  # @return [Hash] headers
9
9
  attr_reader :headers
10
- # @return [String] http_method
11
- attr_accessor :http_method
12
10
  # @return [String] host
13
11
  attr_accessor :host
14
12
  # @return [Integer] port
@@ -18,13 +16,14 @@ module Mushikago
18
16
  # @return [String] params
19
17
  attr_reader :params
20
18
 
21
- def initialize
19
+ def initialize options={}
22
20
  @headers = {}
23
- @host = ''
24
- @port = 80
21
+ endpoint = options[:endpoint] || Mushikago.config.endpoint
22
+ host, port = endpoint.split(':')
23
+ @host = host
24
+ @port = port
25
25
  @path = '/'
26
- @params = {}
27
- @http_method = new_http_request.method
26
+ @params = {}
28
27
  end
29
28
 
30
29
  # @param [String] key パラメータのキー
@@ -0,0 +1,17 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Mushikago
3
+ module Http
4
+ # MushikagoのDELETEリクエストを表す抽象クラス
5
+ class DeleteRequest < Mushikago::Http::Request
6
+ def http_method; 'DELETE' end
7
+ include Mushikago::Auth::Signature
8
+
9
+ protected
10
+ def new_http_request
11
+ new_http_delete_request("#{path}?#{url_encoded_params}")
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Mushikago
3
+ module Http
4
+ # MushikagoのGETリクエストを表す抽象クラス
5
+ class GetRequest < Mushikago::Http::Request
6
+ def http_method; 'GET' end
7
+ include Mushikago::Auth::Signature
8
+
9
+ protected
10
+ def new_http_request
11
+ new_http_get_request("#{path}?#{url_encoded_params}")
12
+ end
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Mushikago
3
+ module Http
4
+ # MushikagoのPOSTリクエストを表す抽象クラス
5
+ class MultipartPostRequest < Mushikago::Http::MultipartRequest
6
+ def http_method; 'POST' end
7
+ include Mushikago::Auth::Signature
8
+
9
+ protected
10
+ def new_http_request
11
+ new_http_post_request(path)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+
18
+
@@ -0,0 +1,19 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Mushikago
3
+ module Http
4
+ # MushikagoのPUTリクエストを表す抽象クラス
5
+ class MultipartPutRequest < Mushikago::Http::MultipartRequest
6
+ def http_method; 'PUT' end
7
+ include Mushikago::Auth::Signature
8
+
9
+ protected
10
+ def new_http_request
11
+ new_http_put_request(path)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+
18
+
19
+
@@ -0,0 +1,17 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Mushikago
3
+ module Http
4
+ # MushikagoのPOSTリクエストを表す抽象クラス
5
+ class PostRequest < Mushikago::Http::Request
6
+ def http_method; 'POST' end
7
+ include Mushikago::Auth::Signature
8
+
9
+ protected
10
+ def new_http_request
11
+ new_http_post_request(path)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+
@@ -0,0 +1,18 @@
1
+ # -*- coding: utf-8 -*-
2
+ module Mushikago
3
+ module Http
4
+ # MushikagoのPUTリクエストを表す抽象クラス
5
+ class PutRequest < Mushikago::Http::Request
6
+ def http_method; 'PUT' end
7
+ include Mushikago::Auth::Signature
8
+
9
+ protected
10
+ def new_http_request
11
+ new_http_put_request(path)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+
18
+
@@ -3,8 +3,6 @@ module Mushikago
3
3
  # mitsubachiにアクセスするためのモジュール
4
4
  module Mitsubachi
5
5
  autoload :Client, 'mushikago/mitsubachi/client'
6
- autoload :Request, 'mushikago/mitsubachi/request'
7
- autoload :MultipartRequest, 'mushikago/mitsubachi/multipart_request'
8
6
 
9
7
  # project
10
8
  autoload :ProjectCreateRequest, 'mushikago/mitsubachi/project_create_request'
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class HttpFetchRequest < Request
5
- def method_name; 'http/fetch.json' end
4
+ class HttpFetchRequest < Mushikago::Http::PostRequest
5
+ def path; '/1/mitsubachi/http/fetch.json' end
6
6
  request_parameter :url
7
7
  request_parameter :project_name
8
8
  request_parameter :script_name
@@ -23,10 +23,6 @@ module Mushikago
23
23
  self.parameters = options[:parameters] if options.has_key?(:parameters)
24
24
  self.header_overwrite = options[:header_overwrite] if options.has_key?(:header_overwrite)
25
25
  end
26
-
27
- def new_http_request
28
- new_http_post_request(path)
29
- end
30
26
  end
31
27
  end
32
28
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class HttpPushRequest < Request
5
- def method_name; 'http/fetch.json' end
4
+ class HttpPushRequest < Mushikago::Http::PostRequest
5
+ def path; '/1/mitsubachi/http/fetch.json' end
6
6
  request_parameter :url
7
7
  request_parameter :project_name
8
8
  request_parameter :script_name
@@ -25,10 +25,6 @@ module Mushikago
25
25
  self.header_overwrite = options[:header_overwrite] if options.has_key?(:header_overwrite)
26
26
  self.mime_type = options[:mime_type] if options.has_key?(:mime_type)
27
27
  end
28
-
29
- def new_http_request
30
- new_http_post_request(path)
31
- end
32
28
  end
33
29
  end
34
30
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ProjectCreateRequest < Request
5
- def method_name; 'project/create' end
4
+ class ProjectCreateRequest < Mushikago::Http::PostRequest
5
+ def path; '/1/mitsubachi/project/create' end
6
6
  request_parameter :project_name
7
7
  request_parameter :dedicated, :default=>false do |v| (v ? 1 : 0).to_s end
8
8
  request_parameter :max_lead_time do |v| v.to_i.to_s end
@@ -21,10 +21,6 @@ module Mushikago
21
21
  self.system_log = options[:system_log]
22
22
  self.log_prefix = options[:log_prefix] if options.has_key?(:log_prefix)
23
23
  end
24
-
25
- def new_http_request
26
- new_http_post_request(path)
27
- end
28
24
  end
29
25
  end
30
26
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ProjectDeleteRequest < Request
5
- def method_name; 'project/delete' end
4
+ class ProjectDeleteRequest < Mushikago::Http::DeleteRequest
5
+ def path; '/1/mitsubachi/project/delete' end
6
6
  request_parameter :project_name
7
7
  request_parameter :forcedelete, :default=>true do |v| (v ? 1 : 0).to_s end
8
8
 
@@ -11,10 +11,6 @@ module Mushikago
11
11
  self.project_name = project_name
12
12
  self.forcedelete = options[:forcedelete]
13
13
  end
14
-
15
- def new_http_request
16
- new_http_delete_request("#{path}?#{url_encoded_params}")
17
- end
18
14
  end
19
15
  end
20
16
  end
@@ -1,18 +1,14 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ProjectDiscontinueRequest < Request
5
- def method_name; 'project/discontinue' end
4
+ class ProjectDiscontinueRequest < Mushikago::Http::PostRequest
5
+ def path; '/1/mitsubachi/project/discontinue' end
6
6
  request_parameter :project_name
7
7
 
8
8
  def initialize project_name, options={}
9
9
  super(options)
10
10
  self.project_name = project_name
11
11
  end
12
-
13
- def new_http_request
14
- new_http_post_request(path)
15
- end
16
12
  end
17
13
  end
18
14
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ProjectInfoRequest < Request
5
- def method_name; 'project/info' end
4
+ class ProjectInfoRequest < Mushikago::Http::GetRequest
5
+ def path; '/1/mitsubachi/project/info' end
6
6
  request_parameter :project_name
7
7
  request_parameter :time do |v| v.to_i.to_s end
8
8
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ProjectListRequest < Request
5
- def method_name; 'project/list' end
4
+ class ProjectListRequest < Mushikago::Http::GetRequest
5
+ def path; '/1/mitsubachi/project/list' end
6
6
  request_parameter :limit do |v| v.to_i.to_s end
7
7
  request_parameter :offset do |v| v.to_i.to_s end
8
8
  request_parameter :filter
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ProjectQueuesRequest < Request
5
- def method_name; 'project/queues' end
4
+ class ProjectQueuesRequest < Mushikago::Http::GetRequest
5
+ def path; '/1/mitsubachi/project/queues' end
6
6
  request_parameter :project_name
7
7
 
8
8
  def initialize project_name, options={}
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ProjectUpdateRequest < Request
5
- def method_name; 'project/update' end
4
+ class ProjectUpdateRequest < Mushikago::Http::PostRequest
5
+ def path; '/1/mitsubachi/project/update' end
6
6
  request_parameter :project_name
7
7
  request_parameter :max_lead_time do |v| v.to_i.to_s end
8
8
  request_parameter :stdout do |v| (v ? 1 : 0).to_s end
@@ -19,10 +19,6 @@ module Mushikago
19
19
  self.system_log = options[:system_log] if options.has_key?(:system_log)
20
20
  self.log_prefix = options[:log_prefix] if options.has_key?(:log_prefix)
21
21
  end
22
-
23
- def new_http_request
24
- new_http_post_request(path)
25
- end
26
22
  end
27
23
  end
28
24
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ResourceDeleteRequest < Request
5
- def method_name; 'resource/delete' end
4
+ class ResourceDeleteRequest < Mushikago::Http::DeleteRequest
5
+ def path; '/1/mitsubachi/resource/delete' end
6
6
  request_parameter :project_name
7
7
  request_parameter :file_name
8
8
 
@@ -11,10 +11,6 @@ module Mushikago
11
11
  self.project_name = project_name
12
12
  self.file_name = file_name
13
13
  end
14
-
15
- def new_http_request
16
- new_http_delete_request("#{path}?#{url_encoded_params}")
17
- end
18
14
  end
19
15
  end
20
16
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ResourceGetRequest < Request
5
- def method_name; 'resource/get' end
4
+ class ResourceGetRequest < Mushikago::Http::GetRequest
5
+ def path; '/1/mitsubachi/resource/get' end
6
6
  request_parameter :project_name
7
7
  request_parameter :file_name
8
8
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ResourceListRequest < Request
5
- def method_name; 'resource/list' end
4
+ class ResourceListRequest < Mushikago::Http::GetRequest
5
+ def path; '/1/mitsubachi/resource/list' end
6
6
  request_parameter :project_name
7
7
  request_parameter :limit do |v| v.to_i.to_s end
8
8
  request_parameter :offset do |v| v.to_i.to_s end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ResourceStoreRequest < MultipartRequest
5
- def method_name; 'resource/store' end
4
+ class ResourceStoreRequest < Mushikago::Http::MultipartPostRequest
5
+ def path; '/1/mitsubachi/resource/store' end
6
6
  request_parameter :project_name
7
7
  request_parameter :file
8
8
  request_parameter :file_name
@@ -21,10 +21,6 @@ module Mushikago
21
21
  self.content_type = options[:content_type] || MIME::Types.of(file.path).first.to_s
22
22
  self.public = options[:public]
23
23
  end
24
-
25
- def new_http_request
26
- new_http_post_request(path)
27
- end
28
24
  end
29
25
  end
30
26
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ScriptDeleteRequest < Request
5
- def method_name; 'script/delete' end
4
+ class ScriptDeleteRequest < Mushikago::Http::DeleteRequest
5
+ def path; '/1/mitsubachi/script/delete' end
6
6
  request_parameter :project_name
7
7
  request_parameter :script_name
8
8
 
@@ -11,10 +11,6 @@ module Mushikago
11
11
  self.project_name = project_name
12
12
  self.script_name = script_name
13
13
  end
14
-
15
- def new_http_request
16
- new_http_delete_request("#{path}?#{url_encoded_params}")
17
- end
18
14
  end
19
15
  end
20
16
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ScriptDeployRequest < MultipartRequest
5
- def method_name; 'script/deploy' end
4
+ class ScriptDeployRequest < Mushikago::Http::MultipartPostRequest
5
+ def path; '/1/mitsubachi/script/deploy' end
6
6
  request_parameter :project_name
7
7
  request_parameter :file
8
8
  request_parameter :script_name
@@ -17,10 +17,6 @@ module Mushikago
17
17
  end
18
18
  self.script_name = options[:script_name] || file.path
19
19
  end
20
-
21
- def new_http_request
22
- new_http_post_request(path)
23
- end
24
20
  end
25
21
  end
26
22
  end
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ScriptGetRequest < Request
5
- def method_name; 'script/get' end
4
+ class ScriptGetRequest < Mushikago::Http::GetRequest
5
+ def path; '/1/mitsubachi/script/get' end
6
6
  request_parameter :project_name
7
7
  request_parameter :script_name
8
8
 
@@ -1,8 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  module Mitsubachi
4
- class ScriptListRequest < Request
5
- def method_name; 'script/list' end
4
+ class ScriptListRequest < Mushikago::Http::GetRequest
5
+ def path; '/1/mitsubachi/script/list' end
6
6
  request_parameter :project_name
7
7
  request_parameter :limit do |v| v.to_i.to_s end
8
8
  request_parameter :offset do |v| v.to_i.to_s end
@@ -3,7 +3,6 @@ module Mushikago
3
3
  # Tomboへのアクセスを行うモジュール
4
4
  module Tombo
5
5
  autoload :Client, 'mushikago/tombo/client'
6
- autoload :Request, 'mushikago/tombo/request'
7
6
  autoload :CaptureRequest, 'mushikago/tombo/capture_request'
8
7
  autoload :CapturesRequest, 'mushikago/tombo/captures_request'
9
8
  autoload :DeleteRequest, 'mushikago/tombo/delete_request'
@@ -2,15 +2,15 @@
2
2
  module Mushikago
3
3
  module Tombo
4
4
  # キャプチャリクエスト
5
- class CaptureRequest < Request
6
- def method_name; 'capture' end
5
+ class CaptureRequest < Mushikago::Http::PostRequest
6
+ def path; '/1/tombo/capture' end
7
7
 
8
- add_param :url
9
- add_param :image_format
10
- add_param :image_quality do |v| v.to_i.to_s end
11
- add_param :thumbnail do |v| (v ? 1 : 0).to_s end
12
- add_param :tags do |v| [v].flatten.compact.join(',') end
13
- add_param :useragent
8
+ request_parameter :url
9
+ request_parameter :image_format
10
+ request_parameter :image_quality do |v| v.to_i.to_s end
11
+ request_parameter :thumbnail do |v| (v ? 1 : 0).to_s end
12
+ request_parameter :tags do |v| [v].flatten.compact.join(',') end
13
+ request_parameter :useragent
14
14
 
15
15
  # @param [String] url キャプチャ対象のURL
16
16
  # @param [Hash] options リクエストのオプション
@@ -29,11 +29,6 @@ module Mushikago
29
29
  self.useragent = options[:useragent] if options.has_key?(:useragent)
30
30
  @headers['Content-type'] = 'application/x-www-form-urlencoded; charset=utf-8'
31
31
  end
32
-
33
- # @private
34
- def new_http_request
35
- new_http_post_request(path)
36
- end
37
32
  end
38
33
  end
39
34
  end
@@ -2,14 +2,14 @@
2
2
  module Mushikago
3
3
  module Tombo
4
4
  # キャプチャ一覧取得リクエスト
5
- class CapturesRequest < Request
6
- def method_name; 'captures' end
5
+ class CapturesRequest < Mushikago::Http::GetRequest
6
+ def path; '/1/tombo/captures' end
7
7
 
8
- add_param :id
9
- add_param :limit
10
- add_param :offset
11
- add_param :domain
12
- add_param :tag
8
+ request_parameter :id
9
+ request_parameter :limit
10
+ request_parameter :offset
11
+ request_parameter :domain
12
+ request_parameter :tag
13
13
 
14
14
  # @param [Hash] options リクエストのオプション
15
15
  # @option options [String] :id 画像のID
@@ -2,10 +2,10 @@
2
2
  module Mushikago
3
3
  module Tombo
4
4
  # Deleteリクエスト
5
- class DeleteRequest < Request
6
- def method_name; 'delete' end
5
+ class DeleteRequest < Mushikago::Http::DeleteRequest
6
+ def path; '/1/tombo/delete' end
7
7
 
8
- add_param :id
8
+ request_parameter :id
9
9
 
10
10
  # @param [String] id 画像のID
11
11
  # @param [Hash] options リクエストのオプション
@@ -13,11 +13,6 @@ module Mushikago
13
13
  super(options)
14
14
  self.id = id
15
15
  end
16
-
17
- # @private
18
- def new_http_request
19
- new_http_delete_request("#{path}?#{url_encoded_params}")
20
- end
21
16
  end
22
17
  end
23
18
  end
@@ -2,8 +2,8 @@
2
2
  module Mushikago
3
3
  module Tombo
4
4
  # API使用状況取得リクエスト
5
- class InfoRequest < Request
6
- def method_name; 'info' end
5
+ class InfoRequest < Mushikago::Http::GetRequest
6
+ def path; '/1/tombo/info' end
7
7
 
8
8
  # @param [Hash] options リクエストのオプション
9
9
  def initialize options={}
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Mushikago
3
3
  # Mushikago SDK for Ruby のバージョン
4
- VERSION = '0.3.6'
4
+ VERSION = '0.3.7'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mushikago-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-01 00:00:00.000000000Z
12
+ date: 2012-02-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &7374660 !ruby/object:Gem::Requirement
16
+ requirement: &5026580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *7374660
24
+ version_requirements: *5026580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mime-types
27
- requirement: &7373800 !ruby/object:Gem::Requirement
27
+ requirement: &5025320 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *7373800
35
+ version_requirements: *5025320
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &7373040 !ruby/object:Gem::Requirement
38
+ requirement: &5023960 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *7373040
46
+ version_requirements: *5023960
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: maruku
49
- requirement: &7372080 !ruby/object:Gem::Requirement
49
+ requirement: &5020940 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *7372080
57
+ version_requirements: *5020940
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yard
60
- requirement: &7371440 !ruby/object:Gem::Requirement
60
+ requirement: &5020020 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *7371440
68
+ version_requirements: *5020020
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &7370820 !ruby/object:Gem::Requirement
71
+ requirement: &5017980 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 2.6.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *7370820
79
+ version_requirements: *5017980
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: ZenTest
82
- requirement: &7370380 !ruby/object:Gem::Requirement
82
+ requirement: &5016460 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *7370380
90
+ version_requirements: *5016460
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: bundler
93
- requirement: &7367220 !ruby/object:Gem::Requirement
93
+ requirement: &5015400 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *7367220
101
+ version_requirements: *5015400
102
102
  description: A SDK for Mushikago Web Service.
103
103
  email:
104
104
  - t.matsuoka@miningbrownie.co.jp
@@ -114,7 +114,6 @@ files:
114
114
  - lib/mushikago/hotaru/client.rb
115
115
  - lib/mushikago/auth/signer.rb
116
116
  - lib/mushikago/auth/signature.rb
117
- - lib/mushikago/tombo/request.rb
118
117
  - lib/mushikago/tombo/info_request.rb
119
118
  - lib/mushikago/tombo/capture_request.rb
120
119
  - lib/mushikago/tombo/captures_request.rb
@@ -125,7 +124,6 @@ files:
125
124
  - lib/mushikago/mitsubachi/resource_delete_request.rb
126
125
  - lib/mushikago/mitsubachi/http_fetch_request.rb
127
126
  - lib/mushikago/mitsubachi/resource.rb
128
- - lib/mushikago/mitsubachi/multipart_request.rb
129
127
  - lib/mushikago/mitsubachi/script_delete_request.rb
130
128
  - lib/mushikago/mitsubachi/http_push_request.rb
131
129
  - lib/mushikago/mitsubachi/resource_get_request.rb
@@ -134,7 +132,6 @@ files:
134
132
  - lib/mushikago/mitsubachi/scripts.rb
135
133
  - lib/mushikago/mitsubachi/project_update_request.rb
136
134
  - lib/mushikago/mitsubachi/resources.rb
137
- - lib/mushikago/mitsubachi/request.rb
138
135
  - lib/mushikago/mitsubachi/projects.rb
139
136
  - lib/mushikago/mitsubachi/resource_list_request.rb
140
137
  - lib/mushikago/mitsubachi/project.rb
@@ -150,8 +147,14 @@ files:
150
147
  - lib/mushikago/version.rb
151
148
  - lib/mushikago/auth.rb
152
149
  - lib/mushikago/configuration.rb
153
- - lib/mushikago/http/multipart_request.rb
150
+ - lib/mushikago/http/multipart.rb
154
151
  - lib/mushikago/http/request.rb
152
+ - lib/mushikago/http/request/post.rb
153
+ - lib/mushikago/http/request/multipart_put.rb
154
+ - lib/mushikago/http/request/put.rb
155
+ - lib/mushikago/http/request/delete.rb
156
+ - lib/mushikago/http/request/get.rb
157
+ - lib/mushikago/http/request/multipart_post.rb
155
158
  - lib/mushikago/http/response.rb
156
159
  - lib/mushikago/http/client.rb
157
160
  - lib/mushikago/http.rb
@@ -1,33 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- module Mushikago
3
- module Mitsubachi
4
- # Mitsubachiのリクエストを表す抽象クラス
5
- class MultipartRequest < Mushikago::Http::MultipartRequest
6
- include Mushikago::Auth::Signature
7
-
8
- # @param [Hash] options オプション
9
- # @option options [String] :endpoint('tombo.mushikago.org') Mitsubachiのエンドポイント
10
- def initialize options={}
11
- super()
12
- endpoint = options[:endpoint] || Mushikago.config.endpoint
13
- host, port = endpoint.split(':')
14
- @host = host
15
- @port = port if port
16
- @path = "/#{api_version}/mitsubachi/#{method_name}"
17
- end
18
-
19
- # @private
20
- private
21
- def api_version
22
- 1
23
- end
24
-
25
- # @private
26
- private
27
- def method_name
28
- ''
29
- end
30
- end
31
- end
32
- end
33
-
@@ -1,32 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- module Mushikago
3
- module Mitsubachi
4
- # Mitsubachiのリクエストを表す抽象クラス
5
- class Request < Mushikago::Http::Request
6
- include Mushikago::Auth::Signature
7
-
8
- # @param [Hash] options オプション
9
- # @option options [String] :endpoint('api.mushikago.org') Mitsubachiのエンドポイント
10
- def initialize options={}
11
- super()
12
- endpoint = options[:endpoint] || Mushikago.config.endpoint
13
- host, port = endpoint.split(':')
14
- @host = host
15
- @port = port if port
16
- @path = "/#{api_version}/mitsubachi/#{method_name}"
17
- end
18
-
19
- # @private
20
- private
21
- def api_version
22
- 1
23
- end
24
-
25
- # @private
26
- private
27
- def method_name
28
- ''
29
- end
30
- end
31
- end
32
- end
@@ -1,32 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- module Mushikago
3
- module Tombo
4
- # Tomboのリクエストを表す抽象クラス
5
- class Request < Mushikago::Http::Request
6
- include Mushikago::Auth::Signature
7
-
8
- # @param [Hash] options オプション
9
- # @option options [String] :endpoint('tombo.mushikago.org') Tomboのエンドポイント
10
- def initialize options={}
11
- super()
12
- endpoint = options[:endpoint] || Mushikago.config.endpoint
13
- host, port = endpoint.split(':')
14
- @host = host
15
- @port = port if port
16
- @path = "/#{api_version}/tombo/#{method_name}"
17
- end
18
-
19
- # @private
20
- private
21
- def api_version
22
- 1
23
- end
24
-
25
- # @private
26
- private
27
- def method_name
28
- ''
29
- end
30
- end
31
- end
32
- end