coaster 0.0.4 → 0.0.5
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/lib/coaster/core_ext/object_translation.rb +5 -1
- data/lib/coaster/version.rb +1 -1
- data/test/test_object_translation.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1c2b790757657909deb31d6c8a22db59b0ada6f
|
4
|
+
data.tar.gz: 4168a86bbb07e21b07a54ddacb0042fb90d2cf7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dae90605decc718a32d01b61876acfd37d036b4ebf5b321aff3cbd929091f6055a5bd0bf9bc32866748c921ba62fb2650edd7b899d118ee3d04a24ea91ac282e
|
7
|
+
data.tar.gz: 8efdb8a2fa82c72d643729802ae8d554d95fef7c8fdd652bf8ac4fad36c6552312c048647baf5260a6c24dcc702f135a283ecf3c28d95afbf5e1117ac0138a23
|
@@ -28,6 +28,9 @@ class Object
|
|
28
28
|
key = key_class.name.gsub(/::/, '.')
|
29
29
|
key = 'class.' + key + subkey
|
30
30
|
|
31
|
+
unless options.key?(:original_throw)
|
32
|
+
options[:original_throw] = options.delete(:throw)
|
33
|
+
end
|
31
34
|
options.merge!(throw: true)
|
32
35
|
result = catch(:exception) do
|
33
36
|
I18n.t(key, *args, options)
|
@@ -40,7 +43,8 @@ class Object
|
|
40
43
|
end
|
41
44
|
|
42
45
|
if key_class.superclass == Object || key_class == Object
|
43
|
-
options[:description]
|
46
|
+
return options[:description] if options[:description].present?
|
47
|
+
throw :exception, result if options[:original_throw]
|
44
48
|
(options[:original_missing] && options[:original_missing].message) ||
|
45
49
|
result.message
|
46
50
|
else
|
data/lib/coaster/version.rb
CHANGED
@@ -27,6 +27,13 @@ module Coaster
|
|
27
27
|
assert_equal 'translation missing: en.class.Coaster.NotTranslated.self', NotTranslated._translate
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_raise_translation_missing
|
31
|
+
exception = catch(:exception) do
|
32
|
+
NotTranslated._translate(throw: true)
|
33
|
+
end
|
34
|
+
assert_equal(I18n::MissingTranslation, exception.class)
|
35
|
+
end
|
36
|
+
|
30
37
|
def test_translation_sub
|
31
38
|
assert_equal 'Coaster SampleObject Title', SampleObject._translate('.title')
|
32
39
|
assert_equal 'Coaster SampleObject Title', SampleObject._translate(:title)
|