i18n-sequel_bitemporal 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +18 -6
- data/Gemfile +1 -0
- data/README.textile +20 -1
- data/ci/{Gemfile.rails-3.x → Gemfile.rails-3.2} +2 -1
- data/ci/{Gemfile.rails-3.x-i18n-0.6 → Gemfile.rails-4.0} +2 -1
- data/ci/Gemfile.rails-4.1 +23 -0
- data/ci/Gemfile.rails-4.2 +23 -0
- data/i18n-sequel_bitemporal.gemspec +1 -1
- data/lib/i18n/backend/sequel_bitemporal.rb +16 -0
- data/lib/i18n/backend/sequel_bitemporal/translation.rb +2 -2
- data/lib/i18n/sequel_bitemporal/version.rb +1 -1
- data/test/api_test.rb +1 -2
- data/test/missing_test.rb +2 -2
- data/test/sequel_cache_test.rb +1 -1
- data/test/sequel_test.rb +56 -1
- data/test/test_helper.rb +11 -3
- metadata +12 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd33458823a537773be7030596348d77748afa26
|
4
|
+
data.tar.gz: 2cd8bfe9ca96357fb7cc58bdef0e7ec6a6ce10df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4ac6a80844e7eb02fe26726035bb9969806b8a12abd80d46c75307f7666a20b68e820c388751c732045754477d89acd02633bfb7baa3153629721584edc1b6b
|
7
|
+
data.tar.gz: 800e91ef1b16110e16509541586e56eb5bff5b2c612c3a24ba34db1984740d2d80b6552e5bb6301ec1beba56239cbba3ca2a64922f65822f61dd7d354ac63144
|
data/.travis.yml
CHANGED
@@ -1,21 +1,33 @@
|
|
1
|
+
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
sudo: false
|
1
4
|
rvm:
|
2
5
|
- 1.9.3
|
3
|
-
- 2.0
|
4
|
-
- 2.1
|
6
|
+
- 2.0
|
7
|
+
- 2.1
|
8
|
+
- 2.2
|
5
9
|
- jruby-19mode
|
6
10
|
env:
|
7
11
|
- ADAPTER=sqlite3
|
8
12
|
- ADAPTER=postgres
|
9
13
|
gemfile:
|
10
|
-
- ci/Gemfile.rails-3.
|
11
|
-
- ci/Gemfile.rails-
|
14
|
+
- ci/Gemfile.rails-3.2
|
15
|
+
- ci/Gemfile.rails-4.0
|
16
|
+
- ci/Gemfile.rails-4.1
|
17
|
+
- ci/Gemfile.rails-4.2
|
12
18
|
matrix:
|
13
19
|
exclude:
|
14
20
|
- rvm: jruby-19mode
|
15
21
|
env: ADAPTER=sqlite3
|
16
|
-
gemfile: ci/Gemfile.rails-3.
|
22
|
+
gemfile: ci/Gemfile.rails-3.2
|
17
23
|
- rvm: jruby-19mode
|
18
24
|
env: ADAPTER=sqlite3
|
19
|
-
gemfile: ci/Gemfile.rails-
|
25
|
+
gemfile: ci/Gemfile.rails-4.0
|
26
|
+
- rvm: jruby-19mode
|
27
|
+
env: ADAPTER=sqlite3
|
28
|
+
gemfile: ci/Gemfile.rails-4.1
|
29
|
+
- rvm: jruby-19mode
|
30
|
+
env: ADAPTER=sqlite3
|
31
|
+
gemfile: ci/Gemfile.rails-4.2
|
20
32
|
before_script:
|
21
33
|
- psql -c 'create database i18n_sequel_bitemporal;' -U postgres
|
data/Gemfile
CHANGED
data/README.textile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
!https://travis-ci.org/TalentBox/i18n-sequel_bitemporal.svg?branch=master!:https://travis-ci.org/TalentBox/i18n-sequel_bitemporal
|
2
|
+
|
1
3
|
h1. I18n::Backend::SequelBitemporal
|
2
4
|
|
3
5
|
This repository contains an "I18n":http://github.com/svenfuchs/i18n Sequel
|
@@ -21,7 +23,7 @@ or to track master's HEAD:
|
|
21
23
|
|
22
24
|
<pre>
|
23
25
|
gem 'i18n-sequel_bitemporal',
|
24
|
-
:
|
26
|
+
:github => 'TalentBox/i18n-sequel_bitemporal',
|
25
27
|
:require => 'i18n/sequel_bitemporal'
|
26
28
|
</pre>
|
27
29
|
|
@@ -87,6 +89,23 @@ Memoization is highly recommended if you use a DB as your backend.
|
|
87
89
|
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend)
|
88
90
|
</pre>
|
89
91
|
|
92
|
+
You can also customize table names for the backing models:
|
93
|
+
|
94
|
+
<pre>
|
95
|
+
require 'i18n/backend/sequel_bitemporal'
|
96
|
+
I18n::Backend::SequelBitemporal.master_table_name = :my_translations
|
97
|
+
I18n::Backend::SequelBitemporal.version_table_name = :my_translation_versions
|
98
|
+
</pre>
|
99
|
+
|
100
|
+
Please note names can be anything you can use in `Sequel::Model#set_dataset`.
|
101
|
+
For example you want your translations table to be in a specific schema:
|
102
|
+
|
103
|
+
<pre>
|
104
|
+
require 'i18n/backend/sequel_bitemporal'
|
105
|
+
I18n::Backend::SequelBitemporal.master_table_name = Sequel.qualify(:translations, :i18n_translations)
|
106
|
+
I18n::Backend::SequelBitemporal.version_table_name = Sequel.qualify(:translations, :i18n_translation_versions)
|
107
|
+
</pre>
|
108
|
+
|
90
109
|
h2. Usage
|
91
110
|
|
92
111
|
You can now use @I18n.t('Your String')@ to lookup translations in the database.
|
@@ -0,0 +1,23 @@
|
|
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 "mysql"
|
16
|
+
gem "sqlite3"
|
17
|
+
end
|
18
|
+
|
19
|
+
platforms :jruby do
|
20
|
+
gem "jdbc-postgres"
|
21
|
+
gem "jdbc-mysql"
|
22
|
+
gem "jdbc-sqlite3"
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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 "mysql"
|
16
|
+
gem "sqlite3"
|
17
|
+
end
|
18
|
+
|
19
|
+
platforms :jruby do
|
20
|
+
gem "jdbc-postgres"
|
21
|
+
gem "jdbc-mysql"
|
22
|
+
gem "jdbc-sqlite3"
|
23
|
+
end
|
@@ -19,6 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_dependency "i18n", ">= 0.
|
22
|
+
s.add_dependency "i18n", ">= 0.6", "< 0.8.0"
|
23
23
|
s.add_dependency "sequel_bitemporal", "~> 0.8.0"
|
24
24
|
end
|
@@ -7,6 +7,22 @@ module I18n
|
|
7
7
|
autoload :StoreProcs, 'i18n/backend/sequel_bitemporal/store_procs'
|
8
8
|
autoload :Translation, 'i18n/backend/sequel_bitemporal/translation'
|
9
9
|
|
10
|
+
def self.master_table_name=(table_name)
|
11
|
+
@master_table_name = table_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.master_table_name
|
15
|
+
@master_table_name || :i18n_translations
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.version_table_name=(table_name)
|
19
|
+
@version_table_name = table_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.version_table_name
|
23
|
+
@version_table_name || :i18n_translation_versions
|
24
|
+
end
|
25
|
+
|
10
26
|
module Implementation
|
11
27
|
include Base, Flatten
|
12
28
|
|
@@ -57,7 +57,7 @@ module I18n
|
|
57
57
|
# Translation.find_by_locale_and_key('en', 'foo').value
|
58
58
|
# # => 'FOO'
|
59
59
|
class SequelBitemporal
|
60
|
-
class TranslationVersion < ::Sequel::Model(
|
60
|
+
class TranslationVersion < ::Sequel::Model(::I18n::Backend::SequelBitemporal.version_table_name)
|
61
61
|
plugin :serialization
|
62
62
|
|
63
63
|
TRUTHY_CHAR = "\001"
|
@@ -100,7 +100,7 @@ module I18n
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
class Translation < ::Sequel::Model(
|
103
|
+
class Translation < ::Sequel::Model(::I18n::Backend::SequelBitemporal.master_table_name)
|
104
104
|
extend Forwardable
|
105
105
|
plugin :bitemporal, version_class: TranslationVersion
|
106
106
|
|
data/test/api_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path('../test_helper', __FILE__)
|
2
2
|
|
3
|
-
class I18nSequelBitemporalApiTest <
|
3
|
+
class I18nSequelBitemporalApiTest < I18nBitemporalTest
|
4
4
|
def setup
|
5
5
|
I18n::Backend::SequelBitemporal::Translation.dataset.delete
|
6
6
|
I18n.backend = I18n::Backend::SequelBitemporal.new
|
@@ -28,4 +28,3 @@ class I18nSequelBitemporalApiTest < Test::Unit::TestCase
|
|
28
28
|
assert_equal I18n::Backend::SequelBitemporal, I18n.backend.class
|
29
29
|
end
|
30
30
|
end if defined?(Sequel)
|
31
|
-
|
data/test/missing_test.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require File.expand_path('../test_helper', __FILE__)
|
2
2
|
|
3
|
-
class I18nSequelBitemporalMissingTest <
|
3
|
+
class I18nSequelBitemporalMissingTest < I18nBitemporalTest
|
4
4
|
class Backend < I18n::Backend::SequelBitemporal
|
5
5
|
include I18n::Backend::SequelBitemporal::Missing
|
6
6
|
end
|
7
7
|
|
8
8
|
def setup
|
9
|
+
super
|
9
10
|
I18n.backend.store_translations(:en, :bar => 'Bar', :i18n => { :plural => { :keys => [:zero, :one, :other] } })
|
10
11
|
I18n.backend = I18n::Backend::Chain.new(Backend.new, I18n.backend)
|
11
12
|
I18n::Backend::SequelBitemporal::Translation.dataset.delete
|
@@ -68,4 +69,3 @@ class I18nSequelBitemporalMissingTest < Test::Unit::TestCase
|
|
68
69
|
end
|
69
70
|
|
70
71
|
end if defined?(Sequel)
|
71
|
-
|
data/test/sequel_cache_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path('../test_helper', __FILE__)
|
2
2
|
|
3
|
-
class I18nBackendSequelBitemporalCacheTest <
|
3
|
+
class I18nBackendSequelBitemporalCacheTest < I18nBitemporalTest
|
4
4
|
def clear_all
|
5
5
|
I18n::Backend::SequelBitemporal::Translation.dataset.delete
|
6
6
|
end
|
data/test/sequel_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path('../test_helper', __FILE__)
|
2
2
|
|
3
|
-
class I18nBackendSequelBitemporalTest <
|
3
|
+
class I18nBackendSequelBitemporalTest < I18nBitemporalTest
|
4
4
|
def clear_all
|
5
5
|
I18n::Backend::SequelBitemporal::Translation.dataset.delete
|
6
6
|
end
|
@@ -63,4 +63,59 @@ class I18nBackendSequelBitemporalTest < Test::Unit::TestCase
|
|
63
63
|
assert_equal %w(foo foo.bar foo.bar.baz), I18n.backend.send(:expand_keys, :'foo.bar.baz')
|
64
64
|
end
|
65
65
|
|
66
|
+
test "allows to override the table names" do
|
67
|
+
::Sequel::Model.db.transaction :rollback => :always do
|
68
|
+
begin
|
69
|
+
::Sequel.migration do
|
70
|
+
change do
|
71
|
+
create_table :another_i18n_translations do
|
72
|
+
primary_key :id
|
73
|
+
String :locale, :null => false
|
74
|
+
String :key, :null => false
|
75
|
+
index [:locale, :key], :unique => true
|
76
|
+
end
|
77
|
+
|
78
|
+
create_table :another_i18n_translation_versions do
|
79
|
+
primary_key :id
|
80
|
+
foreign_key :master_id, :another_i18n_translations, :on_delete => :cascade
|
81
|
+
Time :created_at
|
82
|
+
Time :expired_at
|
83
|
+
Date :valid_from
|
84
|
+
Date :valid_to
|
85
|
+
String :value, :text => true
|
86
|
+
String :interpolations, :text => true
|
87
|
+
TrueClass :is_proc, :null => false, :default => false
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end.apply(::Sequel::Model.db, :up)
|
91
|
+
change_table_names(
|
92
|
+
:another_i18n_translations,
|
93
|
+
:another_i18n_translation_versions
|
94
|
+
)
|
95
|
+
|
96
|
+
assert_equal(
|
97
|
+
::I18n::Backend::SequelBitemporal::Translation.table_name,
|
98
|
+
:another_i18n_translations
|
99
|
+
)
|
100
|
+
assert_equal(
|
101
|
+
::I18n::Backend::SequelBitemporal::TranslationVersion.table_name,
|
102
|
+
:another_i18n_translation_versions
|
103
|
+
)
|
104
|
+
ensure
|
105
|
+
change_table_names nil, nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def change_table_names(master_name, version_name)
|
111
|
+
::I18n::Backend::SequelBitemporal.master_table_name = master_name
|
112
|
+
::I18n::Backend::SequelBitemporal.version_table_name = version_name
|
113
|
+
::I18n::Backend::SequelBitemporal.send :remove_const, :Translation
|
114
|
+
::I18n::Backend::SequelBitemporal.send :remove_const, :TranslationVersion
|
115
|
+
load File.expand_path(
|
116
|
+
"../../lib/i18n/backend/sequel_bitemporal/translation.rb",
|
117
|
+
__FILE__
|
118
|
+
)
|
119
|
+
end
|
120
|
+
|
66
121
|
end if defined?(Sequel)
|
data/test/test_helper.rb
CHANGED
@@ -12,17 +12,25 @@ require 'test_declarative'
|
|
12
12
|
require 'timecop'
|
13
13
|
I18n::Tests.setup_sequel
|
14
14
|
|
15
|
-
class Test::Unit::TestCase
|
15
|
+
class I18nBitemporalTest < Test::Unit::TestCase
|
16
16
|
def self.with_mocha
|
17
17
|
yield if Object.respond_to?(:expects)
|
18
18
|
end
|
19
19
|
|
20
|
+
def setup
|
21
|
+
super
|
22
|
+
I18n.enforce_available_locales = false
|
23
|
+
end
|
24
|
+
|
20
25
|
def teardown
|
21
26
|
I18n.locale = nil
|
22
|
-
I18n.default_locale =
|
23
|
-
I18n.load_path =
|
27
|
+
I18n.default_locale = nil
|
28
|
+
I18n.load_path = nil
|
24
29
|
I18n.available_locales = nil
|
25
30
|
I18n.backend = nil
|
31
|
+
I18n.default_separator = nil
|
32
|
+
I18n.enforce_available_locales = true
|
33
|
+
super
|
26
34
|
end
|
27
35
|
|
28
36
|
def translations
|
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.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Tron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.6'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: 0.8.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0.
|
29
|
+
version: '0.6'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.8.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: sequel_bitemporal
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,8 +60,10 @@ files:
|
|
60
60
|
- MIT-LICENSE
|
61
61
|
- README.textile
|
62
62
|
- Rakefile
|
63
|
-
- ci/Gemfile.rails-3.
|
64
|
-
- ci/Gemfile.rails-
|
63
|
+
- ci/Gemfile.rails-3.2
|
64
|
+
- ci/Gemfile.rails-4.0
|
65
|
+
- ci/Gemfile.rails-4.1
|
66
|
+
- ci/Gemfile.rails-4.2
|
65
67
|
- i18n-sequel_bitemporal.gemspec
|
66
68
|
- lib/i18n/backend/sequel_bitemporal.rb
|
67
69
|
- lib/i18n/backend/sequel_bitemporal/missing.rb
|
@@ -95,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
97
|
version: '0'
|
96
98
|
requirements: []
|
97
99
|
rubyforge_project: "[none]"
|
98
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.4.5
|
99
101
|
signing_key:
|
100
102
|
specification_version: 4
|
101
103
|
summary: I18n Bitemporal Sequel backend
|
@@ -107,3 +109,4 @@ test_files:
|
|
107
109
|
- test/sequel_test.rb
|
108
110
|
- test/test_helper.rb
|
109
111
|
- test/test_setup.rb
|
112
|
+
has_rdoc:
|