bp3-action_dispatch 0.1.3 → 0.1.5
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/.ruby-version +1 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +40 -35
- data/lib/bp3/action_dispatch/request_locale.rb +14 -5
- data/lib/bp3/action_dispatch/version.rb +1 -1
- metadata +3 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdf9be44a42b74756269d26068ccd6d8437722bd5934acf8a8b3da9263d13b5a
|
4
|
+
data.tar.gz: 07f601b2a6e4cb90f36f4f130102de8136d2f3403eb8f8b4d392746c816ab275
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3fc2c07f2d6cb082b23f7123b6b98c434dfa778fe1b36c65bacb7633cdf41bd799f7dc3fc00d201669bb1ff8e65e37c3008148cc11b0cad2728824f6ff0e935
|
7
|
+
data.tar.gz: a616dc90d97b1147cae861f2a4e3c490e88aea3ca5192faa463a6c763e3dc0e5b0be76f6e74e5ae3488dd662e0865e43a5b6b0093730e593b69c306d29db92d6
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-3.
|
1
|
+
ruby-3.4.6
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.5] - 2025-09-19
|
4
|
+
|
5
|
+
- Update ruby version to 3.4.6
|
6
|
+
|
7
|
+
## [0.1.4] - 2025-01-27
|
8
|
+
|
9
|
+
- Increase robustness of path parsing
|
10
|
+
- handle cases with '//' in the path (blank path segments)
|
11
|
+
- return default locale as fallback
|
12
|
+
|
3
13
|
## [0.1.3] - 2024-11-18
|
4
14
|
|
5
15
|
- Use ruby 3.3.5 and relax gem constraints
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bp3-action_dispatch (0.1.
|
4
|
+
bp3-action_dispatch (0.1.5)
|
5
5
|
actionpack (>= 7.1.2)
|
6
6
|
activesupport (>= 7.1.2)
|
7
7
|
i18n (>= 1.8.11)
|
@@ -9,9 +9,9 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actionpack (8.0.
|
13
|
-
actionview (= 8.0.
|
14
|
-
activesupport (= 8.0.
|
12
|
+
actionpack (8.0.1)
|
13
|
+
actionview (= 8.0.1)
|
14
|
+
activesupport (= 8.0.1)
|
15
15
|
nokogiri (>= 1.8.5)
|
16
16
|
rack (>= 2.2.4)
|
17
17
|
rack-session (>= 1.0.1)
|
@@ -19,13 +19,13 @@ GEM
|
|
19
19
|
rails-dom-testing (~> 2.2)
|
20
20
|
rails-html-sanitizer (~> 1.6)
|
21
21
|
useragent (~> 0.16)
|
22
|
-
actionview (8.0.
|
23
|
-
activesupport (= 8.0.
|
22
|
+
actionview (8.0.1)
|
23
|
+
activesupport (= 8.0.1)
|
24
24
|
builder (~> 3.1)
|
25
25
|
erubi (~> 1.11)
|
26
26
|
rails-dom-testing (~> 2.2)
|
27
27
|
rails-html-sanitizer (~> 1.6)
|
28
|
-
activesupport (8.0.
|
28
|
+
activesupport (8.0.1)
|
29
29
|
base64
|
30
30
|
benchmark (>= 0.3)
|
31
31
|
bigdecimal
|
@@ -41,46 +41,47 @@ GEM
|
|
41
41
|
ast (2.4.2)
|
42
42
|
base64 (0.2.0)
|
43
43
|
benchmark (0.4.0)
|
44
|
-
bigdecimal (3.1.
|
44
|
+
bigdecimal (3.1.9)
|
45
45
|
builder (3.3.0)
|
46
46
|
byebug (11.1.3)
|
47
|
-
concurrent-ruby (1.3.
|
48
|
-
connection_pool (2.
|
47
|
+
concurrent-ruby (1.3.5)
|
48
|
+
connection_pool (2.5.0)
|
49
49
|
crass (1.0.6)
|
50
50
|
diff-lcs (1.5.1)
|
51
51
|
drb (2.2.1)
|
52
|
-
erubi (1.13.
|
53
|
-
i18n (1.14.
|
52
|
+
erubi (1.13.1)
|
53
|
+
i18n (1.14.7)
|
54
54
|
concurrent-ruby (~> 1.0)
|
55
|
-
json (2.
|
56
|
-
language_server-protocol (3.17.0.
|
57
|
-
logger (1.6.
|
58
|
-
loofah (2.
|
55
|
+
json (2.9.1)
|
56
|
+
language_server-protocol (3.17.0.4)
|
57
|
+
logger (1.6.5)
|
58
|
+
loofah (2.24.0)
|
59
59
|
crass (~> 1.0.2)
|
60
60
|
nokogiri (>= 1.12.0)
|
61
|
-
minitest (5.25.
|
62
|
-
nokogiri (1.
|
61
|
+
minitest (5.25.4)
|
62
|
+
nokogiri (1.18.2-x86_64-darwin)
|
63
63
|
racc (~> 1.4)
|
64
64
|
parallel (1.26.3)
|
65
|
-
parser (3.3.
|
65
|
+
parser (3.3.7.0)
|
66
66
|
ast (~> 2.4.1)
|
67
67
|
racc
|
68
68
|
racc (1.8.1)
|
69
69
|
rack (3.1.8)
|
70
|
-
rack-session (2.
|
70
|
+
rack-session (2.1.0)
|
71
|
+
base64 (>= 0.1.0)
|
71
72
|
rack (>= 3.0.0)
|
72
|
-
rack-test (2.
|
73
|
+
rack-test (2.2.0)
|
73
74
|
rack (>= 1.3)
|
74
75
|
rails-dom-testing (2.2.0)
|
75
76
|
activesupport (>= 5.0.0)
|
76
77
|
minitest
|
77
78
|
nokogiri (>= 1.6)
|
78
|
-
rails-html-sanitizer (1.6.
|
79
|
+
rails-html-sanitizer (1.6.2)
|
79
80
|
loofah (~> 2.21)
|
80
|
-
nokogiri (
|
81
|
+
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
81
82
|
rainbow (3.1.1)
|
82
83
|
rake (13.2.1)
|
83
|
-
regexp_parser (2.
|
84
|
+
regexp_parser (2.10.0)
|
84
85
|
rspec (3.13.0)
|
85
86
|
rspec-core (~> 3.13.0)
|
86
87
|
rspec-expectations (~> 3.13.0)
|
@@ -93,34 +94,38 @@ GEM
|
|
93
94
|
rspec-mocks (3.13.2)
|
94
95
|
diff-lcs (>= 1.2.0, < 2.0)
|
95
96
|
rspec-support (~> 3.13.0)
|
96
|
-
rspec-support (3.13.
|
97
|
-
rubocop (1.
|
97
|
+
rspec-support (3.13.2)
|
98
|
+
rubocop (1.71.0)
|
98
99
|
json (~> 2.3)
|
99
100
|
language_server-protocol (>= 3.17.0)
|
100
101
|
parallel (~> 1.10)
|
101
102
|
parser (>= 3.3.0.2)
|
102
103
|
rainbow (>= 2.2.2, < 4.0)
|
103
|
-
regexp_parser (>= 2.
|
104
|
-
rubocop-ast (>= 1.
|
104
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
105
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
105
106
|
ruby-progressbar (~> 1.7)
|
106
|
-
unicode-display_width (>= 2.4.0, <
|
107
|
-
rubocop-ast (1.
|
107
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
108
|
+
rubocop-ast (1.38.0)
|
108
109
|
parser (>= 3.3.1.0)
|
109
110
|
rubocop-rake (0.6.0)
|
110
111
|
rubocop (~> 1.0)
|
111
|
-
rubocop-rspec (3.
|
112
|
+
rubocop-rspec (3.4.0)
|
112
113
|
rubocop (~> 1.61)
|
113
114
|
ruby-progressbar (1.13.0)
|
114
|
-
securerandom (0.
|
115
|
+
securerandom (0.4.1)
|
115
116
|
tzinfo (2.0.6)
|
116
117
|
concurrent-ruby (~> 1.0)
|
117
|
-
unicode-display_width (
|
118
|
+
unicode-display_width (3.1.4)
|
119
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
120
|
+
unicode-emoji (4.0.4)
|
118
121
|
uri (1.0.2)
|
119
|
-
useragent (0.16.
|
122
|
+
useragent (0.16.11)
|
120
123
|
|
121
124
|
PLATFORMS
|
122
125
|
x86_64-darwin-21
|
123
126
|
x86_64-darwin-22
|
127
|
+
x86_64-darwin-23
|
128
|
+
x86_64-darwin-24
|
124
129
|
|
125
130
|
DEPENDENCIES
|
126
131
|
bp3-action_dispatch!
|
@@ -132,4 +137,4 @@ DEPENDENCIES
|
|
132
137
|
rubocop-rspec (>= 2.25)
|
133
138
|
|
134
139
|
BUNDLED WITH
|
135
|
-
2.
|
140
|
+
2.7.2
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Bp3
|
4
4
|
module ActionDispatch
|
5
5
|
module RequestLocale
|
6
|
+
attr_reader :locale_from
|
7
|
+
|
6
8
|
def request_locale
|
7
9
|
@request_locale ||= extract_locale
|
8
10
|
end
|
@@ -14,18 +16,19 @@ module Bp3
|
|
14
16
|
extract_locale_from_params ||
|
15
17
|
extract_locale_from_host ||
|
16
18
|
extract_locale_from_header ||
|
17
|
-
extract_locale_from_setting
|
19
|
+
extract_locale_from_setting ||
|
20
|
+
default_locale
|
18
21
|
end
|
19
22
|
|
20
23
|
def extract_locale_from_path
|
21
|
-
locale = original_fullpath.split('/')
|
24
|
+
locale = original_fullpath.split('/').reject { |e| e.nil? || e == '' }.first
|
22
25
|
locale = locale_if_exists(locale)
|
23
26
|
@locale_from = 'path' if locale
|
24
27
|
locale
|
25
28
|
end
|
26
29
|
|
27
30
|
def extract_locale_from_params
|
28
|
-
return nil if params[:locale].
|
31
|
+
return nil if params[:locale].nil? || params[:locale] == ''
|
29
32
|
|
30
33
|
locale = params[:locale]
|
31
34
|
locale = locale_if_exists(locale)
|
@@ -41,7 +44,7 @@ module Bp3
|
|
41
44
|
|
42
45
|
def extract_locale_from_header
|
43
46
|
header = env['HTTP_ACCEPT_LANGUAGE']
|
44
|
-
return if header.
|
47
|
+
return if header.nil? || header == ''
|
45
48
|
|
46
49
|
languages = parse_header(header)
|
47
50
|
sorted = languages.sort_by { |_l, q| q }.reverse
|
@@ -61,12 +64,18 @@ module Bp3
|
|
61
64
|
locale
|
62
65
|
end
|
63
66
|
|
67
|
+
def default_locale
|
68
|
+
locale = I18n.default_locale
|
69
|
+
@locale_from = 'default' if locale
|
70
|
+
locale
|
71
|
+
end
|
72
|
+
|
64
73
|
# example format: 'en;q=0.1,nl'
|
65
74
|
def parse_header(header)
|
66
75
|
languages = header.split(',').map(&:strip)
|
67
76
|
languages.map do |language|
|
68
77
|
locale, quality = language.split(/\s*;\s*q\s*=\s*/i)
|
69
|
-
quality = quality.
|
78
|
+
quality = quality.nil? || quality == '' ? 1.0 : quality.to_f
|
70
79
|
[locale, quality]
|
71
80
|
end
|
72
81
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bp3-action_dispatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wim den Braven
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: actionpack
|
@@ -136,7 +135,6 @@ dependencies:
|
|
136
135
|
- - ">="
|
137
136
|
- !ruby/object:Gem::Version
|
138
137
|
version: '2.25'
|
139
|
-
description:
|
140
138
|
email:
|
141
139
|
- wimdenbraven@persuavis.com
|
142
140
|
executables: []
|
@@ -171,7 +169,6 @@ metadata:
|
|
171
169
|
source_code_uri: https://github.com/persuavis/bp3-action_dispatch
|
172
170
|
changelog_uri: https://github.com/persuavis/bp3-action_dispatch/blob/main/CHANGELOG.md
|
173
171
|
rubygems_mfa_required: 'true'
|
174
|
-
post_install_message:
|
175
172
|
rdoc_options: []
|
176
173
|
require_paths:
|
177
174
|
- lib
|
@@ -186,8 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
183
|
- !ruby/object:Gem::Version
|
187
184
|
version: '0'
|
188
185
|
requirements: []
|
189
|
-
rubygems_version: 3.
|
190
|
-
signing_key:
|
186
|
+
rubygems_version: 3.6.9
|
191
187
|
specification_version: 4
|
192
188
|
summary: bp3-action_dispatch adapts ActionDispatch::Request for BP3 (persuavis/black_phoebe_3).
|
193
189
|
test_files: []
|