i18n-sequel_bitemporal 0.10.0 → 1.0.2

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: e9cf75ce1c5791eb1d10e893c199ff27381f624be920a90e7a37fd22ac167a15
4
- data.tar.gz: fed3419f2f0e7009abffe45ccecf2b3302bbf51b5ae81efb026aa1f3ff196724
3
+ metadata.gz: 17c191652e457d465a3d7951efdf76a432a82690dd7b3f0bae9324b3bbe7a61d
4
+ data.tar.gz: 05a1aa9b8d012cced99c152b0700960bbc812e38b753f4f612bdbef635b2b4f0
5
5
  SHA512:
6
- metadata.gz: ad1735cc01a4701ea6aaeb8268638bfa2eb29f3ae4c9dab3261eed05283374c37d69edc6d6d16467332a9ebd6d84622edc528d951adb880711080cd4c8a60f51
7
- data.tar.gz: dd67ca4ccd22c122e2af86b2049d23c13d11f92658aeb43bdf8cf68b3bb59148d1a515dfea28f754551dcd0c202d899a1472ed191bdbee66a9ce3f0197772cb9
6
+ metadata.gz: 2c147a89f559776c2977e3aad2a8ee38820d79c0c8246f7b77c801b69667d1272d4d55cdd7ca6cc80a7316aba13fd84516490700a6f9bf1ad2fd6313333e9d19
7
+ data.tar.gz: e8cfa24c1ea406cd5ae63eba66040c46db6edb63fe30dff280351cff3745c5b5998ade3000f00dac92da59b1a812affc4baba4c52260194bdde893df9ac98c1b
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.6.3
data/.travis.yml CHANGED
@@ -5,15 +5,13 @@ before_script:
5
5
  - psql -c 'create database i18n_sequel_bitemporal;' -U postgres
6
6
  rvm:
7
7
  - 2.3.8
8
- - 2.4.5
9
- - 2.5.3
8
+ - 2.4.6
9
+ - 2.5.5
10
+ - 2.6.3
10
11
  env:
11
12
  - ADAPTER=sqlite3
12
13
  - ADAPTER=postgres
13
14
  gemfile:
14
- - ci/Gemfile.rails-4.0
15
- - ci/Gemfile.rails-4.1
16
- - ci/Gemfile.rails-4.2
17
15
  - ci/Gemfile.rails-5.0
18
16
  - ci/Gemfile.rails-5.1
19
17
  - ci/Gemfile.rails-5.2
@@ -1,36 +1,41 @@
1
- !https://travis-ci.org/TalentBox/i18n-sequel_bitemporal.svg?branch=master!:https://travis-ci.org/TalentBox/i18n-sequel_bitemporal
1
+ [![Build Status](https://travis-ci.org/TalentBox/i18n-sequel_bitemporal.svg?branch=master)](https://travis-ci.org/TalentBox/i18n-sequel_bitemporal)
2
2
 
3
- h1. I18n::Backend::SequelBitemporal
3
+ # I18n::Backend::SequelBitemporal
4
4
 
5
- This repository contains an "I18n":http://github.com/svenfuchs/i18n Sequel
6
- backend storing translations using a bitemporal approach. This allows you go back in time
7
- in your translations and schedule new translations to appears in the future without
5
+ This repository contains an [I18n](http://github.com/svenfuchs/i18n)
6
+ Sequel
7
+ backend storing translations using a bitemporal approach. This allows
8
+ you go back in time
9
+ in your translations and schedule new translations to appears in the
10
+ future without
8
11
  needing any cron task to run.
9
12
 
10
- Most of the code is a port of the "ActiveRecord backend":http://github.com/svenfuchs/i18n-activerecord from SvenFuchs.
13
+ Most of the code is a port of the [ActiveRecord
14
+ backend](http://github.com/svenfuchs/i18n-activerecord) from SvenFuchs.
11
15
 
12
- It's compatible with both I18n ~> 0.5.0 (Rails 3.0.x) and ~> 0.6.0 (Rails 3.1.x)
16
+ Its compatible with I18n \>= 1.0.0 (Rails 5.x)
13
17
 
14
- h2. Installation
18
+ ## Installation
15
19
 
16
20
  For Bundler put the following in your Gemfile:
17
21
 
18
- <pre>
22
+ ```
19
23
  gem 'i18n-sequel_bitemporal', :require => 'i18n/sequel_bitemporal'
20
- </pre>
24
+ ```
21
25
 
22
- or to track master's HEAD:
26
+ or to track masters HEAD:
23
27
 
24
- <pre>
28
+ ```
25
29
  gem 'i18n-sequel_bitemporal',
26
30
  :github => 'TalentBox/i18n-sequel_bitemporal',
27
31
  :require => 'i18n/sequel_bitemporal'
28
- </pre>
32
+ ```
29
33
 
30
- Next create a sequel migration with the Rails Generator (if you're using rails-sequel).
34
+ Next create a sequel migration with the Rails Generator (if youre using
35
+ rails-sequel).
31
36
  Your migration should look like this:
32
37
 
33
- <pre>
38
+ ```
34
39
  class CreateI18nTranslationsMigration < Sequel::Migration
35
40
 
36
41
  def up
@@ -60,24 +65,27 @@ Your migration should look like this:
60
65
  end
61
66
 
62
67
  end
63
- </pre>
68
+ ```
64
69
 
65
- With these translation tables you will be able to manage your translation, and add new translations or languages.
70
+ With these translation tables you will be able to manage your
71
+ translation, and add new translations or languages.
66
72
 
67
- To load @I18n::Backend::SequelBitemporal@ into your Rails application, create a new file in *config/initializers* named *locale.rb*.
73
+ To load `I18n::Backend::SequelBitemporal` into your Rails application,
74
+ create a new file in **config/initializers** named **locale.rb**.
68
75
 
69
76
  A simple configuration for your locale.rb could look like this:
70
77
 
71
- <pre>
78
+ ```
72
79
  require 'i18n/backend/sequel_bitemporal'
73
80
  I18n.backend = I18n::Backend::SequelBitemporal.new
74
- </pre>
81
+ ```
75
82
 
76
- A more advanced example (Thanks Moritz), which uses YAML files and ActiveRecord for lookups:
83
+ A more advanced example (Thanks Moritz), which uses YAML files and
84
+ ActiveRecord for lookups:
77
85
 
78
86
  Memoization is highly recommended if you use a DB as your backend.
79
87
 
80
- <pre>
88
+ ```
81
89
  require 'i18n/backend/sequel_bitemporal'
82
90
  I18n.backend = I18n::Backend::SequelBitemporal.new
83
91
 
@@ -87,46 +95,44 @@ Memoization is highly recommended if you use a DB as your backend.
87
95
  I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
88
96
 
89
97
  I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend)
90
- </pre>
98
+ ```
91
99
 
92
100
  You can also customize table names for the backing models:
93
101
 
94
- <pre>
102
+ ```
95
103
  require 'i18n/backend/sequel_bitemporal'
96
104
  I18n::Backend::SequelBitemporal.master_table_name = :my_translations
97
105
  I18n::Backend::SequelBitemporal.version_table_name = :my_translation_versions
98
- </pre>
106
+ ```
99
107
 
100
- Please note names can be anything you can use in `Sequel::Model#set_dataset`.
108
+ Please note names can be anything you can use in
109
+ \`Sequel::Model\#set\_dataset\`.
101
110
  For example you want your translations table to be in a specific schema:
102
111
 
103
- <pre>
112
+ ```
104
113
  require 'i18n/backend/sequel_bitemporal'
105
114
  I18n::Backend::SequelBitemporal.master_table_name = Sequel.qualify(:translations, :i18n_translations)
106
115
  I18n::Backend::SequelBitemporal.version_table_name = Sequel.qualify(:translations, :i18n_translation_versions)
107
- </pre>
116
+ ```
108
117
 
109
- h2. Usage
118
+ ## Usage
110
119
 
111
- You can now use @I18n.t('Your String')@ to lookup translations in the database.
120
+ You can now use `I18n.t('Your String')` to lookup translations in the
121
+ database.
112
122
 
113
- h2. Runnning tests
123
+ ## Runnning tests
114
124
 
115
- <pre>
116
- gem install bundler
117
- BUNDLE_GEMFILE=ci/Gemfile.rails-3.x bundle
118
- BUNDLE_GEMFILE=ci/Gemfile.rails-3.x-i18n-0.6 bundle
119
- BUNDLE_GEMFILE=ci/Gemfile.rails-3.x rake
120
- BUNDLE_GEMFILE=ci/Gemfile.rails-3.x-i18n-0.6 rake
121
- </pre>
125
+ gem install bundler
126
+ BUNDLE_GEMFILE=ci/Gemfile.rails-5.x bundle
127
+ BUNDLE_GEMFILE=ci/Gemfile.rails-5.x-i18n-0.6 bundle
128
+ BUNDLE_GEMFILE=ci/Gemfile.rails-5.x rake
129
+ BUNDLE_GEMFILE=ci/Gemfile.rails-5.x-i18n-0.6 rake
122
130
 
123
131
  If you want to see what queries are executed:
124
132
 
125
- <pre>
126
- DEBUG=true BUNDLE_GEMFILE=ci/Gemfile.rails-3.x rake
127
- DEBUG=true BUNDLE_GEMFILE=ci/Gemfile.rails-3.x-i18n-0.6 rake
128
- </pre>
133
+ DEBUG=true BUNDLE_GEMFILE=ci/Gemfile.rails-5.x rake
134
+ DEBUG=true BUNDLE_GEMFILE=ci/Gemfile.rails-5.x-i18n-0.6 rake
129
135
 
130
- h2. Maintainers
136
+ ## Maintainers
131
137
 
132
- * Jonathan Tron
138
+ - Jonathan Tron
@@ -10,7 +10,6 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://github.com/TalentBox/i18n-sequel_bitemporal"
11
11
  s.summary = "I18n Bitemporal Sequel backend"
12
12
  s.description = "I18n Bitemporal Sequel backend. Allows to store translations in a database using Sequel using a bitemporal approach, e.g. for providing a web-interface for managing translations."
13
- s.rubyforge_project = "[none]"
14
13
 
15
14
  s.platform = Gem::Platform::RUBY
16
15
 
@@ -19,6 +18,7 @@ Gem::Specification.new do |s|
19
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
19
  s.require_paths = ["lib"]
21
20
 
22
- s.add_dependency "i18n", ">= 0.6", "< 0.9.0"
21
+ s.add_dependency "i18n", ">= 1.0.0"
23
22
  s.add_dependency "sequel_bitemporal", ">= 0.8.0"
23
+ s.add_dependency "activesupport", ">= 4.0.2"
24
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
@@ -24,6 +25,7 @@ module I18n
24
25
  end
25
26
 
26
27
  module Implementation
28
+ using I18n::HashRefinements if defined?(I18n::HashRefinements)
27
29
  include Base, Flatten
28
30
 
29
31
  def initialize(opts= {})
@@ -42,6 +44,7 @@ module I18n
42
44
 
43
45
  def store_translations(locale, data, options = {})
44
46
  escape = options.fetch(:escape, true)
47
+ valid_from_for_new = options[:valid_from_for_new]
45
48
  flatten_translations(locale, data, escape, false).each do |key, value|
46
49
  # Invalidate all keys matching current one:
47
50
  # key = foo.bar invalidates foo, foo.bar and foo.bar.*
@@ -52,6 +55,7 @@ module I18n
52
55
  translation = Translation.locale(locale).lookup_exactly(expand_keys(key)).limit(1).all.first ||
53
56
  Translation.new(:locale => locale.to_s, :key => key.to_s)
54
57
  translation.attributes = {:value => value}
58
+ translation.attributes[:valid_from] = valid_from_for_new if translation.new?
55
59
  translation.save
56
60
  end
57
61
  end
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module SequelBitemporal
3
- VERSION = "0.10.0"
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: 0.10.0
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: 2018-11-29 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
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.6'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: 0.9.0
19
+ version: 1.0.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '0.6'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: 0.9.0
26
+ version: 1.0.0
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: sequel_bitemporal
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,6 +38,20 @@ dependencies:
44
38
  - - ">="
45
39
  - !ruby/object:Gem::Version
46
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
47
55
  description: I18n Bitemporal Sequel backend. Allows to store translations in a database
48
56
  using Sequel using a bitemporal approach, e.g. for providing a web-interface for
49
57
  managing translations.
@@ -58,11 +66,8 @@ files:
58
66
  - ".travis.yml"
59
67
  - Gemfile
60
68
  - MIT-LICENSE
61
- - README.textile
69
+ - README.md
62
70
  - Rakefile
63
- - ci/Gemfile.rails-4.0
64
- - ci/Gemfile.rails-4.1
65
- - ci/Gemfile.rails-4.2
66
71
  - ci/Gemfile.rails-5.0
67
72
  - ci/Gemfile.rails-5.1
68
73
  - ci/Gemfile.rails-5.2
@@ -83,7 +88,7 @@ files:
83
88
  homepage: http://github.com/TalentBox/i18n-sequel_bitemporal
84
89
  licenses: []
85
90
  metadata: {}
86
- post_install_message:
91
+ post_install_message:
87
92
  rdoc_options: []
88
93
  require_paths:
89
94
  - lib
@@ -98,9 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
103
  - !ruby/object:Gem::Version
99
104
  version: '0'
100
105
  requirements: []
101
- rubyforge_project: "[none]"
102
- rubygems_version: 2.7.6
103
- signing_key:
106
+ rubygems_version: 3.3.7
107
+ signing_key:
104
108
  specification_version: 4
105
109
  summary: I18n Bitemporal Sequel backend
106
110
  test_files:
data/ci/Gemfile.rails-4.0 DELETED
@@ -1,21 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path => "../"
4
-
5
- gem 'railties', '~> 4.0.0'
6
-
7
- gem "test-unit"
8
- gem "test_declarative"
9
- gem "mocha"
10
- gem "rake"
11
- gem "timecop"
12
-
13
- platforms :ruby do
14
- gem "pg"
15
- gem "sqlite3"
16
- end
17
-
18
- platforms :jruby do
19
- gem "jdbc-postgres"
20
- gem "jdbc-sqlite3"
21
- end
data/ci/Gemfile.rails-4.1 DELETED
@@ -1,21 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path => "../"
4
-
5
- gem 'railties', '~> 4.1.0'
6
-
7
- gem "test-unit"
8
- gem "test_declarative"
9
- gem "mocha"
10
- gem "rake"
11
- gem "timecop"
12
-
13
- platforms :ruby do
14
- gem "pg"
15
- gem "sqlite3"
16
- end
17
-
18
- platforms :jruby do
19
- gem "jdbc-postgres"
20
- gem "jdbc-sqlite3"
21
- end
data/ci/Gemfile.rails-4.2 DELETED
@@ -1,21 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec :path => "../"
4
-
5
- gem 'railties', '~> 4.2.0'
6
-
7
- gem "test-unit"
8
- gem "test_declarative"
9
- gem "mocha"
10
- gem "rake"
11
- gem "timecop"
12
-
13
- platforms :ruby do
14
- gem "pg"
15
- gem "sqlite3"
16
- end
17
-
18
- platforms :jruby do
19
- gem "jdbc-postgres"
20
- gem "jdbc-sqlite3"
21
- end