olive_branch 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/olive_branch/middleware.rb +28 -26
- data/lib/olive_branch/version.rb +1 -1
- 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: a106693bc43b70d778cef9b9036eb117a847a000
|
4
|
+
data.tar.gz: 5d9e7ac4ab6af23ce36a9df7b3393a4fc11f99f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b74e3efc8aa26373c6b89502b4ce27c895dff86fd3a9e48a8d11d4c6bcb04b50ece997b294c543e73760f25b6fa55ab7b2355bf813423f300068c8fc0e9265f1
|
7
|
+
data.tar.gz: 90980c1788233fe058ed5131cb2c1f294553c77bdb0ac8dc48801ca41971f283185fa9258f52e4ea2acaa77bd94c564cd68ed831fa7e3e3461ccfa0fe66c476b
|
@@ -12,42 +12,44 @@ module OliveBranch
|
|
12
12
|
end
|
13
13
|
|
14
14
|
@app.call(env).tap do |_status, headers, response|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
next unless inflection && headers["Content-Type"] =~ /application\/json/
|
16
|
+
response.each do |body|
|
17
|
+
begin
|
18
|
+
new_response = JSON.parse(body)
|
19
|
+
rescue JSON::ParserError
|
20
|
+
next
|
21
|
+
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
23
|
+
if inflection == "camel"
|
24
|
+
if new_response.is_a? Array
|
25
|
+
new_response.each { |o| o.deep_transform_keys! { |k| k.camelize(:lower)} }
|
26
|
+
else
|
27
|
+
new_response.deep_transform_keys! { |k| k.camelize(:lower) }
|
28
|
+
end
|
29
|
+
elsif inflection == "dash"
|
30
|
+
if new_response.is_a? Array
|
31
|
+
new_response.each { |o| o.deep_transform_keys!(&:dasherize) }
|
32
|
+
else
|
33
|
+
new_response.deep_transform_keys!(&:dasherize)
|
35
34
|
end
|
36
|
-
|
37
|
-
body.replace(new_response.to_json)
|
38
35
|
end
|
36
|
+
|
37
|
+
body.replace(new_response.to_json)
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
43
42
|
def underscore_params(env)
|
44
43
|
if defined?(Rails) && Rails::VERSION::MAJOR >= 5
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
begin
|
45
|
+
request_body = JSON.parse(env['rack.input'].read)
|
46
|
+
request_body.deep_transform_keys!(&:underscore)
|
47
|
+
req = StringIO.new(request_body.to_json)
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
env['rack.input'] = req
|
50
|
+
env['CONTENT_LENGTH'] = req.length
|
51
|
+
rescue JSON::ParserError
|
52
|
+
end
|
51
53
|
else
|
52
54
|
env["action_dispatch.request.request_parameters"].deep_transform_keys!(&:underscore)
|
53
55
|
end
|
data/lib/olive_branch/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: olive_branch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Fatsi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-01-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|