subdomain_locale 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Isolate +9 -8
- data/Rakefile +3 -3
- data/Readme.md +10 -0
- data/lib/subdomain_locale/url_for.rb +4 -2
- data/subdomain_locale.gemspec +3 -2
- data/test/dummy/app/mailers/hello_mailer.rb +5 -3
- data/test/dummy/app/views/hello/world.html.erb +4 -4
- data/test/dummy/config/environments/test.rb +1 -1
- data/test/rails_test.rb +3 -3
- data/test/test_helper.rb +0 -5
- metadata +32 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89b4a08096b05551117c0cd44f1fcf1efb0fbf45
|
4
|
+
data.tar.gz: 74466f490964eaa00a1151cd151ce32cbf608c47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a79dfd3d19011a1201596ea65ab6681c577e75f28a16951accd081f8ae32006244f22a51608e251eb0d1047705ef27c568035077ed9883e0bc878b98b6b58358
|
7
|
+
data.tar.gz: 58b66f01b130c27d72659af4fa54d6d456dfa5c8f559f86229612a20973de3af916d2aa956547de2c3e491a7bfb7b77307cdb78055b207f5fea65f789f99708b
|
data/Isolate
CHANGED
@@ -1,25 +1,26 @@
|
|
1
1
|
options system: false, cleanup: false
|
2
2
|
|
3
3
|
gem 'bundler', '~> 1.5.0'
|
4
|
-
gem 'i18n', '~> 0.
|
4
|
+
gem 'i18n', '~> 0.7.0'
|
5
|
+
gem 'rack-test', '~> 0.6.2'
|
6
|
+
gem 'mail', '~> 2.6.0'
|
5
7
|
|
6
8
|
case ENV['RAILS']
|
7
|
-
when '3.2'
|
8
|
-
version = '~> 3.2.16'
|
9
|
-
gem 'actionpack', version
|
10
|
-
gem 'actionmailer', version
|
11
|
-
gem 'railties', version
|
12
|
-
gem 'minitest', '~> 4.2'
|
13
9
|
when '4.0'
|
14
10
|
version = '~> 4.0.0'
|
15
11
|
gem 'actionpack', version
|
16
12
|
gem 'actionmailer', version
|
17
13
|
gem 'railties', version
|
18
|
-
when
|
14
|
+
when '4.1'
|
19
15
|
version = '~> 4.1.0'
|
20
16
|
gem 'actionpack', version
|
21
17
|
gem 'actionmailer', version
|
22
18
|
gem 'railties', version
|
19
|
+
when '4.2', nil
|
20
|
+
version = '~> 4.2.0'
|
21
|
+
gem 'actionpack', version
|
22
|
+
gem 'actionmailer', version
|
23
|
+
gem 'railties', version
|
23
24
|
else
|
24
25
|
raise "Unrecognized Rails version: #{ENV['RAILS']}"
|
25
26
|
end
|
data/Rakefile
CHANGED
@@ -12,11 +12,11 @@ Rake::TestTask.new do |t|
|
|
12
12
|
end
|
13
13
|
|
14
14
|
task "test:all" do
|
15
|
-
sh "
|
15
|
+
sh({"RAILS" => "4.2"}, $0, "test")
|
16
16
|
puts
|
17
|
-
sh
|
17
|
+
sh({"RAILS" => "4.1"}, $0, "test")
|
18
18
|
puts
|
19
|
-
sh
|
19
|
+
sh({"RAILS" => "4.0"}, $0, "test")
|
20
20
|
end
|
21
21
|
|
22
22
|
task :default => :test
|
data/Readme.md
CHANGED
@@ -84,6 +84,16 @@ rake test:all
|
|
84
84
|
|
85
85
|
## Changelog
|
86
86
|
|
87
|
+
1.2.0
|
88
|
+
|
89
|
+
* Support Rails 4.2 and I18n 0.7; drop Rails 3.2.
|
90
|
+
* Note: Rails 4.2 is more strict about `_path/_url` helpers. Make sure to use `_url` helper whenever you specify locale parameter:
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
root_path(locale: :ru) # bad, will raise deprecation warning
|
94
|
+
root_url(locale: :ru) # good
|
95
|
+
```
|
96
|
+
|
87
97
|
1.1.0
|
88
98
|
|
89
99
|
* Custom subdomain provided in your default_url_options now has precedence over the default subdomain-locale.
|
@@ -7,7 +7,7 @@ module SubdomainLocale
|
|
7
7
|
# url_for params.merge(locale: 'ru') # => /ru/current_path
|
8
8
|
# After including this module:
|
9
9
|
# url_for params.merge(locale: 'ru') # => http://ru.example.com/current_path
|
10
|
-
def url_for(options)
|
10
|
+
def url_for(options, *other)
|
11
11
|
options = options.dup
|
12
12
|
if options.key?(:locale)
|
13
13
|
# Locale specified, force full URL
|
@@ -16,7 +16,7 @@ module SubdomainLocale
|
|
16
16
|
options[:only_path] = false
|
17
17
|
end
|
18
18
|
|
19
|
-
super
|
19
|
+
super(options, *other)
|
20
20
|
end
|
21
21
|
|
22
22
|
def default_url_options
|
@@ -25,6 +25,8 @@ module SubdomainLocale
|
|
25
25
|
})
|
26
26
|
end
|
27
27
|
|
28
|
+
private
|
29
|
+
|
28
30
|
def current_locale
|
29
31
|
I18n.locale
|
30
32
|
end
|
data/subdomain_locale.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "subdomain_locale"
|
5
|
-
spec.version = "1.
|
5
|
+
spec.version = "1.2.0"
|
6
6
|
spec.authors = ["Semyon Perepelitsa"]
|
7
7
|
spec.email = ["sema@sema.in"]
|
8
8
|
spec.summary = "Set I18n locale based on subdomain (Rails plugin)."
|
@@ -12,5 +12,6 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.files = File.read("Manifest.txt").split("\n")
|
13
13
|
spec.test_files = spec.files.grep(%r{^test/})
|
14
14
|
|
15
|
-
spec.add_dependency "i18n", "
|
15
|
+
spec.add_dependency "i18n", ">= 0.7.0", "< 0.8"
|
16
|
+
spec.add_dependency "railties", ">= 4.0", "< 5.0"
|
16
17
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
class HelloMailer < ActionMailer::Base
|
2
|
-
def world
|
3
|
-
|
4
|
-
f
|
2
|
+
def world(locale)
|
3
|
+
I18n.with_locale(locale) do
|
4
|
+
mail from: "app@example.com", to: "world@example.com", subject: "Hello, world!" do |f|
|
5
|
+
f.text
|
6
|
+
end
|
5
7
|
end
|
6
8
|
end
|
7
9
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<menu>
|
2
|
-
<%= link_to "Home",
|
3
|
-
<%= link_to "English",
|
4
|
-
<%= link_to "Russian",
|
5
|
-
<%= link_to "Ukrainian",
|
2
|
+
<%= link_to "Home", root_url %>
|
3
|
+
<%= link_to "English", root_url(locale: "en") %>
|
4
|
+
<%= link_to "Russian", root_url(locale: "ru") %>
|
5
|
+
<%= link_to "Ukrainian", root_url(locale: "uk") %>
|
6
6
|
<%= link_to "Beta", root_url(subdomain: "beta") %>
|
7
7
|
</menu>
|
8
8
|
|
@@ -1,7 +1,6 @@
|
|
1
1
|
Dummy::Application.configure do
|
2
2
|
config.eager_load = false
|
3
3
|
config.cache_classes = true
|
4
|
-
config.serve_static_assets = true
|
5
4
|
config.consider_all_requests_local = true
|
6
5
|
config.action_controller.perform_caching = false
|
7
6
|
config.action_dispatch.show_exceptions = false
|
@@ -9,4 +8,5 @@ Dummy::Application.configure do
|
|
9
8
|
config.active_support.deprecation = :stderr
|
10
9
|
config.action_mailer.delivery_method = :test
|
11
10
|
config.action_mailer.default_url_options = { host: "example.com" }
|
11
|
+
config.active_support.test_order = :random
|
12
12
|
end
|
data/test/rails_test.rb
CHANGED
@@ -6,7 +6,7 @@ class HelloControllerTest < ActionController::TestCase
|
|
6
6
|
@request.host = "ru.example.com"
|
7
7
|
get :world
|
8
8
|
menu = css_select("menu a")
|
9
|
-
assert_equal "/", menu[0]["href"]
|
9
|
+
assert_equal "http://example.com/", menu[0]["href"]
|
10
10
|
assert_equal "http://en.example.com/", menu[1]["href"]
|
11
11
|
assert_equal "http://example.com/", menu[2]["href"]
|
12
12
|
assert_equal "http://ua.example.com/", menu[3]["href"]
|
@@ -49,13 +49,13 @@ end
|
|
49
49
|
|
50
50
|
class HelloMailerTest < ActionController::TestCase
|
51
51
|
def test_locale_domain
|
52
|
-
mail =
|
52
|
+
mail = HelloMailer.world(:uk)
|
53
53
|
assert_equal "http://ua.example.com/", mail.body.to_s.lines[3].chomp
|
54
54
|
end
|
55
55
|
|
56
56
|
# BetaMailer overrides default_url_options
|
57
57
|
def test_custom_domain
|
58
|
-
mail =
|
58
|
+
mail = BetaMailer.world(:uk)
|
59
59
|
assert_equal "http://beta.example.com/", mail.body.to_s.lines[3].chomp
|
60
60
|
end
|
61
61
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subdomain_locale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Semyon Perepelitsa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.7.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.8'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.7.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.8'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: railties
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '4.0'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '5.0'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '4.0'
|
50
|
+
- - "<"
|
25
51
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0
|
52
|
+
version: '5.0'
|
27
53
|
description:
|
28
54
|
email:
|
29
55
|
- sema@sema.in
|