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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e65696dd80713050ce9baff9d3ae61288bedaa6
4
- data.tar.gz: 2d258e82c9218d840c49fae82c042e84ed5a60b3
3
+ metadata.gz: a106693bc43b70d778cef9b9036eb117a847a000
4
+ data.tar.gz: 5d9e7ac4ab6af23ce36a9df7b3393a4fc11f99f6
5
5
  SHA512:
6
- metadata.gz: 13d7b5ab67bbaf244a1eb87b0ecc59ead20465b37a46376f845dfafb93293f7a64eaae60efd36400fa6982f613315288a64b81d192a5f84ad392012f41832c1c
7
- data.tar.gz: 0ae945f6a8c95e14bf18ef260469241a41d58dedee1ccf3c4a4dcca534198fab5caebbb5eaf2d3612fd31c0468cd017828665fe5331d79470c8c7a7cb64ba50f
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
- if 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
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
- 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)
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
- request_body = JSON.parse(env['rack.input'].read)
46
- request_body.deep_transform_keys!(&:underscore)
47
- req = StringIO.new(request_body.to_json)
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
- env['rack.input'] = req
50
- env['CONTENT_LENGTH'] = req.length
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
@@ -1,3 +1,3 @@
1
1
  module OliveBranch
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
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.1
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: 2016-12-23 00:00:00.000000000 Z
12
+ date: 2017-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails