bp3-action_dispatch 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +38 -34
- data/lib/bp3/action_dispatch/request_locale.rb +14 -5
- data/lib/bp3/action_dispatch/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a83f6c1e661ae30a16db2f0e917cdb20f6b05e01c31df9382b5f6fccbc37507b
|
4
|
+
data.tar.gz: 4caf8ea58b59eef52f4a095815bcb8f29636e7f14513599e50c45092fa2865b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bde24835bc1109b7ee9411c7a61c72f20c2afe45ff7ad31b24d098a08b7f23d06cf73688f2d53ec99456eff769aae1c0409eca7a9acb8fa33e47d8eeb86b2042
|
7
|
+
data.tar.gz: dff7c0b3c30f34e5ef8126e691092815aca057144039e88bb2780ffe0408fc2a6eda5c14fe2ea33533461fe96bf97abffc5422c33c808cb67b4f3761c55e459d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.4] - 2025-01-27
|
4
|
+
|
5
|
+
- Increase robustness of path parsing
|
6
|
+
- handle cases with '//' in the path (blank path segments)
|
7
|
+
- return default locale as fallback
|
8
|
+
|
3
9
|
## [0.1.3] - 2024-11-18
|
4
10
|
|
5
11
|
- 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.4)
|
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,37 @@ 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
|
124
128
|
|
125
129
|
DEPENDENCIES
|
126
130
|
bp3-action_dispatch!
|
@@ -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,14 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wim den Braven
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
- !ruby/object:Gem::Version
|
187
187
|
version: '0'
|
188
188
|
requirements: []
|
189
|
-
rubygems_version: 3.5.
|
189
|
+
rubygems_version: 3.5.23
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: bp3-action_dispatch adapts ActionDispatch::Request for BP3 (persuavis/black_phoebe_3).
|