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 +4 -4
- data/.travis.yml +1 -1
- data/lib/egree/client.rb +19 -19
- data/lib/egree/document.rb +1 -1
- data/lib/egree/version.rb +1 -1
- data/spec/egree/client_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eb9f6cd9c2b0d668b8c1e8f0ae4f551db1aacbd
|
4
|
+
data.tar.gz: 91782d40ea49733ba22757fdb3c2ad73571c2a1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 290a45487cb216df280ab2ad6666d9419a1268e9d360e3f1cc5cc99aa1b2a38735c6bce3b65bf65356d8bae8ba7c07304106d3f8f1a9b44e74bfb98e2690cd41
|
7
|
+
data.tar.gz: 09c546e645ebae7f922e3dc2cd312cb6811f54b3f45db14b56396b34529411f29880c11de548a99777389a11db85c99dbec73197eb822d319b3f3ded9e518fd6
|
data/.travis.yml
CHANGED
@@ -6,7 +6,7 @@ script: rspec spec
|
|
6
6
|
addons:
|
7
7
|
code_climate:
|
8
8
|
repo_token:
|
9
|
-
secure:
|
9
|
+
secure: "MYIsQJ3/wQ6xBYaWCwgG1HRyrH7MH4vME+ACEbM9poMun6jgvFu7Unc0eGpjMxzytophN5o7j0LTc6xxNCMCz6UGFK8Y7RP9/fii6bLFdqROS7jrxYf6tFwKXO4bAhhOZdZjyuYEFiRxImNHPXka+ap4vOnP/QW3D8l94lrAyoM="
|
10
10
|
env:
|
11
11
|
global:
|
12
12
|
- secure: CPu3hIqPCA4txUqh7aS90PR7hGURzyoqcMu0zJx4qvrtvzsI9eyEWKx7P8pXbvYUIgaGevw5GiWEMYH2axkH/74KMyAL9DsdpDA06aCxdZfs7iEaNfZY+l4MN3WCFb9WoLVL7fG+wqgvZXnV4RyLkn+W+vjdmvjY8RZ9G7/0HiE=
|
data/lib/egree/client.rb
CHANGED
@@ -32,9 +32,9 @@ module Egree
|
|
32
32
|
response = make_post api_command, body
|
33
33
|
|
34
34
|
if response.success?
|
35
|
-
SuccessResult.new
|
35
|
+
SuccessResult.new response.body
|
36
36
|
else
|
37
|
-
ErrorResult.new
|
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 :
|
75
|
+
attr_reader :raw
|
88
76
|
|
89
77
|
def initialize response
|
90
|
-
@
|
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 :
|
95
|
+
attr_reader :raw
|
96
|
+
|
97
|
+
def initialize response
|
98
|
+
@raw = response
|
99
|
+
end
|
100
100
|
|
101
|
-
def
|
102
|
-
|
101
|
+
def errors
|
102
|
+
Array(raw.to_s.scan(/<p>(.*?)<\/p>/).flatten)
|
103
103
|
end
|
104
104
|
|
105
105
|
def success?
|
data/lib/egree/document.rb
CHANGED
data/lib/egree/version.rb
CHANGED
data/spec/egree/client_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2014-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|