rack-locale_memorable 0.3.2 → 0.3.3

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: 5ccb7d078d2dd4d582f7db663cf0436da123b94e6531f8d6de83a63c1eb03bbd
4
- data.tar.gz: eb20d6db30ef828dfac9f27843ab9a249308c889835f912e61986d1f08f1edc9
3
+ metadata.gz: 51ae9ed5a060ebb4263d0faeded7a6bdd94d40abb9835c670ce500e278ae5ac1
4
+ data.tar.gz: 758bc0cf5ac3498be41d78b79382024752d8a7ebb5995c0097b16031dacf4d86
5
5
  SHA512:
6
- metadata.gz: 5b6212b7c2a58b6f110a22856ac52c8197600ccc9929f229147f8324d6342a15e5472ef45917fe11dfbdd2bf196877fd8b5e26f962cfa9668b95d7622b77cd8d
7
- data.tar.gz: 6fdd32c5bad90120d759514971c20b2de1330fbc9774bbf218cd91a7781cfffb89f2a29f3da5547452b4ae1cede23d757d6b25ca345429cb7b5f81b6f98f0eae
6
+ metadata.gz: a6f73bce4a3940de8115d561cb2a3785f143e48496ba0822a186257122a3b8e4a0e2de1bc84ef5466da5cb0862fdcf5e410520d0d949100f7cfecfefad9e1a15
7
+ data.tar.gz: e38a7bd143e65235b55af8b05897135d04ca897ba0fdac1892e66b992005f7e81517a3265924bbba210860451abd8c39e9d5c756f029a5299bd9c98831599027
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.3] - 2022-09-28
4
+
5
+ ### Refactored
6
+
7
+ - requre active_support/core_ext only https://github.com/nov/rack-locale_memorable/commit/bf56b49f064a30d9688d65d2dd2901763bf31cee
8
+ - stop using request class's instance variables following response class's design https://github.com/nov/rack-locale_memorable/commit/056807010fcb5c01d4d1745f06f8a9f87aad2ec6
9
+
3
10
  ## [0.3.2] - 2022-09-28
4
11
 
5
12
  ### Fixed
@@ -3,30 +3,24 @@
3
3
  module Rack
4
4
  class LocaleMemorable
5
5
  class Request < Rack::Request
6
- attr_reader :explicit_locale, :params_key, :cookie_key
6
+ attr_reader :explicit_locale
7
7
 
8
- def initialize(env, params_key:, cookie_key:)
9
- super env
10
- @params_key = params_key
11
- @cookie_key = cookie_key
12
- end
13
-
14
- def detect_locale
8
+ def detect_locale(params_key:, cookie_key:)
15
9
  (
16
- from_params ||
17
- from_cookies ||
10
+ from_params(params_key) ||
11
+ from_cookies(cookie_key) ||
18
12
  from_headers
19
13
  )
20
14
  end
21
15
 
22
16
  private
23
17
 
24
- def from_params
25
- @explicit_locale = primary_locale_from params[params_key]
18
+ def from_params(key)
19
+ @explicit_locale = primary_locale_from params[key]
26
20
  end
27
21
 
28
- def from_cookies
29
- primary_locale_from cookies[cookie_key]
22
+ def from_cookies(key)
23
+ primary_locale_from cookies[key]
30
24
  end
31
25
 
32
26
  def from_headers
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  class LocaleMemorable
5
- VERSION = '0.3.2'
5
+ VERSION = '0.3.3'
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'active_support'
4
- require 'active_support/all'
4
+ require 'active_support/core_ext'
5
5
  require 'http/accept'
6
6
  require 'rack'
7
7
 
@@ -16,8 +16,8 @@ module Rack
16
16
  end
17
17
 
18
18
  def call(env)
19
- request = Request.new(env, params_key: @params_key, cookie_key: @cookie_key)
20
- I18n.with_locale(request.detect_locale) do
19
+ request = Request.new env
20
+ I18n.with_locale(request.detect_locale params_key: @params_key, cookie_key: @cookie_key) do
21
21
  status, headers, body = @app.call(env)
22
22
  response = Response.new body, status, headers
23
23
  if request.explicit_locale.present?
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.3.2
4
+ version: 0.3.3
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.1.6
166
+ rubygems_version: 3.3.7
167
167
  signing_key:
168
168
  specification_version: 4
169
169
  summary: Remember locale in rack layer