olive_branch 2.1.5 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30af0d59c0e8df679e1783b6cd3ce57d5c21798ecff3b667ac0f8fd8338d8574
4
- data.tar.gz: d9351f2645900302d92b35a0d0ae3e74b76eac6896214afd78a28c2f622a6f6b
3
+ metadata.gz: fb564e7a107ec4a4ec603c123a1712b4cc564091606a42acf3a420ef61d42a8c
4
+ data.tar.gz: 980afa4b827e039484b1e0a9983c49cdcb884c1202c5a984ab008ecf65b0df0b
5
5
  SHA512:
6
- metadata.gz: e4e60b68bacc722e63e6ea81d98879aa8b429c884380eee66603b991720feba73b87476da6c780430d83aea3ed706493d5691ee054c8ed8f5343cd36cd699bab
7
- data.tar.gz: 9262f295bd14cb6babf280b6064be3ba0603497728e2bbd8d8ea782b5827d3652df381d7607991bbe9dc8c32edab41cefaef99caa566dd73014fe4cddfbbb332
6
+ metadata.gz: 69c7a3da07246dd9566a5fb62b276f2fd31e085066a8369d3e95d49c21ee0f6592c6718eeeccf4335be6b7062af82491772919c7e37cb831cc1d949b4acb906f
7
+ data.tar.gz: c4662471213424e5c06ccf547b90745b75a8addd9ba6f4382ce306f47fe3af328f062144454a6f69d3a5550dc1141c7d7f1cde1a8334afd146594b689cb91f27
data/README.md CHANGED
@@ -21,7 +21,7 @@ config.middleware.use OliveBranch::Middleware
21
21
 
22
22
  ## Use
23
23
 
24
- Include a `X-Key-Inflection` header with values of `camel`, `dash`, or `snake` in your JSON API requests.
24
+ Include a `Key-Inflection` header with values of `camel`, `dash`, `snake` or `pascal` in your JSON API requests.
25
25
 
26
26
  For more examples, see [our blog post](https://www.viget.com/articles/introducing-olivebranch).
27
27
 
@@ -48,7 +48,13 @@ end
48
48
  config.middleware.use OliveBranch::Middleware, camelize: FastCamel.method(:camelize)
49
49
  ```
50
50
 
51
- A default inflection can be specified so you don't have to include the `X-Key-Inflection` header on every request.
51
+ Default inflection header key can be changed like
52
+
53
+ ```ruby
54
+ config.middleware.use OliveBranch::Middleware, inflection_header: 'Inflect-With'
55
+ ```
56
+
57
+ A default inflection can be specified so you don't have to include the `Key-Inflection` header on every request.
52
58
 
53
59
  ```ruby
54
60
  config.middleware.use OliveBranch::Middleware, inflection: 'camel'
@@ -55,6 +55,8 @@ module OliveBranch
55
55
  @exclude_response = args[:exclude_response] || Checks.method(:default_exclude)
56
56
  @exclude_params = args[:exclude_params] || Checks.method(:default_exclude)
57
57
  @default_inflection = args[:inflection]
58
+ @inflection_header = args.fetch(:inflection_header, 'Key-Inflection').gsub(/[^a-z0-9]/i, '_').upcase
59
+ @inflection_header = "HTTP_#{@inflection_header}" unless @inflection_header.start_with?('HTTP_')
58
60
  end
59
61
 
60
62
  def call(env)
@@ -100,7 +102,7 @@ module OliveBranch
100
102
  end
101
103
 
102
104
  def inflection_type(env)
103
- env["HTTP_X_KEY_INFLECTION"] || @default_inflection
105
+ env[@inflection_header] || @default_inflection
104
106
  end
105
107
 
106
108
  def inflection_method(env)
@@ -1,3 +1,3 @@
1
1
  module OliveBranch
2
- VERSION = '2.1.5'
2
+ VERSION = '3.0.0'
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: 2.1.5
4
+ version: 3.0.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: 2019-02-21 00:00:00.000000000 Z
12
+ date: 2019-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails