serial_translator 2.0.1 → 2.0.2

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
- SHA1:
3
- metadata.gz: 783b148b631058301494001a7418bfc09f809d2e
4
- data.tar.gz: 0a56fcaa10a203518feda80b0a3e5fa6bbf522b1
2
+ SHA256:
3
+ metadata.gz: e8416de9ed2d78026be3343cc9af2e87fd5b1cc422d27a9c0071a4a9bb871c77
4
+ data.tar.gz: 3885221de80e12cc598214594a983182aed37aabd3da2f2ce5324c2dd24c0959
5
5
  SHA512:
6
- metadata.gz: 5fcedb9a2e4d9be52977279c9eeb77faca7338dfad61b59b90ed197c067d354c8dbd6dc78434d50a5d838c296d4588b49f5807dba9f6fc85817a7557fb4e1280
7
- data.tar.gz: bb7e2fa8d707ff170eb96c0081f0fae5145f18e3c2b77ec29fc1e593a56427b2b877c337ddb48edde97133a5f67b604739dc8762684f62cc49193087ad788a9d
6
+ metadata.gz: bd3e4d060f3bc25681952742562ded695f4ad10219e677407633e5e865e76aa4afba47dc9116981a2b0453e2a128fc6fb9a66663432ee3270a1c575d6a9130eb
7
+ data.tar.gz: 827a71095c2db3bb562731dda31217fa0b95c1d680b02463e6463221fa2865aeb6f26ba40c2ba46be5698b92e17b1ec9b87eb8bed12dbfa5b084cc267004ecf7
@@ -1,6 +1,11 @@
1
+ before_install:
2
+ - gem update --system
3
+ - gem update bundler
4
+
1
5
  rvm:
2
- - 2.3.3
3
- - 2.4.0
6
+ - 2.3.6
7
+ - 2.4.3
8
+ - 2.5.0
4
9
 
5
10
  script: "bundle exec rake"
6
11
 
@@ -14,6 +14,9 @@ module SerialTranslator
14
14
  attr_writer :current_translation_locale, :translation_fallback
15
15
  end
16
16
 
17
+ class InvalidLocaleError < StandardError
18
+ end
19
+
17
20
  module ClassMethods
18
21
  attr_reader :serial_translator_attributes
19
22
 
@@ -39,6 +42,9 @@ module SerialTranslator
39
42
  # Define the normal setter, that respects the
40
43
  # current translation locale
41
44
  define_method "#{attr_name}=" do |value|
45
+ unless I18n.available_locales.include?(current_translation_locale)
46
+ raise InvalidLocaleError, "current_translation_locale #{current_translation_locale.inspect} is not a member of I18n.available_locales: #{I18n.available_locales.inspect}"
47
+ end
42
48
  __send__(:"#{attr_name}_translations_will_change!")
43
49
  translations = translations_for(attr_name)
44
50
  if value.present?
@@ -1,3 +1,3 @@
1
1
  module SerialTranslator
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -48,6 +48,12 @@ describe SerialTranslator do
48
48
  expect(object.title_translations).to eq({ de: 'Deutsch' })
49
49
  end
50
50
 
51
+ it 'raises an error if current translation is not an I18n locale' do
52
+ object.current_translation_locale = :foobar
53
+ expect { object.title = 'Deutsch' }.to raise_error(SerialTranslator::InvalidLocaleError)
54
+ expect(object.title_translations).to eq({})
55
+ end
56
+
51
57
  it 'nil removes the value for the current text locale' do
52
58
  object.title_translations = { de: 'Deutsch' }
53
59
  object.current_translation_locale = :de
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: 2.0.1
4
+ version: 2.0.2
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: 2017-01-23 00:00:00.000000000 Z
11
+ date: 2018-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  version: '0'
184
184
  requirements: []
185
185
  rubyforge_project:
186
- rubygems_version: 2.6.8
186
+ rubygems_version: 2.7.6
187
187
  signing_key:
188
188
  specification_version: 4
189
189
  summary: Translate attribute values without additional models