mushikago-sdk 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,7 +25,7 @@ module Mushikago
25
25
  request.add_signature!(signer)
26
26
 
27
27
  # send request
28
- Net::HTTP.start(request.host) do |http|
28
+ Net::HTTP.start(request.host, request.port) do |http|
29
29
  http_request = request.to_http_request
30
30
  http_response = http.request(http_request)
31
31
  return Mushikago::Http::Response.new(JSON.parse(http_response.body))
@@ -9,6 +9,8 @@ module Mushikago
9
9
  attr_accessor :http_method
10
10
  # @return [String] host
11
11
  attr_accessor :host
12
+ # @return [Integer] port
13
+ attr_accessor :port
12
14
  # @return [String] path
13
15
  attr_accessor :path
14
16
  # @return [String] params
@@ -17,6 +19,7 @@ module Mushikago
17
19
  def initialize
18
20
  @headers = {}
19
21
  @host = ''
22
+ @port = 80
20
23
  @path = '/'
21
24
  @params = {}
22
25
  @http_method = new_http_request.method
@@ -14,7 +14,6 @@ module Mushikago
14
14
  self.offset = options[:offset] if options.has_key?(:offset)
15
15
  self.domain = options[:domain] if options.has_key?(:domain)
16
16
  self.tag = options[:tag] if options.has_key?(:tag)
17
- @host = options[:endpoint] ||= Mushikago.config.tombo_endpoint
18
17
  @path = "/#{api_version}/captures.json"
19
18
  end
20
19
  end
@@ -5,7 +5,10 @@ module Mushikago
5
5
 
6
6
  def initialize options={}
7
7
  super()
8
- @host = options[:endpoint] ||= Mushikago.config.tombo_endpoint
8
+ endpoint = options[:endpoint] || Mushikago.config.tombo_endpoint
9
+ host, port = endpoint.split(':')
10
+ self.host = host
11
+ self.port = port if port
9
12
  end
10
13
 
11
14
  def api_version
@@ -1,3 +1,3 @@
1
1
  module Mushikago
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -15,6 +15,7 @@ describe Mushikago::Http::Request do
15
15
 
16
16
  it{ should respond_to(:http_method) }
17
17
  it{ should respond_to(:host, :host=) }
18
+ it{ should respond_to(:port, :port=) }
18
19
  it{ should respond_to(:path, :path=) }
19
20
  it{ should respond_to(:headers) }
20
21
  it{ should respond_to(:params) }
@@ -23,6 +24,7 @@ describe Mushikago::Http::Request do
23
24
 
24
25
  it{ subject.http_method.should == 'GET' }
25
26
  it{ subject.host.should == 'tombo.ap-northeast-1.mushikago.org' }
27
+ it{ subject.port.to_i.should == 80 }
26
28
  it{ subject.path.should == '/1/list.json' }
27
29
  it{ subject.headers.should be_a_kind_of(Hash) }
28
30
  it{ subject.headers['hoge'].should == 'fuga' }
@@ -14,7 +14,7 @@ describe Mushikago::Tombo::Client do
14
14
  it{ should respond_to(:captures) }
15
15
  it{ should respond_to(:delete) }
16
16
  it{ should respond_to(:info) }
17
- =begin
17
+
18
18
  context 'send capture request' do
19
19
  before :all do
20
20
  @response = @client.capture('http://www.tombo.ne.jp/', :thumbnail=>1)
@@ -29,7 +29,6 @@ describe Mushikago::Tombo::Client do
29
29
  it{ subject['image_url'].should_not be_nil }
30
30
  it{ subject['thumbnail_url'].should_not be_nil }
31
31
  end
32
- =end
33
32
 
34
33
  context 'send captures request' do
35
34
  before :all do
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mushikago::Tombo::Request do
4
+ before :all do
5
+ @request = Mushikago::Tombo::Request.new
6
+ end
7
+
8
+ subject{ @request }
9
+
10
+ it{ should respond_to(:api_version) }
11
+ it{ subject.api_version.should == 1 }
12
+ it{ subject.host.should == Mushikago.config.tombo_endpoint }
13
+
14
+ context 'construct with options' do
15
+ before :all do
16
+ @request = Mushikago::Tombo::Request.new(:endpoint => 'localhost:18080')
17
+ end
18
+
19
+ subject{ @request }
20
+
21
+ it{ subject.host.should == 'localhost' }
22
+ it{ subject.port.to_i.should == 18080 }
23
+ end
24
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mushikago-sdk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Toru Matsuoka
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-05 00:00:00 Z
18
+ date: 2011-09-06 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: json
@@ -150,6 +150,7 @@ files:
150
150
  - spec/mushikago/auth/signer_spec.rb
151
151
  - spec/mushikago/auth/signature_spec.rb
152
152
  - spec/mushikago/tombo/client_spec.rb
153
+ - spec/mushikago/tombo/request_spec.rb
153
154
  - spec/mushikago/tombo/delete_request_spec.rb
154
155
  - spec/mushikago/tombo/captures_request_spec.rb
155
156
  - spec/mushikago/tombo/info_request_spec.rb
@@ -196,6 +197,7 @@ test_files:
196
197
  - spec/mushikago/auth/signer_spec.rb
197
198
  - spec/mushikago/auth/signature_spec.rb
198
199
  - spec/mushikago/tombo/client_spec.rb
200
+ - spec/mushikago/tombo/request_spec.rb
199
201
  - spec/mushikago/tombo/delete_request_spec.rb
200
202
  - spec/mushikago/tombo/captures_request_spec.rb
201
203
  - spec/mushikago/tombo/info_request_spec.rb