rack-locale_memorable 0.2.2 → 0.3.0

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
  SHA256:
3
- metadata.gz: c5d66845b0ecc18ec3afd2e985bad0d29533f031cad50f4a214b3273ccf21634
4
- data.tar.gz: f4c1190527981fc0a17899539ceaf0cb954a68276b18cef39990e3f881a7eba9
3
+ metadata.gz: b56451d07060a802f688db0f338178fa1c8d2ed9f1ea5bafd1ec120e0e241fae
4
+ data.tar.gz: 6d98f588efe1eb3d14a13ff989600fc67f1e3ae84ccc99e641206398b27c5589
5
5
  SHA512:
6
- metadata.gz: 2bfa002397c86cd7c82a92b01d0ae56102869e65a4c20f7bc92b50128c12badf4692e6a42ded5008b60dac58f8290c2e77280a55d1674edc7daf71a3d374f16c
7
- data.tar.gz: 0ca6c6d961aa210f709545e0610c5e6f3d29abb983e262484e9f133d4ac2b93ee40df9e5d6dad724d6e36ef6b4b8ce6e9a07d982ea68e7bb503bfa93d6f55488
6
+ metadata.gz: 4a2cdb7a55ff2d53fbf951fa11c31e2e8fd056c762f9dda3c22799e90b3fe3e32dd667534e6f069bf471a3185eb16a873bd054848f65d7aba626dbdc6c94dfdc
7
+ data.tar.gz: b945b0c1f8398a9bb3ac3c9e97ff9e303af47e35fe5a5d271a1af7bef304e8e15730c961b9c30c9dd83d4b1af2c0aa0e8e52f876ec59fba8e12548b1b20604ff
@@ -3,7 +3,13 @@
3
3
  module Rack
4
4
  class LocaleMemorable
5
5
  class Request < Rack::Request
6
- attr_reader :explicit_locale
6
+ attr_reader :explicit_locale, :params_key, :cookie_key
7
+
8
+ def initialize(env, params_key:, cookie_key:)
9
+ super env
10
+ @params_key = params_key
11
+ @cookie_key = cookie_key
12
+ end
7
13
 
8
14
  def detect_locale
9
15
  (
@@ -16,11 +22,11 @@ module Rack
16
22
  private
17
23
 
18
24
  def from_params
19
- @explicit_locale = primary_locale_from params['locale']
25
+ @explicit_locale = primary_locale_from params[params_key]
20
26
  end
21
27
 
22
28
  def from_cookies
23
- primary_locale_from cookies['locale']
29
+ primary_locale_from cookies[cookie_key]
24
30
  end
25
31
 
26
32
  def from_headers
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  class LocaleMemorable
5
- VERSION = '0.2.2'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -7,14 +7,16 @@ require 'rack'
7
7
 
8
8
  module Rack
9
9
  class LocaleMemorable
10
- def initialize(app, secure_cookie: true, cookie_expiry: 1.year.from_now)
10
+ def initialize(app, params_key: 'locale', cookie_key: 'locale', secure_cookie: true, cookie_expiry: 1.year.from_now)
11
11
  @app = app
12
+ @params_key = params_key
13
+ @cookie_key = cookie_key
12
14
  @secure_cookie = secure_cookie
13
15
  @cookie_expiry = cookie_expiry
14
16
  end
15
17
 
16
18
  def call(env)
17
- request = Request.new(env)
19
+ request = Request.new(env, params_key: @params_key, cookie_key: @cookie_key)
18
20
  I18n.with_locale(request.detect_locale) do
19
21
  status, headers, body = @app.call(env)
20
22
  response = Response.new body, status, headers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-locale_memorable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
165
  requirements: []
166
- rubygems_version: 3.3.7
166
+ rubygems_version: 3.1.6
167
167
  signing_key:
168
168
  specification_version: 4
169
169
  summary: Remember locale in rack layer