olive_branch 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/olive_branch/middleware.rb +14 -1
- data/lib/olive_branch/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1003430e098e5da7f06c8b10bf05e5fbaad73609
|
4
|
+
data.tar.gz: fd1d42c19334bf3afcce7da25e36affc58ce1836
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33354c35884b50bf2a270b23e9f0ab465fb96b20114254cb01d661102b1c64cf93b1bbfcf0a17ea77425a732dd21a10d0d6e13630f401a2d9bda13257c7787f9
|
7
|
+
data.tar.gz: 86dbfc19f6350351ba615e242c9235f42eed5d78217894118028a3dcaa1195352732822687483b395cc5a5b71c13f398b8e1acd6a43e103c2c938d10290a54de
|
data/README.md
CHANGED
@@ -18,6 +18,8 @@ This gem lets your API users pass in and receive camelCased or dash-cased keys,
|
|
18
18
|
|
19
19
|
Include a `X-Key-Inflection` header with values of `camel`, `dash`, or `snake` in your JSON API requests.
|
20
20
|
|
21
|
+
For more examples, see [our blog post](https://www.viget.com/articles/introducing-olivebranch).
|
22
|
+
|
21
23
|
|
22
24
|
* * *
|
23
25
|
|
@@ -8,7 +8,7 @@ module OliveBranch
|
|
8
8
|
inflection = env["HTTP_X_KEY_INFLECTION"]
|
9
9
|
|
10
10
|
if inflection && env["CONTENT_TYPE"] =~ /application\/json/
|
11
|
-
env
|
11
|
+
underscore_params(env)
|
12
12
|
end
|
13
13
|
|
14
14
|
@app.call(env).tap do |_status, headers, response|
|
@@ -31,5 +31,18 @@ module OliveBranch
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
def underscore_params(env)
|
36
|
+
if Rails::VERSION::MAJOR < 5
|
37
|
+
env["action_dispatch.request.request_parameters"].deep_transform_keys!(&:underscore)
|
38
|
+
else
|
39
|
+
request_body = JSON.parse(env['rack.input'].read)
|
40
|
+
request_body.deep_transform_keys!(&:underscore)
|
41
|
+
req = StringIO.new(request_body.to_json)
|
42
|
+
|
43
|
+
env['rack.input'] = req
|
44
|
+
env['CONTENT_LENGTH'] = req.length
|
45
|
+
end
|
46
|
+
end
|
34
47
|
end
|
35
48
|
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.
|
4
|
+
version: 1.2.0
|
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
|
+
date: 2016-10-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
74
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.
|
75
|
+
rubygems_version: 2.5.1
|
76
76
|
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: Handle camel/snake/dash case conversion
|