oop_rails_server 0.0.19 → 0.0.20
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 140913824859d2e60dac03fd6dcf65dea5a08583
|
4
|
+
data.tar.gz: 5f2868f6c2eb0c022e58a8662482df1a977999dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7571e1382081033e21809caff1f082d7b72137c752063e99a008470b57c47c6e5b4f57f393dd422232561a20026cadca1ad0e8717ffd0fb45de4ec0014a255f
|
7
|
+
data.tar.gz: ae4e5afc2c61b4154833537c1c2e4c49993165343101bc67fea02d4d9a2954e015ddfe088df8023eaa662fd5e648410ef1ea8dc9beb3f017d33e7a157cde9c87
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# `oop_rails_server` Releases
|
2
2
|
|
3
|
+
## 0.0.20, 27 September 2016
|
4
|
+
|
5
|
+
* If exceptions have a `cause`, nest that inside the JSON returned on error.
|
6
|
+
* Pass 'Accept: text/html' by default when fetching from a Rails server, unless specified otherwise.
|
7
|
+
|
3
8
|
## 0.0.19, 20 September 2016
|
4
9
|
|
5
10
|
* Significant internal refactor to how Gemfiles get modified that's much more reliable; changes
|
@@ -94,11 +94,16 @@ module OopRailsServer
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def get_response(path_or_uri, options = { })
|
97
|
-
options.assert_valid_keys(:ignore_status_code, :nil_on_not_found, :query, :no_layout)
|
97
|
+
options.assert_valid_keys(:ignore_status_code, :nil_on_not_found, :query, :no_layout, :accept_header)
|
98
98
|
|
99
99
|
uri = uri_for(path_or_uri, options[:query])
|
100
|
-
|
101
|
-
|
100
|
+
data = nil
|
101
|
+
accept_header = options.fetch(:accept_header, 'text/html')
|
102
|
+
Net::HTTP.start(uri.host, uri.port) do |http|
|
103
|
+
request = Net::HTTP::Get.new(uri)
|
104
|
+
request['Accept'] = accept_header if accept_header
|
105
|
+
data = http.request(request)
|
106
|
+
end
|
102
107
|
|
103
108
|
if (data.code.to_s != '200')
|
104
109
|
if options[:ignore_status_code]
|
@@ -106,7 +111,7 @@ module OopRailsServer
|
|
106
111
|
elsif options[:nil_on_not_found]
|
107
112
|
data = nil
|
108
113
|
else
|
109
|
-
raise "'#{uri}' returned #{data.code.inspect}, not 200; body was: #{data.body.
|
114
|
+
raise "'#{uri}' returned #{data.code.inspect}, not 200; body was: #{data.body.inspect}"
|
110
115
|
end
|
111
116
|
end
|
112
117
|
data
|
@@ -5,11 +5,22 @@ class ApplicationController < ActionController::Base
|
|
5
5
|
|
6
6
|
rescue_from Exception do |exception|
|
7
7
|
render :json => {
|
8
|
-
:exception =>
|
9
|
-
:class => exception.class.name,
|
10
|
-
:message => exception.message,
|
11
|
-
:backtrace => exception.backtrace
|
12
|
-
}
|
8
|
+
:exception => exception_to_hash(exception)
|
13
9
|
}
|
14
10
|
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def exception_to_hash(exception)
|
14
|
+
out = {
|
15
|
+
:class => exception.class.name,
|
16
|
+
:message => exception.message,
|
17
|
+
:backtrace => exception.backtrace
|
18
|
+
}
|
19
|
+
|
20
|
+
if exception.cause && (! exception.cause.equal?(exception))
|
21
|
+
out[:cause] = exception_to_hash(exception.cause)
|
22
|
+
end
|
23
|
+
|
24
|
+
out
|
25
|
+
end
|
15
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oop_rails_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Geweke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|