egree 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0f2d7c80d917dd99f8e55c4e15384dcee04eccb
4
- data.tar.gz: d0655650a9da89c3812b73e8700ef321a5ab7a3b
3
+ metadata.gz: 7eb9f6cd9c2b0d668b8c1e8f0ae4f551db1aacbd
4
+ data.tar.gz: 91782d40ea49733ba22757fdb3c2ad73571c2a1b
5
5
  SHA512:
6
- metadata.gz: 4d61499c6c2280e750e57045b9bc9b58445347f5cf6a64e51b66a2cafd1f993176b3390b57c04063b342d3e763de6a1589b0ece507e1b179f9e007b8ad701a25
7
- data.tar.gz: 035356b9a7955d67d5d8e037c7c7c745854e4924715b0f5072d1ca8a1c41ae9d09ddb5e97ba4996f2d56c0de42fca91ca18e53b530dae74ad682e3507f5834f7
6
+ metadata.gz: 290a45487cb216df280ab2ad6666d9419a1268e9d360e3f1cc5cc99aa1b2a38735c6bce3b65bf65356d8bae8ba7c07304106d3f8f1a9b44e74bfb98e2690cd41
7
+ data.tar.gz: 09c546e645ebae7f922e3dc2cd312cb6811f54b3f45db14b56396b34529411f29880c11de548a99777389a11db85c99dbec73197eb822d319b3f3ded9e518fd6
@@ -6,7 +6,7 @@ script: rspec spec
6
6
  addons:
7
7
  code_climate:
8
8
  repo_token:
9
- secure: Y3b1vSaq1qa9dMTbtftg1HzUrftWkx42F2yD/8ana0nUpg3b6xrvzx3LDiEPG1nLU4R7yk+KBr1dQH+skFl2LCJQpyfqwVvFhZz67S4a/8gQfYReTZDGJELMRP6HxbFbsSNisN11a3Kg3VIutBqyU9u1vSIMPx/o8ScvxVcAqHg=
9
+ secure: "MYIsQJ3/wQ6xBYaWCwgG1HRyrH7MH4vME+ACEbM9poMun6jgvFu7Unc0eGpjMxzytophN5o7j0LTc6xxNCMCz6UGFK8Y7RP9/fii6bLFdqROS7jrxYf6tFwKXO4bAhhOZdZjyuYEFiRxImNHPXka+ap4vOnP/QW3D8l94lrAyoM="
10
10
  env:
11
11
  global:
12
12
  - secure: CPu3hIqPCA4txUqh7aS90PR7hGURzyoqcMu0zJx4qvrtvzsI9eyEWKx7P8pXbvYUIgaGevw5GiWEMYH2axkH/74KMyAL9DsdpDA06aCxdZfs7iEaNfZY+l4MN3WCFb9WoLVL7fG+wqgvZXnV4RyLkn+W+vjdmvjY8RZ9G7/0HiE=
@@ -32,9 +32,9 @@ module Egree
32
32
  response = make_post api_command, body
33
33
 
34
34
  if response.success?
35
- SuccessResult.new parse_success_response(response.body)
35
+ SuccessResult.new response.body
36
36
  else
37
- ErrorResult.new parse_error_response(response.body)
37
+ ErrorResult.new response.body
38
38
  end
39
39
  end
40
40
 
@@ -64,18 +64,6 @@ module Egree
64
64
  end
65
65
  end
66
66
 
67
- def parse_success_response body
68
- begin
69
- JSON.parse body
70
- rescue JSON::ParserError
71
- body
72
- end
73
- end
74
-
75
- def parse_error_response body
76
- body.scan(/<p>(.*?)<\/p>/).flatten
77
- end
78
-
79
67
  def hosts
80
68
  {
81
69
  production: "app.egree.com",
@@ -84,10 +72,18 @@ module Egree
84
72
  end
85
73
 
86
74
  class SuccessResult
87
- attr_reader :response
75
+ attr_reader :raw
88
76
 
89
77
  def initialize response
90
- @response = response
78
+ @raw = response
79
+ end
80
+
81
+ def response
82
+ begin
83
+ JSON.parse raw
84
+ rescue JSON::ParserError
85
+ raw
86
+ end
91
87
  end
92
88
 
93
89
  def success?
@@ -96,10 +92,14 @@ module Egree
96
92
  end
97
93
 
98
94
  class ErrorResult
99
- attr_reader :errors
95
+ attr_reader :raw
96
+
97
+ def initialize response
98
+ @raw = response
99
+ end
100
100
 
101
- def initialize errors = []
102
- @errors = Array(errors)
101
+ def errors
102
+ Array(raw.to_s.scan(/<p>(.*?)<\/p>/).flatten)
103
103
  end
104
104
 
105
105
  def success?
@@ -5,7 +5,7 @@ module Egree
5
5
  end
6
6
 
7
7
  class Document
8
- attr_reader :path, :filename, :username, :password
8
+ attr_reader :path, :username, :password
9
9
 
10
10
  def initialize path, filename: nil, username: nil, password: nil
11
11
  @path = path
@@ -1,3 +1,3 @@
1
1
  module Egree
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -68,6 +68,12 @@ RSpec.describe Egree::Client do
68
68
  expect(result.response).to eq("result" => "Success")
69
69
  end
70
70
 
71
+ it "exposes the raw response" do
72
+ result = client.post "/some/path"
73
+
74
+ expect(result.raw).to eq('{ "result": "Success" }')
75
+ end
76
+
71
77
  it "handles simple string bodies" do
72
78
  stub_request(:post, "https://admin:secret@app.egree.com/some/path").to_return({
73
79
  status: 200,
@@ -100,6 +106,12 @@ RSpec.describe Egree::Client do
100
106
 
101
107
  expect(result.errors).to eq [ "Error message", "Another error" ]
102
108
  end
109
+
110
+ it "exposes the raw response" do
111
+ result = client.post "/some/path"
112
+
113
+ expect(result.raw).to eq("<html><p>Error message</p><p>Another error</p></html>")
114
+ end
103
115
  end
104
116
  end
105
117
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: egree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Junström
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-18 00:00:00.000000000 Z
11
+ date: 2014-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday