olive_branch 1.0.0 → 1.0.1

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: c1547ffafacf7baa2b3c55a911c4b943b09f0cfe
4
- data.tar.gz: 81463b9e8ada7c5bacfe04c7edbbc3d5d5765107
3
+ metadata.gz: 57c893d626504869e2eacd978f3f267545f8e84b
4
+ data.tar.gz: 020ffd7265062ac8bf6fa461eaf00102fa14f923
5
5
  SHA512:
6
- metadata.gz: ed68fde9ecd1176b9b93046575fa868823b4eabbb4b9f937470aa357d93245d6b9dd6be23c2a745286f0feddd03d6ede0ee8351300202c4e2739c7b2b3c9a938
7
- data.tar.gz: a1e5a53e095253afa619b5ac93bbe73f27bd7ec73d7888214589c9e92cb0a9add2b156228755b71f2073f91c2d41bc9b9b296da37489a1ef1bea1e193a5f1625
6
+ metadata.gz: b14b69a93aa6f614cb47c7b1f7755953aae47cfb97652a520a1959b74bb2af468212fb047f2d09d92ab6fea85625985b0a6aa2084d0fe63835669bf60b31d492
7
+ data.tar.gz: c01c628795936ba94a4da782eb4a3a41b7b1269419e24c743d83876336c5ede5082e20be964a060b3ee9f5d33213d38f6040e65dd096624a3c43451da5a77995
data/README.md CHANGED
@@ -8,11 +8,11 @@ This gem lets your API users pass in and receive camelCased or dash-cased keys,
8
8
 
9
9
  1. Add this to your Gemfile and then `bundle install`:
10
10
 
11
- gem "olive_branch"
11
+ gem "olive_branch"
12
12
 
13
13
  2. Add this to `config/applcation.rb`:
14
14
 
15
- config.middleware.use "OliveBranch::Middleware"
15
+ config.middleware.use "OliveBranch::Middleware"
16
16
 
17
17
  ## Use
18
18
 
@@ -11,20 +11,24 @@ module OliveBranch
11
11
  env["action_dispatch.request.request_parameters"].deep_transform_keys!(&:underscore)
12
12
  end
13
13
 
14
- status, headers, response = @app.call(env)
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
22
 
16
- if inflection && headers["Content-Type"] =~ /application\/json/
17
- new_response = JSON.parse(response.body)
23
+ if inflection == "camel"
24
+ new_response.deep_transform_keys! { |k| k.camelize(:lower) }
25
+ elsif inflection == "dash"
26
+ new_response.deep_transform_keys!(&:dasherize)
27
+ end
18
28
 
19
- if inflection == "camel"
20
- new_response.deep_transform_keys! { |k| k.camelize(:lower) }
21
- elsif inflection == "dash"
22
- new_response.deep_transform_keys!(&:dasherize)
29
+ body.replace(new_response.to_json)
30
+ end
23
31
  end
24
-
25
- [status, headers, [new_response.to_json]]
26
- else
27
- [status, headers, response]
28
32
  end
29
33
  end
30
34
  end
@@ -1,3 +1,3 @@
1
1
  module OliveBranch
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
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.0.0
4
+ version: 1.0.1
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-04-13 00:00:00.000000000 Z
12
+ date: 2016-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '4.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '3.2'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '3.2'
28
42
  description: Handle camel/snake/dash case conversion
29
43
  email:
30
44
  - eli.fatsi@viget.com