i18n-sequel_bitemporal 1.0.1 → 1.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
2
  SHA256:
3
- metadata.gz: 001e75fff58372096d2e4bf9864cd3574c524a7aa6d5a8fcfd37f701a05778bd
4
- data.tar.gz: 89495e4d973f1d036c850dc75fd9fff7e378649aa93cee9dfc26cf7f6944e112
3
+ metadata.gz: 17c191652e457d465a3d7951efdf76a432a82690dd7b3f0bae9324b3bbe7a61d
4
+ data.tar.gz: 05a1aa9b8d012cced99c152b0700960bbc812e38b753f4f612bdbef635b2b4f0
5
5
  SHA512:
6
- metadata.gz: 57755d218667ac589fafcab3d4689bb5ecfe01cb60971f2716ec77efd6e098359b690cb457c0281d5544fdb10a1a0f0fb48283472f1b0d56987e52f033fad28c
7
- data.tar.gz: 4e048ec53e79fb4371482990d0469363624491c9caea3b18140b832cc6339a16cb63fbd64306acd12a79e3243326ab56b6720bd7683711c134e73ec9d9d2d3e1
6
+ metadata.gz: 2c147a89f559776c2977e3aad2a8ee38820d79c0c8246f7b77c801b69667d1272d4d55cdd7ca6cc80a7316aba13fd84516490700a6f9bf1ad2fd6313333e9d19
7
+ data.tar.gz: e8cfa24c1ea406cd5ae63eba66040c46db6edb63fe30dff280351cff3745c5b5998ade3000f00dac92da59b1a812affc4baba4c52260194bdde893df9ac98c1b
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_dependency "i18n", ">= 1.0.0"
22
22
  s.add_dependency "sequel_bitemporal", ">= 0.8.0"
23
+ s.add_dependency "activesupport", ">= 4.0.2"
23
24
  end
@@ -1,4 +1,5 @@
1
1
  require 'i18n/backend/base'
2
+ require 'active_support/core_ext/hash/keys'
2
3
 
3
4
  module I18n
4
5
  module Backend
@@ -43,6 +44,7 @@ module I18n
43
44
 
44
45
  def store_translations(locale, data, options = {})
45
46
  escape = options.fetch(:escape, true)
47
+ valid_from_for_new = options[:valid_from_for_new]
46
48
  flatten_translations(locale, data, escape, false).each do |key, value|
47
49
  # Invalidate all keys matching current one:
48
50
  # key = foo.bar invalidates foo, foo.bar and foo.bar.*
@@ -53,6 +55,7 @@ module I18n
53
55
  translation = Translation.locale(locale).lookup_exactly(expand_keys(key)).limit(1).all.first ||
54
56
  Translation.new(:locale => locale.to_s, :key => key.to_s)
55
57
  translation.attributes = {:value => value}
58
+ translation.attributes[:valid_from] = valid_from_for_new if translation.new?
56
59
  translation.save
57
60
  end
58
61
  end
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module SequelBitemporal
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
data/test/sequel_test.rb CHANGED
@@ -52,6 +52,21 @@ class I18nBackendSequelBitemporalTest < I18nBitemporalTest
52
52
  assert_equal [], translations.map(&:value)
53
53
  end
54
54
 
55
+ test "use today as the default valid from for the new translation" do
56
+ I18n.backend.store_translations(:es, {:"Pagina's" => "Pagina's"} )
57
+ translation = I18n::Backend::SequelBitemporal::Translation.locale(:es).lookup("Pagina's").limit(1).all.first
58
+ assert_equal "Pagina's", translation.value
59
+ assert_equal Date.today, translation.current_version.valid_from
60
+ end
61
+
62
+ test "can specify valid from for the new translation" do
63
+ valid_from_for_new = Date.parse("2001-01-01")
64
+ I18n.backend.store_translations(:es, {:"Pagina's" => "Pagina's"}, valid_from_for_new: valid_from_for_new )
65
+ translation = I18n::Backend::SequelBitemporal::Translation.locale(:es).lookup("Pagina's").limit(1).all.first
66
+ assert_equal "Pagina's", translation.value
67
+ assert_equal valid_from_for_new, translation.current_version.valid_from
68
+ end
69
+
55
70
  with_mocha do
56
71
  test "missing translations table does not cause an error in #available_locales" do
57
72
  I18n::Backend::SequelBitemporal::Translation.expects(:available_locales).raises(::Sequel::Error)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-sequel_bitemporal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Tron
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-14 00:00:00.000000000 Z
11
+ date: 2022-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.8.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 4.0.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 4.0.2
41
55
  description: I18n Bitemporal Sequel backend. Allows to store translations in a database
42
56
  using Sequel using a bitemporal approach, e.g. for providing a web-interface for
43
57
  managing translations.
@@ -74,7 +88,7 @@ files:
74
88
  homepage: http://github.com/TalentBox/i18n-sequel_bitemporal
75
89
  licenses: []
76
90
  metadata: {}
77
- post_install_message:
91
+ post_install_message:
78
92
  rdoc_options: []
79
93
  require_paths:
80
94
  - lib
@@ -89,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
103
  - !ruby/object:Gem::Version
90
104
  version: '0'
91
105
  requirements: []
92
- rubygems_version: 3.0.3
93
- signing_key:
106
+ rubygems_version: 3.3.7
107
+ signing_key:
94
108
  specification_version: 4
95
109
  summary: I18n Bitemporal Sequel backend
96
110
  test_files: