dragoman 0.0.2 → 0.0.3
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/.gitignore +2 -0
- data/lib/dragoman/mapper.rb +3 -2
- data/lib/dragoman/mapper_rails3.rb +1 -1
- data/lib/dragoman/translator.rb +1 -0
- data/lib/dragoman/version.rb +1 -1
- data/spec/fixtures/config/routes.rb +20 -2
- data/spec/fixtures/locales/routes.yml +7 -0
- data/spec/routing/routes_spec.rb +19 -1
- data/spec/spec_helper.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c50f0ba55cd1b168ff9e181f96432d0a958a1fe5
|
4
|
+
data.tar.gz: ac628c72a7880a938596ed4239d7af3a6adebd66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1abbc1032a4f4a01d0cc41cdb8db0819d60bdb86b094b6c807796be7bfc674c76c1cef4e5b87b539394acc14a90329ce178ef6e70b7af39cc015c0a4d795f05e
|
7
|
+
data.tar.gz: 3d7683e61754b51c76424d92fec15cd96ec952b3345db3fe30b1f731ad317db5cbdcd29bb48f65423bc384f0df077f1387828c9b1cbf37ba365f3c8b86b6b949
|
data/.gitignore
CHANGED
data/lib/dragoman/mapper.rb
CHANGED
@@ -26,7 +26,7 @@ module Dragoman
|
|
26
26
|
|
27
27
|
def add_route_with_localization(action, options)
|
28
28
|
if @current_locale
|
29
|
-
options[:path] = Dragoman::Translator.translate_path(action, @current_locale)
|
29
|
+
options[:path] = Dragoman::Translator.translate_path(options[:path] || action, @current_locale) unless canonical_action?(action)
|
30
30
|
options[:locale] = @current_locale
|
31
31
|
end
|
32
32
|
add_route_without_localization action, options
|
@@ -37,6 +37,7 @@ module Dragoman
|
|
37
37
|
options = args.extract_options!.dup
|
38
38
|
if options[:path] || args.any?
|
39
39
|
options[:path] = Dragoman::Translator.translate_path(options[:path] || args.flatten.join('/'), @current_locale)
|
40
|
+
options[:shallow_path] = Dragoman::Translator.translate_path(options[:shallow_path], @current_locale) if options[:shallow_path]
|
40
41
|
end
|
41
42
|
scope_without_localization options, &block
|
42
43
|
else
|
@@ -47,7 +48,7 @@ module Dragoman
|
|
47
48
|
def resources_with_localization(*resources, &block)
|
48
49
|
options = resources.extract_options!.dup
|
49
50
|
if @current_locale
|
50
|
-
options[:path] = Dragoman::Translator.translate_path(resources.last, @current_locale)
|
51
|
+
options[:path] = Dragoman::Translator.translate_path(options[:path] || resources.last, @current_locale)
|
51
52
|
end
|
52
53
|
resources_without_localization(*resources, options, &block)
|
53
54
|
end
|
@@ -29,7 +29,7 @@ module Dragoman
|
|
29
29
|
|
30
30
|
def add_route_with_localization(action, options)
|
31
31
|
if @current_locale
|
32
|
-
options[:path] = Dragoman::Translator.translate_path(action, @current_locale)
|
32
|
+
options[:path] = Dragoman::Translator.translate_path(options[:path] || action, @current_locale) unless canonical_action?(action, true)
|
33
33
|
options[:locale] = @current_locale
|
34
34
|
end
|
35
35
|
add_route_without_localization action, options
|
data/lib/dragoman/translator.rb
CHANGED
data/lib/dragoman/version.rb
CHANGED
@@ -10,10 +10,28 @@ Dummy::Application.routes.draw do
|
|
10
10
|
get 'payments' => 'application#index'
|
11
11
|
end
|
12
12
|
|
13
|
-
resources :products
|
13
|
+
resources :products#, path_names: {edit: 'accept'}
|
14
14
|
resource :account
|
15
15
|
|
16
|
-
get '' => 'application#
|
16
|
+
get '' => 'application#index', as: 'empty'
|
17
|
+
|
18
|
+
namespace 'empty', path: '' do
|
19
|
+
get 'books' => 'application#index'
|
20
|
+
end
|
21
|
+
resources :invitations, only: [] do
|
22
|
+
member do
|
23
|
+
get :edit, path: 'accept'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
resources :chairs, only: :index, path: 'seats'
|
28
|
+
|
29
|
+
# shallow routes
|
30
|
+
scope 'fast', shallow_path: 'fast' do
|
31
|
+
resources :cars, :only => [:index] do
|
32
|
+
resources :drivers, :only => [:show], shallow: true
|
33
|
+
end
|
34
|
+
end
|
17
35
|
end
|
18
36
|
|
19
37
|
end
|
data/spec/routing/routes_spec.rb
CHANGED
@@ -50,6 +50,25 @@ describe 'routes' do
|
|
50
50
|
expect(empty_en_path).to eq '/'
|
51
51
|
end
|
52
52
|
|
53
|
+
it 'skips empty scopes' do
|
54
|
+
expect(empty_books_nl_path).to eq '/boeken'
|
55
|
+
expect(empty_books_en_path).to eq '/books'
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'looks up translations by the path option if present' do
|
59
|
+
expect(edit_invitation_nl_path(2)).to eq '/uitnodigingen/2/accepteren'
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'looks up resources translations by the path option if present' do
|
63
|
+
expect(chairs_nl_path).to eq '/stoelen'
|
64
|
+
expect(chairs_en_path).to eq '/seats'
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'translated shallow paths' do
|
68
|
+
expect(driver_nl_path(3)).to eq '/snelle/bestuurders/3'
|
69
|
+
expect(driver_en_path(3)).to eq '/fast/drivers/3'
|
70
|
+
end
|
71
|
+
|
53
72
|
describe 'adds untranslated path helpers' do
|
54
73
|
it 'uses the I18n locale' do
|
55
74
|
I18n.locale = :nl
|
@@ -59,7 +78,6 @@ describe 'routes' do
|
|
59
78
|
|
60
79
|
describe 'adds untranslated url helpers' do
|
61
80
|
it 'uses the I18n locale' do
|
62
|
-
print_routes
|
63
81
|
I18n.locale = :nl
|
64
82
|
expect(payments_url).to eq 'http://example.com/geheim/betalingen'
|
65
83
|
end
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pieter Visser
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-rails
|