route_translator 5.0.4 → 5.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 082c2e8186923d0e715cc9540942a23fc09a9f85
4
- data.tar.gz: 41803873b2329a079d55cc1cc3251402f7c0dfc1
3
+ metadata.gz: b3b566e8efb88b086812e1308e50a25a665b5b1a
4
+ data.tar.gz: 43ba2e28fd4e1b24b3451c54e8aae47ad4961693
5
5
  SHA512:
6
- metadata.gz: 7b78458687cdaba7cd60f658f5973319f1cb05240db25be435446bdcba0a198d0555fc44f1da5bbe334c97ca8c5a9050a690339ddcad88c7a44c03778e02c3d1
7
- data.tar.gz: 5d0a9e7baec151c0bcfe7cd26b3ef166d8e5bb18c22e63d931f13f5adb0ebc7c433551cbddd7b9965821de58970c92b7922e9834b4fdb540e5036dc727ad72a9
6
+ metadata.gz: 5588fc472c0c4b192b7610e8a31091fbdaa93c9ba57749e8e281d10744537f52f3a24a8e913837bb83ad2f3230cf8c950ba0e709977da332204376b050cd2bec
7
+ data.tar.gz: fe53b0f81af8176c9f1cf53d07b869b0a18da4d3bbe09a29f7868faedcd3416e2999557b9b2b95a17dca1ad48f5632b5e59704050cb2bc60d40ef46bde6f3bf3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.5 (2016-12-15)
4
+
5
+ * Fix generated prefix to localized one (#123)
6
+ * Improve Mapper's monkey patch
7
+
3
8
  ## 5.0.4 (2016-11-11)
4
9
 
5
10
  * Retain value of options_constraints if callable
@@ -10,8 +10,11 @@ module ActionDispatch
10
10
  @localized = false
11
11
  end
12
12
 
13
- def add_route(action, controller, options, original_path, to, via, formatted, anchor, options_constraints) # :nodoc:
14
- path = path_for_action(action, original_path)
13
+ # rubocop:disable Lint/UnderscorePrefixedVariableName
14
+ def add_route(action, controller, options, _path, to, via, formatted, anchor, options_constraints) # :nodoc:
15
+ return super unless @localized
16
+
17
+ path = path_for_action(action, _path)
15
18
  raise ArgumentError, 'path is required' if path.blank?
16
19
 
17
20
  action = action.to_s
@@ -35,10 +38,17 @@ module ActionDispatch
35
38
 
36
39
  mapping = Mapping.build(@scope, @set, ast, controller, default_action, to, via, formatted, options_constraints, anchor, options)
37
40
 
38
- if @localized
39
- @set.add_localized_route(mapping, ast, as, anchor, @scope, path, controller, default_action, to, via, formatted, options_constraints, options)
40
- else
41
- @set.add_route(mapping, ast, as, anchor)
41
+ @set.add_localized_route(mapping, ast, as, anchor, @scope, path, controller, default_action, to, via, formatted, options_constraints, options)
42
+ end
43
+ # rubocop:enable Lint/UnderscorePrefixedVariableName
44
+
45
+ private
46
+
47
+ def define_generate_prefix(app, name)
48
+ return super unless @localized
49
+
50
+ RouteTranslator::Translator.available_locales.each do |locale|
51
+ super(app, "#{name}_#{locale.to_s.underscore}")
42
52
  end
43
53
  end
44
54
  end
@@ -8,16 +8,6 @@ module RouteTranslator
8
8
  class << self
9
9
  private
10
10
 
11
- def available_locales
12
- locales = RouteTranslator.available_locales
13
- locales.concat(RouteTranslator.native_locales) if RouteTranslator.native_locales.present?
14
- # Make sure the default locale is translated in last place to avoid
15
- # problems with wildcards when default locale is omitted in paths. The
16
- # default routes will catch all paths like wildcard if it is translated first.
17
- locales.delete I18n.default_locale
18
- locales.push I18n.default_locale
19
- end
20
-
21
11
  def host_locales_option?
22
12
  RouteTranslator.config.host_locales.present?
23
13
  end
@@ -35,6 +25,16 @@ module RouteTranslator
35
25
 
36
26
  module_function
37
27
 
28
+ def available_locales
29
+ locales = RouteTranslator.available_locales
30
+ locales.concat(RouteTranslator.native_locales) if RouteTranslator.native_locales.present?
31
+ # Make sure the default locale is translated in last place to avoid
32
+ # problems with wildcards when default locale is omitted in paths. The
33
+ # default routes will catch all paths like wildcard if it is translated first.
34
+ locales.delete I18n.default_locale
35
+ locales.push I18n.default_locale
36
+ end
37
+
38
38
  def translations_for(route_set, path, name, options_constraints, options)
39
39
  RouteTranslator::Translator::RouteHelpers.add name, route_set.named_routes
40
40
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module RouteTranslator
3
- VERSION = '5.0.4'.freeze
3
+ VERSION = '5.0.5'.freeze
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: route_translator
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.4
4
+ version: 5.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geremia Taglialatela
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-11-11 00:00:00.000000000 Z
13
+ date: 2016-12-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.8.15
89
+ version: 0.8.17
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.8.15
96
+ version: 0.8.17
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: minitest
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -140,28 +140,28 @@ dependencies:
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: '11.3'
143
+ version: '12.0'
144
144
  type: :development
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: '11.3'
150
+ version: '12.0'
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: rubocop
153
153
  requirement: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - "~>"
156
156
  - !ruby/object:Gem::Version
157
- version: 0.45.0
157
+ version: 0.46.0
158
158
  type: :development
159
159
  prerelease: false
160
160
  version_requirements: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - "~>"
163
163
  - !ruby/object:Gem::Version
164
- version: 0.45.0
164
+ version: 0.46.0
165
165
  - !ruby/object:Gem::Dependency
166
166
  name: simplecov
167
167
  requirement: !ruby/object:Gem::Requirement
@@ -219,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  version: '0'
220
220
  requirements: []
221
221
  rubyforge_project:
222
- rubygems_version: 2.5.1
222
+ rubygems_version: 2.5.2
223
223
  signing_key:
224
224
  specification_version: 4
225
225
  summary: Translate your Rails routes in a simple manner