midwife-client 0.0.6 → 0.0.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.
@@ -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
- response = Net::HTTP.start(uri.host, uri.port) { |http|
25
- http.request(request)
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)
@@ -1,5 +1,5 @@
1
1
  module Midwife
2
2
  class Client
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
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: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
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-25 00:00:00 -04:00
18
+ date: 2011-05-31 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency