mobility 0.7.3 → 0.7.4

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
  SHA256:
3
- metadata.gz: 0e0f95b761c21d4b4e8dbbbc3b46dea6a2b70039ca864dba15983689f207cf69
4
- data.tar.gz: 1b2e5d61347a30f602dcaf56a7e467b24bf775bf0577a9494d84683921779705
3
+ metadata.gz: 1d9a9d5c551c18a0df94133a0adc5182d872afcab3e690a4580f480fab66cd09
4
+ data.tar.gz: b4a9efc3055adc3ee91d5fe47ba42a1b2f59bb00d820537d4ae2e3588e556753
5
5
  SHA512:
6
- metadata.gz: da7f935a5624a5ba5aae4eed92ea45ee2eb04593ba7efd370d51cc10b8715ec933d4955a36ced854b68190de40598bff1fed3ab99befe1c7c46bce681e0b4e8c
7
- data.tar.gz: 76ba495e0ae4d8e287b5581f97641f3e2e71e69fbd326c18c12031c76a4db5dc7a36b8f0733c14a1ee31b322fdd805cf4089eaad67fa55a517c9d7c1837a35aa
6
+ metadata.gz: e6c2658659e778be404e1c5f66b2d873a7d7a5a7f8a9f8b15773105949f6f29e7e8c9654e0e77a919b4bcc2472c31bdc29f82ec5cf0275db81e0a3575caf6f29
7
+ data.tar.gz: e20925dc8d6d4152f58b038101de146735a34919bfe7a91b3605ec08b7b1a5a76c177e227428d7a80219d7c414bf71804d6a01f7fead43857b3870214ce6b7b9
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## 0.7
4
4
 
5
+ ### 0.7.4 (June 8, 2018)
6
+ * Handle locales with multiple dashes in locale accessors, or raise
7
+ ArgumentError for invalid format
8
+ ([#253](https://github.com/shioyama/mobility/pull/253))
9
+
5
10
  ### 0.7.3 (June 7, 2018)
6
11
  * Fix uniqueness on Mobility model with no translated attributes ([#252](Fix
7
12
  uniqueness on Mobility model with no translated attributes))
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility (0.7.2)
4
+ mobility (0.7.3)
5
5
  i18n (>= 0.6.10, < 1.1)
6
6
  request_store (~> 1.0)
7
7
 
data/README.md CHANGED
@@ -51,7 +51,7 @@ Installation
51
51
  Add this line to your application's Gemfile:
52
52
 
53
53
  ```ruby
54
- gem 'mobility', '~> 0.7.3'
54
+ gem 'mobility', '~> 0.7.4'
55
55
  ```
56
56
 
57
57
  Mobility is cryptographically signed. To be sure the gem you install hasn't
data/lib/mobility.rb CHANGED
@@ -37,6 +37,8 @@ module Mobility
37
37
 
38
38
  # General error for version compatibility conflicts
39
39
  class VersionNotSupportedError < ArgumentError; end
40
+ CALL_COMPILABLE_REGEXP = /\A[a-zA-Z_]\w*[!?]?\z/
41
+ private_constant :CALL_COMPILABLE_REGEXP
40
42
 
41
43
  begin
42
44
  require "rails"
@@ -198,7 +200,7 @@ module Mobility
198
200
  # Mobility.normalize_locale("pt-BR")
199
201
  # #=> "pt_br"
200
202
  def normalize_locale(locale = Mobility.locale)
201
- "#{locale.to_s.downcase.sub("-", "_")}"
203
+ "#{locale.to_s.downcase.tr("-", "_")}"
202
204
  end
203
205
  alias_method :normalized_locale, :normalize_locale
204
206
 
@@ -206,13 +208,18 @@ module Mobility
206
208
  # @param [String,Symbol] attribute
207
209
  # @param [String,Symbol] locale
208
210
  # @return [String] Normalized locale accessor name
211
+ # @raise [ArgumentError] if generated accessor has an invalid format
209
212
  # @example
210
213
  # Mobility.normalize_locale_accessor(:foo, :ja)
211
214
  # #=> "foo_ja"
212
215
  # Mobility.normalize_locale_accessor(:bar, "pt-BR")
213
216
  # #=> "bar_pt_br"
214
217
  def normalize_locale_accessor(attribute, locale = Mobility.locale)
215
- "#{attribute}_#{normalize_locale(locale)}"
218
+ "#{attribute}_#{normalize_locale(locale)}".tap do |accessor|
219
+ unless CALL_COMPILABLE_REGEXP.match(accessor)
220
+ raise ArgumentError, "#{accessor.inspect} is not a valid accessor"
221
+ end
222
+ end
216
223
  end
217
224
 
218
225
  # Raises InvalidLocale exception if the locale passed in is present but not available.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mobility
4
- VERSION = "0.7.3"
4
+ VERSION = "0.7.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
@@ -30,7 +30,7 @@ cert_chain:
30
30
  eGDROPZoL5RXwiOnRbexxa7dcAxMrDfGB/hpiunIPWPsi4n5P7K/6OO/sGVMl9xv
31
31
  SZBPXjzrHdyOFLBYXB+PG7s3F/4=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-06-07 00:00:00.000000000 Z
33
+ date: 2018-06-08 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: request_store
metadata.gz.sig CHANGED
Binary file