text_helpers 1.0.0 → 1.0.1

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: 821b971353a180079293995889c2ac37c578e4afbeb2fb4ab4f2b23d885121fa
4
- data.tar.gz: 90b1c2814b154bd44b5c862c4cb65b3874eb4def96a8e3f87e7c39d28e9373da
3
+ metadata.gz: 97f5f8d490471d60b7cc9286f2fb49460862917a1ed6b6d36c984fb8f5a22ac3
4
+ data.tar.gz: a2fadb5cea94f89c87cf31ef1a7dbb8779739c6aab67d2b9f143968498cc25e7
5
5
  SHA512:
6
- metadata.gz: ab19b219ea2f6b4877e1da8d103395836c7666154711591a255e093750059f72415fb283d6f427086ad96782375fa92cce9dfff4645b98fe38af203401b1a46f
7
- data.tar.gz: 07b98f9af2b8258d696b3cb067ad54a25bf8e68e4d51f490e5f449dca418ef055cd562ae91ead997eb4be4c62a9587f83bc52bc97b52fd3f811bc176003eccac
6
+ metadata.gz: 73f98e2a518aeafb35653d9d713a3b983d456d2e947bc98fcc1c519d9b8b7034f741eb2985475336e5b9fe6786ebc8502e2fe9994001a259c19c1c0800b769d2
7
+ data.tar.gz: 37a0c2ba7e0510dd38d720abafb43ba6342f1af8b578422b520d82956aa9a46df22b87a6774b615f1665a21b11618f185229face8e8c9b44513c44081cd1f2f0
@@ -37,11 +37,11 @@ module TextHelpers
37
37
  options = html_safe_options(options)
38
38
  text = I18n.t(key, **{
39
39
  scope: self.translation_scope,
40
- default: "!#{key}!"
40
+ default: "!#{key}!",
41
+ cascade: true,
41
42
  }.merge(options)).strip
42
43
 
43
- interpolation_options = options.dup
44
- interpolation_options[:cascade] = true unless interpolation_options.has_key?(:cascade)
44
+ interpolation_options = { cascade: true }.merge(options)
45
45
 
46
46
  # Interpolate any keypaths (e.g., `!some.lookup.path/key!`) found in the text.
47
47
  while text =~ KEYPATH_MATCHER do
@@ -1,3 +1,3 @@
1
1
  module TextHelpers
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -1,4 +1,4 @@
1
- require_relative '../../test_helper'
1
+ require_relative "../../test_helper"
2
2
 
3
3
  describe TextHelpers::Translation do
4
4
  before do
@@ -242,6 +242,14 @@ describe TextHelpers::Translation do
242
242
  I18n.backend = @original_backend
243
243
  end
244
244
 
245
+ it "cascades the requested key by default" do
246
+ I18n.backend.store_translations(:en, {test_scoped_key: "a translation"})
247
+ assert_equal "a translation", @helper.text(:test_scoped_key, scope: "some.unnecessary.scope")
248
+
249
+ I18n.backend.store_translations(:en, {some: {test_scoped_key: "a scoped translation"}})
250
+ assert_equal "a scoped translation", @helper.text(:test_scoped_key, scope: "some.unnecessary.scope")
251
+ end
252
+
245
253
  it "cascades the interpolated key by default" do
246
254
  I18n.backend.store_translations(:en, {test_scoped_key: "a translation"})
247
255
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text_helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Horner
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-27 00:00:00.000000000 Z
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,7 +108,7 @@ homepage: https://github.com/ahorner/text-helpers
108
108
  licenses:
109
109
  - MIT
110
110
  metadata: {}
111
- post_install_message:
111
+ post_install_message:
112
112
  rdoc_options: []
113
113
  require_paths:
114
114
  - lib
@@ -123,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.1.2
127
- signing_key:
126
+ rubygems_version: 3.1.4
127
+ signing_key:
128
128
  specification_version: 4
129
129
  summary: TextHelpers is a gem which supplies some basic utilities for text localization
130
130
  in Rails projects. The library is intended to make it simple to keep your application's