rack-user-locale 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +52 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +17 -17
- data/Rakefile +6 -32
- data/VERSION +1 -1
- data/lib/rack-user-locale.rb +1 -0
- data/lib/rack/user-locale/version.rb +7 -0
- data/rack-user-locale.gemspec +30 -79
- metadata +18 -50
- data/test/basic_rack_app.rb +0 -7
- data/test/helper.rb +0 -37
- data/test/rack-user-locale_test.rb +0 -232
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d18c409a6882027dd3ffa8c8a8fa4b3b8da8767e93309968f7ae25dc86a3934
|
4
|
+
data.tar.gz: d7b1b968cb64df8b9ad00c9262824739fcde3004d7b46d53fb5c68001e8cebaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cf20a5001d3b73cbc39df31eae4c9e5cdb14c32d31412e432fc75a59a22360d9e716c232782000c5450488b4df03777cc756012270cfc58a78591fe3a5b43b0
|
7
|
+
data.tar.gz: 4fa662d9fbeec20b5c69b09ae27084ef5f65c0d282f3110fe0a987d27c44abd7d0c905965fd8b1a84da0a91e32740b7e9e8b61fdd16476e85340e3deeda02359
|
data/.gitignore
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
coverage.data
|
4
|
+
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
|
8
|
+
# yard generated
|
9
|
+
doc
|
10
|
+
.yardoc
|
11
|
+
|
12
|
+
# bundler
|
13
|
+
.bundle
|
14
|
+
|
15
|
+
# jeweler generated
|
16
|
+
pkg
|
17
|
+
|
18
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
19
|
+
#
|
20
|
+
# * Create a file at ~/.gitignore
|
21
|
+
# * Include files you want ignored
|
22
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
23
|
+
#
|
24
|
+
# After doing this, these files will be ignored in all your git projects,
|
25
|
+
# saving you from having to 'pollute' every project you touch with them
|
26
|
+
#
|
27
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
28
|
+
#
|
29
|
+
# For MacOS:
|
30
|
+
#
|
31
|
+
.DS_Store
|
32
|
+
|
33
|
+
# For TextMate
|
34
|
+
#*.tmproj
|
35
|
+
#tmtags
|
36
|
+
|
37
|
+
# For emacs:
|
38
|
+
#*~
|
39
|
+
#\#*
|
40
|
+
#.\#*
|
41
|
+
|
42
|
+
# For vim:
|
43
|
+
#*.swp
|
44
|
+
|
45
|
+
# For redcar:
|
46
|
+
#.redcar
|
47
|
+
|
48
|
+
# For rubinius:
|
49
|
+
#*.rbc
|
50
|
+
|
51
|
+
.rvmrc
|
52
|
+
.byebug_history
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.0
|
data/Gemfile.lock
CHANGED
@@ -5,7 +5,7 @@ GEM
|
|
5
5
|
ansi (1.5.0)
|
6
6
|
builder (3.2.3)
|
7
7
|
byebug (10.0.2)
|
8
|
-
concurrent-ruby (1.
|
8
|
+
concurrent-ruby (1.1.4)
|
9
9
|
descendants_tracker (0.0.4)
|
10
10
|
thread_safe (~> 0.3, >= 0.3.1)
|
11
11
|
faraday (0.9.2)
|
@@ -20,7 +20,7 @@ GEM
|
|
20
20
|
oauth2 (~> 1.0)
|
21
21
|
hashie (3.6.0)
|
22
22
|
highline (2.0.0)
|
23
|
-
i18n (1.1
|
23
|
+
i18n (1.5.1)
|
24
24
|
concurrent-ruby (~> 1.0)
|
25
25
|
jeweler (2.3.9)
|
26
26
|
builder
|
@@ -33,18 +33,18 @@ GEM
|
|
33
33
|
rake
|
34
34
|
rdoc
|
35
35
|
semver2
|
36
|
-
jwt (1.
|
36
|
+
jwt (2.1.0)
|
37
37
|
mime-types (2.99.3)
|
38
|
-
mini_portile2 (2.
|
38
|
+
mini_portile2 (2.4.0)
|
39
39
|
minitest (5.11.3)
|
40
40
|
minitest-fail-fast (0.1.0)
|
41
41
|
minitest (~> 5)
|
42
|
-
minitest-macos-notification (0.0.
|
42
|
+
minitest-macos-notification (0.0.4)
|
43
43
|
minitest (~> 5.0)
|
44
|
-
minitest-reporters (~> 1.3
|
44
|
+
minitest-reporters (~> 1.3)
|
45
45
|
os (~> 1.0)
|
46
46
|
terminal-notifier (~> 2.0)
|
47
|
-
minitest-reporters (1.3.
|
47
|
+
minitest-reporters (1.3.5)
|
48
48
|
ansi
|
49
49
|
builder
|
50
50
|
minitest (>= 5.0)
|
@@ -52,21 +52,21 @@ GEM
|
|
52
52
|
multi_json (1.13.1)
|
53
53
|
multi_xml (0.6.0)
|
54
54
|
multipart-post (2.0.0)
|
55
|
-
nokogiri (1.
|
56
|
-
mini_portile2 (~> 2.
|
57
|
-
oauth2 (1.4.
|
58
|
-
faraday (>= 0.8, < 0.
|
59
|
-
jwt (
|
55
|
+
nokogiri (1.10.0)
|
56
|
+
mini_portile2 (~> 2.4.0)
|
57
|
+
oauth2 (1.4.1)
|
58
|
+
faraday (>= 0.8, < 0.16.0)
|
59
|
+
jwt (>= 1.0, < 3.0)
|
60
60
|
multi_json (~> 1.3)
|
61
61
|
multi_xml (~> 0.5)
|
62
62
|
rack (>= 1.2, < 3)
|
63
63
|
os (1.0.0)
|
64
|
-
psych (3.0
|
65
|
-
rack (2.0.
|
64
|
+
psych (3.1.0)
|
65
|
+
rack (2.0.6)
|
66
66
|
rack-test (1.1.0)
|
67
67
|
rack (>= 1.0, < 3)
|
68
|
-
rake (12.3.
|
69
|
-
rdoc (6.
|
68
|
+
rake (12.3.2)
|
69
|
+
rdoc (6.1.1)
|
70
70
|
ruby-progressbar (1.10.0)
|
71
71
|
semver2 (3.4.2)
|
72
72
|
terminal-notifier (2.0.0)
|
@@ -90,4 +90,4 @@ DEPENDENCIES
|
|
90
90
|
yard (~> 0.9)
|
91
91
|
|
92
92
|
BUNDLED WITH
|
93
|
-
1.
|
93
|
+
1.17.2
|
data/Rakefile
CHANGED
@@ -1,38 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
4
|
-
require "bundler"
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
warn e.message
|
9
|
-
warn "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require "rake"
|
13
|
-
|
14
|
-
require "jeweler"
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "rack-user-locale"
|
18
|
-
gem.homepage = "http://github.com/schinery/rack-user-locale"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %(Rack module for getting and setting a user's locale)
|
21
|
-
gem.description = %(A Rack module for getting and setting a user's locale via a cookie or browser default language.)
|
22
|
-
gem.email = "stuart.chinery@gmail.com"
|
23
|
-
gem.authors = ["Stuart Chinery", "Dave Hrycyszyn"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
3
|
+
require "bundler/gem_tasks"
|
28
4
|
require "rake/testtask"
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
33
10
|
end
|
34
11
|
|
35
12
|
task default: :test
|
36
|
-
|
37
|
-
require "yard"
|
38
|
-
YARD::Rake::YardocTask.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/lib/rack-user-locale.rb
CHANGED
data/rack-user-locale.gemspec
CHANGED
@@ -1,85 +1,36 @@
|
|
1
|
-
#
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: rack-user-locale 0.1.1 ruby lib
|
1
|
+
# frozen_string_literal: true
|
6
2
|
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "rack/user-locale/version"
|
10
6
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
s.email = "stuart.chinery@gmail.com".freeze
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE.txt",
|
19
|
-
"README.md"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".document",
|
23
|
-
".rubocop.yml",
|
24
|
-
".ruby-version",
|
25
|
-
".travis.yml",
|
26
|
-
"Gemfile",
|
27
|
-
"Gemfile.lock",
|
28
|
-
"LICENSE.txt",
|
29
|
-
"README.md",
|
30
|
-
"Rakefile",
|
31
|
-
"VERSION",
|
32
|
-
"lib/rack-user-locale.rb",
|
33
|
-
"rack-user-locale.gemspec",
|
34
|
-
"test/basic_rack_app.rb",
|
35
|
-
"test/helper.rb",
|
36
|
-
"test/rack-user-locale_test.rb"
|
37
|
-
]
|
38
|
-
s.homepage = "http://github.com/schinery/rack-user-locale".freeze
|
39
|
-
s.licenses = ["MIT".freeze]
|
40
|
-
s.rubygems_version = "2.7.7".freeze
|
41
|
-
s.summary = "Rack module for getting and setting a user's locale".freeze
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "rack-user-locale"
|
9
|
+
spec.version = Rack::UserLocale::VERSION
|
10
|
+
spec.authors = ["Stuart Chinery"]
|
11
|
+
spec.email = ["stuart.chinery@gmail.com"]
|
42
12
|
|
43
|
-
|
44
|
-
|
13
|
+
spec.summary = "A Rack module for getting and setting a user's locale"
|
14
|
+
spec.description = "A Rack module for getting and setting a user's locale via a cookie or browser default language."
|
15
|
+
spec.homepage = "https://github.com/schinery/rack-user-locale"
|
16
|
+
spec.license = "MIT"
|
45
17
|
|
46
|
-
|
47
|
-
|
48
|
-
s.add_runtime_dependency(%q<rack>.freeze, [">= 0"])
|
49
|
-
s.add_development_dependency(%q<bundler>.freeze, ["~> 1.16"])
|
50
|
-
s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
|
51
|
-
s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3"])
|
52
|
-
s.add_development_dependency(%q<minitest>.freeze, ["~> 5.0"])
|
53
|
-
s.add_development_dependency(%q<minitest-fail-fast>.freeze, ["~> 0.1"])
|
54
|
-
s.add_development_dependency(%q<minitest-macos-notification>.freeze, ["~> 0"])
|
55
|
-
s.add_development_dependency(%q<minitest-reporters>.freeze, ["~> 1.3"])
|
56
|
-
s.add_development_dependency(%q<rack-test>.freeze, ["~> 1.1"])
|
57
|
-
s.add_development_dependency(%q<yard>.freeze, ["~> 0.9"])
|
58
|
-
else
|
59
|
-
s.add_dependency(%q<i18n>.freeze, [">= 0"])
|
60
|
-
s.add_dependency(%q<rack>.freeze, [">= 0"])
|
61
|
-
s.add_dependency(%q<bundler>.freeze, ["~> 1.16"])
|
62
|
-
s.add_dependency(%q<byebug>.freeze, [">= 0"])
|
63
|
-
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3"])
|
64
|
-
s.add_dependency(%q<minitest>.freeze, ["~> 5.0"])
|
65
|
-
s.add_dependency(%q<minitest-fail-fast>.freeze, ["~> 0.1"])
|
66
|
-
s.add_dependency(%q<minitest-macos-notification>.freeze, ["~> 0"])
|
67
|
-
s.add_dependency(%q<minitest-reporters>.freeze, ["~> 1.3"])
|
68
|
-
s.add_dependency(%q<rack-test>.freeze, ["~> 1.1"])
|
69
|
-
s.add_dependency(%q<yard>.freeze, ["~> 0.9"])
|
70
|
-
end
|
71
|
-
else
|
72
|
-
s.add_dependency(%q<i18n>.freeze, [">= 0"])
|
73
|
-
s.add_dependency(%q<rack>.freeze, [">= 0"])
|
74
|
-
s.add_dependency(%q<bundler>.freeze, ["~> 1.16"])
|
75
|
-
s.add_dependency(%q<byebug>.freeze, [">= 0"])
|
76
|
-
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3"])
|
77
|
-
s.add_dependency(%q<minitest>.freeze, ["~> 5.0"])
|
78
|
-
s.add_dependency(%q<minitest-fail-fast>.freeze, ["~> 0.1"])
|
79
|
-
s.add_dependency(%q<minitest-macos-notification>.freeze, ["~> 0"])
|
80
|
-
s.add_dependency(%q<minitest-reporters>.freeze, ["~> 1.3"])
|
81
|
-
s.add_dependency(%q<rack-test>.freeze, ["~> 1.1"])
|
82
|
-
s.add_dependency(%q<yard>.freeze, ["~> 0.9"])
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
83
20
|
end
|
84
|
-
end
|
85
21
|
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency "i18n", "~> 0"
|
27
|
+
spec.add_dependency "rack", "~> 0"
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
30
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
31
|
+
spec.add_development_dependency "minitest-fail-fast", "~> 0.1"
|
32
|
+
spec.add_development_dependency "minitest-macos-notification", "~> 0"
|
33
|
+
spec.add_development_dependency "minitest-reporters", "~> 1.3"
|
34
|
+
spec.add_development_dependency "rack-test", "~> 1.1"
|
35
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
36
|
+
end
|
metadata
CHANGED
@@ -1,42 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-user-locale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stuart Chinery
|
8
|
-
- Dave Hrycyszyn
|
9
8
|
autorequire:
|
10
|
-
bindir:
|
9
|
+
bindir: exe
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2019-01-07 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: i18n
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
16
|
requirements:
|
18
|
-
- - "
|
17
|
+
- - "~>"
|
19
18
|
- !ruby/object:Gem::Version
|
20
19
|
version: '0'
|
21
20
|
type: :runtime
|
22
21
|
prerelease: false
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
24
23
|
requirements:
|
25
|
-
- - "
|
24
|
+
- - "~>"
|
26
25
|
- !ruby/object:Gem::Version
|
27
26
|
version: '0'
|
28
27
|
- !ruby/object:Gem::Dependency
|
29
28
|
name: rack
|
30
29
|
requirement: !ruby/object:Gem::Requirement
|
31
30
|
requirements:
|
32
|
-
- - "
|
31
|
+
- - "~>"
|
33
32
|
- !ruby/object:Gem::Version
|
34
33
|
version: '0'
|
35
34
|
type: :runtime
|
36
35
|
prerelease: false
|
37
36
|
version_requirements: !ruby/object:Gem::Requirement
|
38
37
|
requirements:
|
39
|
-
- - "
|
38
|
+
- - "~>"
|
40
39
|
- !ruby/object:Gem::Version
|
41
40
|
version: '0'
|
42
41
|
- !ruby/object:Gem::Dependency
|
@@ -53,34 +52,6 @@ dependencies:
|
|
53
52
|
- - "~>"
|
54
53
|
- !ruby/object:Gem::Version
|
55
54
|
version: '1.16'
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: byebug
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: jeweler
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - "~>"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '2.3'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - "~>"
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '2.3'
|
84
55
|
- !ruby/object:Gem::Dependency
|
85
56
|
name: minitest
|
86
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,29 +123,29 @@ dependencies:
|
|
152
123
|
- !ruby/object:Gem::Version
|
153
124
|
version: '1.1'
|
154
125
|
- !ruby/object:Gem::Dependency
|
155
|
-
name:
|
126
|
+
name: rake
|
156
127
|
requirement: !ruby/object:Gem::Requirement
|
157
128
|
requirements:
|
158
129
|
- - "~>"
|
159
130
|
- !ruby/object:Gem::Version
|
160
|
-
version: '0
|
131
|
+
version: '12.0'
|
161
132
|
type: :development
|
162
133
|
prerelease: false
|
163
134
|
version_requirements: !ruby/object:Gem::Requirement
|
164
135
|
requirements:
|
165
136
|
- - "~>"
|
166
137
|
- !ruby/object:Gem::Version
|
167
|
-
version: '0
|
138
|
+
version: '12.0'
|
168
139
|
description: A Rack module for getting and setting a user's locale via a cookie or
|
169
140
|
browser default language.
|
170
|
-
email:
|
141
|
+
email:
|
142
|
+
- stuart.chinery@gmail.com
|
171
143
|
executables: []
|
172
144
|
extensions: []
|
173
|
-
extra_rdoc_files:
|
174
|
-
- LICENSE.txt
|
175
|
-
- README.md
|
145
|
+
extra_rdoc_files: []
|
176
146
|
files:
|
177
147
|
- ".document"
|
148
|
+
- ".gitignore"
|
178
149
|
- ".rubocop.yml"
|
179
150
|
- ".ruby-version"
|
180
151
|
- ".travis.yml"
|
@@ -185,11 +156,9 @@ files:
|
|
185
156
|
- Rakefile
|
186
157
|
- VERSION
|
187
158
|
- lib/rack-user-locale.rb
|
159
|
+
- lib/rack/user-locale/version.rb
|
188
160
|
- rack-user-locale.gemspec
|
189
|
-
|
190
|
-
- test/helper.rb
|
191
|
-
- test/rack-user-locale_test.rb
|
192
|
-
homepage: http://github.com/schinery/rack-user-locale
|
161
|
+
homepage: https://github.com/schinery/rack-user-locale
|
193
162
|
licenses:
|
194
163
|
- MIT
|
195
164
|
metadata: {}
|
@@ -208,9 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
177
|
- !ruby/object:Gem::Version
|
209
178
|
version: '0'
|
210
179
|
requirements: []
|
211
|
-
|
212
|
-
rubygems_version: 2.7.7
|
180
|
+
rubygems_version: 3.0.1
|
213
181
|
signing_key:
|
214
182
|
specification_version: 4
|
215
|
-
summary: Rack module for getting and setting a user's locale
|
183
|
+
summary: A Rack module for getting and setting a user's locale
|
216
184
|
test_files: []
|
data/test/basic_rack_app.rb
DELETED
data/test/helper.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rubygems"
|
4
|
-
require "bundler"
|
5
|
-
require "rack/test"
|
6
|
-
|
7
|
-
begin
|
8
|
-
Bundler.setup(:default, :development)
|
9
|
-
rescue Bundler::BundlerError => e
|
10
|
-
warn e.message
|
11
|
-
warn "Run `bundle install` to install missing gems"
|
12
|
-
exit e.status_code
|
13
|
-
end
|
14
|
-
|
15
|
-
require "minitest/autorun"
|
16
|
-
require "minitest/fail_fast"
|
17
|
-
require "minitest/macos_notification"
|
18
|
-
require "minitest/reporters"
|
19
|
-
require "minitest/spec"
|
20
|
-
|
21
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
22
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
23
|
-
require "rack-user-locale"
|
24
|
-
|
25
|
-
class Minitest::Test
|
26
|
-
extend Minitest::Spec::DSL
|
27
|
-
include Rack::Test::Methods
|
28
|
-
end
|
29
|
-
|
30
|
-
Minitest::Reporters.use!(
|
31
|
-
[
|
32
|
-
Minitest::Reporters::SpecReporter.new,
|
33
|
-
Minitest::Reporters::MacosNotificationReporter.new(title: "Rack::UserLocale Gem")
|
34
|
-
],
|
35
|
-
ENV,
|
36
|
-
Minitest.backtrace_filter
|
37
|
-
)
|
@@ -1,232 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "helper"
|
4
|
-
require "basic_rack_app"
|
5
|
-
require "byebug"
|
6
|
-
|
7
|
-
class RackUserLocaleTest < Minitest::Test
|
8
|
-
describe Rack::UserLocale do
|
9
|
-
before do
|
10
|
-
I18n.enforce_available_locales = false
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "without accepted_locales set" do
|
14
|
-
before do
|
15
|
-
def app
|
16
|
-
Rack::Builder.new do
|
17
|
-
use Rack::UserLocale
|
18
|
-
|
19
|
-
run BasicRackApp.new
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
I18n.default_locale = :en
|
24
|
-
I18n.locale = :en
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should have I18n.locale set to :en" do
|
28
|
-
assert_equal :en, I18n.locale
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "when a locale cookie is set" do
|
32
|
-
before do
|
33
|
-
get "http://example.com/", {}, "HTTP_COOKIE" => "user-locale=be"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should have I18n.locale set to :be" do
|
37
|
-
assert_equal :be, I18n.locale
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should not set a cookie in the response" do
|
41
|
-
assert_equal nil, last_response["Set-Cookie"]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "when from HTTP_ACCEPT_LANGUAGE headers" do
|
46
|
-
describe "with a single locale" do
|
47
|
-
before do
|
48
|
-
get "http://example.com/", {}, "HTTP_ACCEPT_LANGUAGE" => "fr-be", "SCRIPT_NAME" => "/"
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should have I18n.locale set to :fr" do
|
52
|
-
assert_equal :fr, I18n.locale
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should set a cookie in the response" do
|
56
|
-
assert_equal "user-locale=fr; path=/", last_response["Set-Cookie"]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "with an multiple locales" do
|
61
|
-
before do
|
62
|
-
get "http://example.com/", {},
|
63
|
-
"HTTP_ACCEPT_LANGUAGE" => "de-DE;q=0.8,de;q=0.8,no-NO;q=1.0,no;q=0.7,ru-RU;q=0.7,sv-SE;q=0.4,sv;q=0.3,nl-BE;q=0.9",
|
64
|
-
"SCRIPT_NAME" => "/"
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should have I18n.locale set to :no" do
|
68
|
-
assert_equal :no, I18n.locale
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should set a cookie in the response" do
|
72
|
-
assert_equal "user-locale=no; path=/", last_response["Set-Cookie"]
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "when both a cooke and HTTP_ACCEPT_LANGUAGE headers are set" do
|
78
|
-
before do
|
79
|
-
get "http://example.com/", {}, "HTTP_COOKIE" => "user-locale=af",
|
80
|
-
"HTTP_ACCEPT_LANGUAGE" => "ar-sa", "SCRIPT_NAME" => "/"
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should have I18n.locale set to :af" do
|
84
|
-
assert_equal :af, I18n.locale
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should not set a cookie in the response" do
|
88
|
-
assert_equal nil, last_response["Set-Cookie"]
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "when nothing is changed" do
|
93
|
-
before do
|
94
|
-
get "http://example.com/", {}, "SCRIPT_NAME" => "/"
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should have I18n.locale set to :en" do
|
98
|
-
assert_equal :en, I18n.locale
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should set a cookie in the response" do
|
102
|
-
assert_equal "user-locale=en; path=/", last_response["Set-Cookie"]
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "with accepted_locales set" do
|
108
|
-
before do
|
109
|
-
def app
|
110
|
-
Rack::Builder.new do
|
111
|
-
use Rack::UserLocale, accepted_locales: %i[en es fr de ja nl]
|
112
|
-
|
113
|
-
run BasicRackApp.new
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
I18n.default_locale = :en
|
118
|
-
I18n.locale = :en
|
119
|
-
end
|
120
|
-
|
121
|
-
it "should have I18n.locale set to :en" do
|
122
|
-
assert_equal :en, I18n.locale
|
123
|
-
end
|
124
|
-
|
125
|
-
describe "when a locale cookie is set" do
|
126
|
-
before do
|
127
|
-
get "http://example.com/", {}, "HTTP_COOKIE" => "user-locale=es", "SCRIPT_NAME" => "/"
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should have I18n.locale set to :es" do
|
131
|
-
assert_equal :es, I18n.locale
|
132
|
-
end
|
133
|
-
|
134
|
-
it "should not set a cookie in the response" do
|
135
|
-
assert_equal nil, last_response["Set-Cookie"]
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe "when from HTTP_ACCEPT_LANGUAGE headers" do
|
140
|
-
describe "with an accepted locale" do
|
141
|
-
before do
|
142
|
-
get "http://example.com/", {}, "HTTP_ACCEPT_LANGUAGE" => "fr-be", "SCRIPT_NAME" => "/"
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should have I18n.locale set to :fr" do
|
146
|
-
assert_equal :fr, I18n.locale
|
147
|
-
end
|
148
|
-
|
149
|
-
it "should set a cookie in the response" do
|
150
|
-
assert_equal "user-locale=fr; path=/", last_response["Set-Cookie"]
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe "with an multiple locales" do
|
155
|
-
describe "at different weights" do
|
156
|
-
before do
|
157
|
-
get "http://example.com/", {},
|
158
|
-
"HTTP_ACCEPT_LANGUAGE" => "de-DE;q=0.8,de;q=0.8,no-NO;q=0.7,no;q=0.7,ru-RU;q=0.7,sv-SE;q=0.4,sv;q=0.3,nl-BE;q=0.9",
|
159
|
-
"SCRIPT_NAME" => "/"
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should have I18n.locale set to :nl" do
|
163
|
-
assert_equal :nl, I18n.locale
|
164
|
-
end
|
165
|
-
|
166
|
-
it "should set a cookie in the response" do
|
167
|
-
assert_equal "user-locale=nl; path=/", last_response["Set-Cookie"]
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe "at the same weight" do
|
172
|
-
before do
|
173
|
-
get "http://example.com/", {},
|
174
|
-
"HTTP_ACCEPT_LANGUAGE" => "fr,en,ja", "SCRIPT_NAME" => "/"
|
175
|
-
end
|
176
|
-
|
177
|
-
it "should have I18n.locale set to :fr" do
|
178
|
-
assert_equal :fr, I18n.locale
|
179
|
-
end
|
180
|
-
|
181
|
-
it "should set a cookie in the response" do
|
182
|
-
assert_equal "user-locale=fr; path=/", last_response["Set-Cookie"]
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
describe "without an accepted locale" do
|
188
|
-
before do
|
189
|
-
get "http://example.com/", {}, "HTTP_ACCEPT_LANGUAGE" => "ar-sa", "SCRIPT_NAME" => "/"
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should have I18n.locale set to :en" do
|
193
|
-
assert_equal :en, I18n.locale
|
194
|
-
end
|
195
|
-
|
196
|
-
it "should set a cookie in the response" do
|
197
|
-
assert_equal "user-locale=en; path=/", last_response["Set-Cookie"]
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
describe "when both a cooke and HTTP_ACCEPT_LANGUAGE headers are set" do
|
203
|
-
before do
|
204
|
-
get "http://example.com/", {}, "HTTP_COOKIE" => "user-locale=ja",
|
205
|
-
"HTTP_ACCEPT_LANGUAGE" => "fr-be", "SCRIPT_NAME" => "/"
|
206
|
-
end
|
207
|
-
|
208
|
-
it "should have I18n.locale set to :ja" do
|
209
|
-
assert_equal :ja, I18n.locale
|
210
|
-
end
|
211
|
-
|
212
|
-
it "should not set a cookie in the response" do
|
213
|
-
assert_equal nil, last_response["Set-Cookie"]
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
describe "when nothing is changed" do
|
218
|
-
before do
|
219
|
-
get "http://example.com/", {}, "SCRIPT_NAME" => "/"
|
220
|
-
end
|
221
|
-
|
222
|
-
it "should have I18n.locale set to :en" do
|
223
|
-
assert_equal :en, I18n.locale
|
224
|
-
end
|
225
|
-
|
226
|
-
it "should set a cookie in the response" do
|
227
|
-
assert_equal "user-locale=en; path=/", last_response["Set-Cookie"]
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|