dragoman 0.0.10 → 0.0.11
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 +5 -13
- data/lib/dragoman/mapper.rb +7 -2
- data/lib/dragoman/route_set.rb +2 -2
- data/lib/dragoman/version.rb +1 -1
- data/spec/fake_app.rb +1 -0
- data/spec/routing/routes_spec.rb +22 -22
- data/spec/spec_helper.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YzRkZmRjNzg1MTQ2ODAyODAyM2Q4OTFmZmE3NjliZDc4MGM0NWE1ZA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a00d94d070f03449aaa0a78c015073607b8486a
|
4
|
+
data.tar.gz: 06d2ba3a8a7d8092c83b3e15b4285611ffc6613a
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
OGZkNWFmYmUyNTk3N2U1YzUyY2FkMjlhZGU3NTU0MGYzOTUzNjY4NDdkMmQ3
|
11
|
-
ZDNkNjVmZDk2NjVjNTdkNjhjMGIwMzNmN2I1OGRhNjY4NWY1MTM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YmZkYjM3ZWE2N2Q2NGJmMWQ0NjUyZTZiZTc5MDA0OTA0NjAxZDVjOTllNDBm
|
14
|
-
ZjdlZDkyM2VlMDBjYzhkYTIzOTgxOGVmNmQwODY0ZDIyYmQyZjZkYzdiYzdl
|
15
|
-
Njg0ZDQ5ODllZjhiNDBhMDYyNDJiZjdiYjJkMjI2NjA5MmM0N2Q=
|
6
|
+
metadata.gz: 9824500a664c5dfee10542aba3807ea35241cd4443d870fa079af2ff01aa4ae08555f7ea70cfbfe4c3625e58797018b441913dbcb121b967427bdca0667f66ef
|
7
|
+
data.tar.gz: d521c7b1ff4f5d161e244e86f4b866ff6da5596803cf4ad2ec64fdb1ae9feddd62dffe55991c9c1b5179c686753ec17ba2a475d36679dd389dd2670ff590ea74
|
data/lib/dragoman/mapper.rb
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
module Dragoman
|
2
2
|
module Mapper
|
3
3
|
def localize
|
4
|
-
|
5
|
-
|
4
|
+
locales = I18n.available_locales
|
5
|
+
unscoped_locales = [I18n.default_locale]
|
6
|
+
scoped_locales = locales - unscoped_locales
|
7
|
+
scope ':locale', shallow_path: ':locale', defaults: {dragoman_options: {locales: scoped_locales}} do
|
8
|
+
yield
|
9
|
+
end
|
10
|
+
defaults dragoman_options: {locales: unscoped_locales} do
|
6
11
|
yield
|
7
12
|
end
|
8
13
|
@locales = nil
|
data/lib/dragoman/route_set.rb
CHANGED
@@ -23,8 +23,8 @@ module Dragoman
|
|
23
23
|
new_conditions[:path_info] = new_path
|
24
24
|
new_conditions[:parsed_path_info] = Dragoman::Journey::Parser.new.parse new_path if new_conditions[:parsed_path_info]
|
25
25
|
end
|
26
|
-
new_requirements[:locale] = locale
|
27
|
-
new_defaults[:locale] = locale
|
26
|
+
new_requirements[:locale] = locale.to_s
|
27
|
+
new_defaults[:locale] = locale.to_s
|
28
28
|
add_route_without_localization app, new_conditions, new_requirements, new_defaults, new_name, anchor
|
29
29
|
end
|
30
30
|
else
|
data/lib/dragoman/version.rb
CHANGED
data/spec/fake_app.rb
CHANGED
@@ -14,6 +14,7 @@ module Dummy
|
|
14
14
|
config.paths["config/locales"] = ["spec/fixtures/locales/routes.yml"]
|
15
15
|
config.eager_load = false
|
16
16
|
config.i18n.fallbacks = true
|
17
|
+
config.i18n.default_locale = :nl
|
17
18
|
|
18
19
|
if Dummy.rails4?
|
19
20
|
config.paths["config/routes.rb"] = ["spec/fixtures/config/routes.rb"]
|
data/spec/routing/routes_spec.rb
CHANGED
@@ -16,80 +16,80 @@ describe 'routes' do
|
|
16
16
|
expect(products_en_path).to eq '/en/products'
|
17
17
|
expect(new_product_en_path).to eq '/en/products/new'
|
18
18
|
expect(edit_product_en_path(id: 1)).to eq '/en/products/1/edit'
|
19
|
-
expect(products_nl_path).to eq '/
|
20
|
-
expect(new_product_nl_path).to eq '/
|
21
|
-
expect(edit_product_nl_path(id: 1)).to eq '/
|
19
|
+
expect(products_nl_path).to eq '/producten'
|
20
|
+
expect(new_product_nl_path).to eq '/producten/nieuw'
|
21
|
+
expect(edit_product_nl_path(id: 1)).to eq '/producten/1/wijzigen'
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'translates resource' do
|
25
25
|
expect(account_en_path).to eq '/en/account'
|
26
26
|
expect(edit_account_en_path).to eq '/en/account/edit'
|
27
27
|
expect(new_account_en_path).to eq '/en/account/new'
|
28
|
-
expect(account_nl_path).to eq '/
|
29
|
-
expect(edit_account_nl_path).to eq '/
|
30
|
-
expect(new_account_nl_path).to eq '/
|
28
|
+
expect(account_nl_path).to eq '/profiel'
|
29
|
+
expect(edit_account_nl_path).to eq '/profiel/wijzigen'
|
30
|
+
expect(new_account_nl_path).to eq '/profiel/nieuw'
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'translates namespaced routes' do
|
34
|
-
expect(admin_customers_nl_path).to eq '/
|
34
|
+
expect(admin_customers_nl_path).to eq '/beheer/klanten'
|
35
35
|
expect(admin_customers_en_path).to eq '/en/admin/customers'
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'translates scoped routes' do
|
39
|
-
expect(payments_nl_path).to eq '/
|
39
|
+
expect(payments_nl_path).to eq '/geheim/betalingen'
|
40
40
|
expect(payments_en_path).to eq '/en/secret/payments'
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'sets the correct locale' do
|
44
|
-
expect(get: '/
|
45
|
-
expect(get: '/
|
44
|
+
expect(get: '/producten').to route_to(controller: 'products', action: 'index', locale: 'nl')
|
45
|
+
expect(get: '/products').not_to be_routable
|
46
46
|
expect(get: '/products').not_to be_routable
|
47
47
|
expect(get: '/en/products').to route_to(controller: 'products', action: 'index', locale: 'en')
|
48
48
|
expect(get: '/en/producten').not_to be_routable
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'skips empty paths' do
|
52
|
-
expect(empty_nl_path).to eq '/
|
52
|
+
expect(empty_nl_path).to eq '/'
|
53
53
|
expect(empty_en_path).to eq '/en'
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'skips empty scopes' do
|
57
|
-
expect(empty_books_nl_path).to eq '/
|
57
|
+
expect(empty_books_nl_path).to eq '/boeken'
|
58
58
|
expect(empty_books_en_path).to eq '/en/books'
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'looks up translations by the path option if present' do
|
62
|
-
expect(edit_invitation_nl_path(id: 2)).to eq '/
|
62
|
+
expect(edit_invitation_nl_path(id: 2)).to eq '/uitnodigingen/2/accepteren'
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'looks up resources translations by the path option if present' do
|
66
|
-
expect(chairs_nl_path).to eq '/
|
66
|
+
expect(chairs_nl_path).to eq '/stoelen'
|
67
67
|
expect(chairs_en_path).to eq '/en/seats'
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'translates shallow paths' do
|
71
|
-
expect(driver_nl_path(id: 3)).to eq '/
|
71
|
+
expect(driver_nl_path(id: 3)).to eq '/snelle/bestuurders/3'
|
72
72
|
expect(driver_en_path(id: 3)).to eq '/en/fast/drivers/3'
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'skips blank translations' do
|
76
|
-
expect(music_nl_path).to eq '/
|
76
|
+
expect(music_nl_path).to eq '/music'
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'uses the default path if no translation is present' do
|
80
80
|
expect(sounds_en_path).to eq '/en/glitches'
|
81
|
-
expect(sounds_nl_path).to eq '/
|
81
|
+
expect(sounds_nl_path).to eq '/sounds'
|
82
82
|
end
|
83
83
|
|
84
84
|
it 'translates routes in the original order as specified in routes.rb' do
|
85
85
|
expect(get: '/en/votes/positive').to route_to(action: 'positive', controller: 'votes', locale: 'en')
|
86
|
-
expect(get: '/
|
86
|
+
expect(get: '/votes/positief').to route_to(action: 'positive', controller: 'votes', locale: 'nl') # should use 'positive' action instead of 'show'
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'uses the I18n locale to add untranslated path helpers' do
|
90
90
|
I18n.locale = :nl
|
91
|
-
expect(product_path(id: 1)).to eq '/
|
92
|
-
expect(payments_path).to eq '/
|
91
|
+
expect(product_path(id: 1)).to eq '/producten/1'
|
92
|
+
expect(payments_path).to eq '/geheim/betalingen'
|
93
93
|
|
94
94
|
I18n.locale = :en
|
95
95
|
expect(product_path(id: 1)).to eq '/en/products/1'
|
@@ -98,8 +98,8 @@ describe 'routes' do
|
|
98
98
|
|
99
99
|
it 'uses the I18n locale to add untranslated url helpers' do
|
100
100
|
I18n.locale = :nl
|
101
|
-
expect(product_url(id: 1)).to eq 'http://example.com/
|
102
|
-
expect(payments_url).to eq 'http://example.com/
|
101
|
+
expect(product_url(id: 1)).to eq 'http://example.com/producten/1'
|
102
|
+
expect(payments_url).to eq 'http://example.com/geheim/betalingen'
|
103
103
|
|
104
104
|
I18n.locale = :en
|
105
105
|
expect(product_url(id: 1)).to eq 'http://example.com/en/products/1'
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragoman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pieter Visser
|
@@ -9,34 +9,34 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - '>='
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: guard-rspec
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
description:
|
@@ -82,17 +82,17 @@ require_paths:
|
|
82
82
|
- lib
|
83
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- -
|
85
|
+
- - '>='
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: '0'
|
88
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
89
|
requirements:
|
90
|
-
- -
|
90
|
+
- - '>='
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.4.
|
95
|
+
rubygems_version: 2.4.7
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Simple Rails Routes Translator
|