midwife-client 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/midwife/client.rb +10 -3
- data/lib/midwife/client/version.rb +1 -1
- data/spec/client_spec.rb +1 -1
- metadata +4 -4
data/lib/midwife/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "net/http"
|
2
|
+
require "net/https"
|
2
3
|
require "uri"
|
3
4
|
require "json"
|
4
5
|
|
@@ -7,6 +8,7 @@ module Midwife
|
|
7
8
|
attr_reader :response
|
8
9
|
|
9
10
|
def initialize(response)
|
11
|
+
super(response.body)
|
10
12
|
@response = response
|
11
13
|
end
|
12
14
|
end
|
@@ -21,9 +23,14 @@ module Midwife
|
|
21
23
|
request["content-type"] = "application/json"
|
22
24
|
request.body = attributes.to_json
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
26
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
27
|
+
|
28
|
+
if (uri.port == 443) # ssl?
|
29
|
+
http.use_ssl = true
|
30
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
31
|
+
end
|
32
|
+
|
33
|
+
response = http.request(request)
|
27
34
|
|
28
35
|
if response.code =~ /2../
|
29
36
|
JSON.parse(response.body)
|
data/spec/client_spec.rb
CHANGED
@@ -141,7 +141,7 @@ describe Midwife::Client do
|
|
141
141
|
|
142
142
|
context 'when processing a non-success response' do
|
143
143
|
let(:client) { Midwife::Client.new }
|
144
|
-
let(:response) { double(:code => '404') }
|
144
|
+
let(:response) { double(:code => '404', :body => 'error') }
|
145
145
|
|
146
146
|
|
147
147
|
before do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midwife-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 7
|
10
|
+
version: 0.0.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Guterl
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05-
|
18
|
+
date: 2011-05-31 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|