lumberg 3.0.0 → 3.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62bbbbeac1e7b971a4d258310f24dc22e5d4bca2
4
- data.tar.gz: 8a451da0ae4001a4cd9d9415b2edca146d683f53
3
+ metadata.gz: 52c46d1297e939a78ed704799eb7c2f7f5dfd0ac
4
+ data.tar.gz: 1fa9469f31285e6feed8453e373d1a292be4e7a7
5
5
  SHA512:
6
- metadata.gz: 9798a4a18f6e7603daba5a8ceb878a3ef8448deff7b31655a177070c14c970f69194204ddc0ea6ca419f0f2e4f1074e5f0d9351eac6e13d4e7d315602bb7e977
7
- data.tar.gz: 5ddb8c7a7a0e9b020a2ac75c18629246922fce6cf9f9fa3b7cd6669ee8130aab6d387c593cdb8cef5eebac735aa81509d91611c34dd91102f8d10f639fc4b365
6
+ metadata.gz: 97879e4cf0e072b5887441a2f08cee3154d14573c2318cb75bc352d715a46e93a4a08912a639911329902c2bab403619d9cd9635b1ed3788991b69b7fde5742d
7
+ data.tar.gz: 85b21775cfd5c1a9b795c835429d434899cffe9440373a0267449793c5723562e1329b53bf7b3117ac9b2328d4b8becdf1f004efa5f385420815b6dbb3552faf
@@ -26,7 +26,15 @@ module Lumberg
26
26
  env[:body]
27
27
  end
28
28
 
29
- env[:body] = format_response body
29
+ if body =~ /cPanel operations have been temporarily suspended/
30
+ raise Lumberg::WhmConnectionError.new(body)
31
+ end
32
+
33
+ if @type == :whostmgr || response_type(body) == :whostmgr
34
+ env[:body] = format_response body
35
+ else
36
+ env[:body] = format_response JSON.parse(body)
37
+ end
30
38
  end
31
39
 
32
40
  def response_values(env)
@@ -1,3 +1,3 @@
1
1
  module Lumberg
2
- VERSION = '3.0.0'
2
+ VERSION = '3.1.0'
3
3
  end
@@ -251,7 +251,6 @@ module Lumberg
251
251
  c.request :url_encoded
252
252
  c.response :format_whm, @force_response_type, @response_key, @boolean_params
253
253
  c.response :logger, create_logger_instance
254
- c.response :json unless @force_response_type == :whostmgr
255
254
  c.adapter :net_http
256
255
  c.options[:timeout] = timeout if timeout
257
256
  end.get(function).body
@@ -6,8 +6,9 @@ describe Lumberg::FormatWhm do
6
6
 
7
7
  context "gzip" do
8
8
  let(:gzipped_data) do
9
- "\u001F\x8B\b\u0000\u001E¹R\u0000\u0003+\xCE\xCFMUHI,I\u0004\u0000" +
10
- "\u001E\xE9\xC2\xD9\t\u0000\u0000\u0000"
9
+ "\x1F\x8B\b\x00\x13d\x01V\x00\x03\xABV*.MNN-.V\xB2*)*M\xD5Q\xCA" +
10
+ "\x05\xB2\x13\xD3S\x95\xAC\x94\x8A\xF3sS\x15R\x12K\x12\x95j\x01" +
11
+ "\xA0E\x91\xF9&\x00\x00\x00"
11
12
  end
12
13
 
13
14
  it "removes content encoding" do
@@ -18,13 +19,14 @@ describe Lumberg::FormatWhm do
18
19
 
19
20
  env.should_not include "content-encoding"
20
21
 
21
- env[:body][:params].should eq "some data"
22
+ env[:body][:params][:message].should eq "some data"
22
23
  end
23
24
  end
24
25
 
25
26
  context "deflate" do
26
27
  let(:compressed_data) do
27
- "x\x9C+\xCE\xCFMUHI,I\x04\x00\x11\x81\x03o"
28
+ "x\x9C\xABV*.MNN-.V\xB2*)*M\xD5Q\xCA\x05\xB2\x13\xD3S\x95\xAC" +
29
+ "\x94\x8A\xF3sS\x15R\x12K\x12\x95j\x01\n\xFE\rq"
28
30
  end
29
31
 
30
32
  it "removes content encoding" do
@@ -35,19 +37,28 @@ describe Lumberg::FormatWhm do
35
37
 
36
38
  env.should_not include "content-encoding"
37
39
 
38
- env[:body][:params].should eq "some data"
40
+ env[:body][:params][:message].should eq "some data"
39
41
  end
40
42
  end
41
43
 
42
44
  context "no content encoding" do
43
45
  it "doesn't touch response headers" do
44
- env = { body: "some data", response_headers: { foo: "bar" } }
46
+ env = { body: "{\"success\":true,\"message\":\"some data\"}",
47
+ response_headers: { foo: "bar" } }
45
48
 
46
49
  subject.on_complete(env)
47
50
 
48
51
  env[:response_headers].should include :foo
49
52
 
50
- env[:body][:params].should eq "some data"
53
+ env[:body][:params][:message].should eq "some data"
54
+ end
55
+ end
56
+
57
+ context "API unavailable" do
58
+ it "raises a Lumberg::WhmConnectionError" do
59
+ env = { body: "cPanel operations have been temporarily suspended", response_headers: { foo: "bar" } }
60
+
61
+ expect { subject.on_complete(env) }.to raise_error(Lumberg::WhmConnectionError)
51
62
  end
52
63
  end
53
64
  end
@@ -164,6 +164,7 @@ module Lumberg
164
164
 
165
165
  before(:each) do
166
166
  Net::HTTP.stub(:new) { net_http }
167
+ JSON.stub(:parse) { { } }
167
168
  end
168
169
 
169
170
  it "sets HTTP timeout when assigned" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lumberg
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Mazzi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-12 00:00:00.000000000 Z
11
+ date: 2015-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json