serial_translator 0.0.8 → 0.0.9
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9e4f4ceb0a81d11f416db203565703539668e9a2
|
|
4
|
+
data.tar.gz: 51c01f7015a9492680270e25efadefb0689ea12f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 939aeec909cd13e19d67f2b50a88520370e2802a0812b3eb040e7196ebfcc44ca6e8f7df9bb51935c6d73509f8c4f4188eb05f996a5c27e15cf4f2e1261079bc
|
|
7
|
+
data.tar.gz: 88a8921c319fb5daa24e6ec4dea64a235dc42dd8eba1b3ef5291222656884f5e3eead03f298b3b8edbf0e44ebe594852c1fd9e77f21e895af84eacae59c4d56f
|
data/.travis.yml
CHANGED
data/lib/serial_translator.rb
CHANGED
|
@@ -92,13 +92,7 @@ module SerialTranslator
|
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def translations_for(attribute)
|
|
95
|
-
|
|
96
|
-
translations.each do |locale, string|
|
|
97
|
-
string.singleton_class.class_eval do
|
|
98
|
-
define_method(:locale) { || locale }
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
translations
|
|
95
|
+
__send__(:"#{attribute}_translations") || {}
|
|
102
96
|
end
|
|
103
97
|
|
|
104
98
|
def translated_into?(locale)
|
|
@@ -75,7 +75,7 @@ describe SerialTranslator::SerialTranslatorValidator do
|
|
|
75
75
|
|
|
76
76
|
it 'validates correctly on language change as well' do
|
|
77
77
|
I18n.locale = :de
|
|
78
|
-
example.description =
|
|
78
|
+
example.description = :something_to_make_it_pass_valid
|
|
79
79
|
example.title = 'Valid foo'
|
|
80
80
|
expect(example).to be_valid
|
|
81
81
|
|
|
@@ -8,7 +8,6 @@ describe SerialTranslator do
|
|
|
8
8
|
it 'returns the translated value in the requested locale' do
|
|
9
9
|
object.title_translations = { de: 'German translation', en: 'English translation' }
|
|
10
10
|
expect(object.title(:de)).to eq 'German translation'
|
|
11
|
-
expect(object.title(:de).locale).to eq :de
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
it 'provides a boolean predicate to check the presence of a translated value' do
|
|
@@ -20,13 +19,11 @@ describe SerialTranslator do
|
|
|
20
19
|
it 'returns the origin locale value if no translation is present' do
|
|
21
20
|
object.title_translations = { en: 'English translation' }
|
|
22
21
|
expect(object.title(:de)).to eq 'English translation'
|
|
23
|
-
expect(object.title(:de).locale).to eq :en
|
|
24
22
|
end
|
|
25
23
|
|
|
26
24
|
it 'returns the origin locale value if the translation is empty' do
|
|
27
25
|
object.title_translations = { de: '', en: 'English translation' }
|
|
28
26
|
expect(object.title(:de)).to eq 'English translation'
|
|
29
|
-
expect(object.title(:de).locale).to eq :en
|
|
30
27
|
end
|
|
31
28
|
|
|
32
29
|
it 'returns nil if no translations are there at all' do
|
|
@@ -38,7 +35,6 @@ describe SerialTranslator do
|
|
|
38
35
|
object.title_translations = { de: 'Deutsch', en: 'English' }
|
|
39
36
|
object.current_translation_locale = :en
|
|
40
37
|
expect(object.title).to eq 'English'
|
|
41
|
-
expect(object.title.locale).to eq :en
|
|
42
38
|
end
|
|
43
39
|
|
|
44
40
|
it 'does not fail even if translations were not initialized before' do
|
|
@@ -77,13 +73,11 @@ describe SerialTranslator do
|
|
|
77
73
|
it 'gets the correct translation' do
|
|
78
74
|
object.title_translations = { de: 'Deutsch' }
|
|
79
75
|
expect(object.title_de).to eq 'Deutsch'
|
|
80
|
-
expect(object.title_de.locale).to eq :de
|
|
81
76
|
end
|
|
82
77
|
|
|
83
78
|
it 'uses fallback mechanisms as well' do
|
|
84
79
|
object.title_translations = { en: 'English' }
|
|
85
80
|
expect(object.title_de).to eq 'English'
|
|
86
|
-
expect(object.title_de.locale).to eq :en
|
|
87
81
|
end
|
|
88
82
|
end
|
|
89
83
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: serial_translator
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- betterplace development team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-01-
|
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|