txdb 3.1.0 → 4.0.0
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 +4 -4
- data/lib/txdb/backends/globalize/reader.rb +3 -3
- data/lib/txdb/database.rb +3 -0
- data/lib/txdb/downloader.rb +2 -8
- data/lib/txdb/handlers/triggers/pull_handler.rb +1 -7
- data/lib/txdb/iterators/globalize_iterator.rb +1 -1
- data/lib/txdb/table.rb +0 -2
- data/lib/txdb/version.rb +1 -1
- data/spec/backends/globalize/writer_spec.rb +2 -2
- data/spec/config_spec.rb +1 -2
- data/spec/handlers/triggers/pull_handler_spec.rb +2 -4
- data/spec/iterators/auto_increment_iterator_spec.rb +0 -1
- data/spec/iterators/globalize_iterator_spec.rb +0 -1
- data/spec/spec_helpers/globalize_configurator.rb +0 -1
- data/spec/spec_helpers/test_backend.rb +1 -1
- data/spec/spec_helpers/test_configurator.rb +4 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26654801172fbb542a042bcb6a0449b76ed7b5e7
|
4
|
+
data.tar.gz: deca843a00c592d7f8170c6616e40978b43c99a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a788e05c2df484b71aa34676f91717d54a53b467f58f0c2c3845b93a5913bddc8afc1291daf21e6d92a9f3922e3a848f6d37d48b48106035a7cf43e12adb611c
|
7
|
+
data.tar.gz: 2436f1495010364e154322a7896fd1cccf37ca1f6e2534bd182ef72e0e15692da64ec231011c13b51578eb13bf40d62b01246edfe05a5094169537a09dc70e05
|
@@ -22,7 +22,7 @@ module Txdb
|
|
22
22
|
def resource
|
23
23
|
@resource ||= Txgh::TxResource.new(
|
24
24
|
project_slug, resource_slug, Globalize::Backend::RESOURCE_TYPE,
|
25
|
-
|
25
|
+
source_locale, source_file, nil, nil
|
26
26
|
)
|
27
27
|
end
|
28
28
|
|
@@ -34,8 +34,8 @@ module Txdb
|
|
34
34
|
resource_slug_for(table)
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
table.
|
37
|
+
def source_locale
|
38
|
+
table.database.source_locale
|
39
39
|
end
|
40
40
|
|
41
41
|
def source_file
|
data/lib/txdb/database.rb
CHANGED
@@ -8,6 +8,7 @@ module Txdb
|
|
8
8
|
|
9
9
|
attr_reader :adapter, :backend, :username, :password, :host, :port, :name
|
10
10
|
attr_reader :pool, :transifex_project, :tables, :connection_string
|
11
|
+
attr_reader :locales, :source_locale
|
11
12
|
|
12
13
|
def initialize(options = {})
|
13
14
|
@adapter = options.fetch(:adapter)
|
@@ -18,6 +19,8 @@ module Txdb
|
|
18
19
|
@port = options.fetch(:port, DEFAULT_PORT)
|
19
20
|
@name = options.fetch(:name)
|
20
21
|
@pool = options.fetch(:pool, DEFAULT_POOL)
|
22
|
+
@locales = options.fetch(:locales)
|
23
|
+
@source_locale = options.fetch(:source_locale)
|
21
24
|
@transifex_project = TransifexProject.new(options.fetch(:transifex))
|
22
25
|
@connection_string = ConnectionString.new(options).string
|
23
26
|
@tables = options.fetch(:tables).map do |table_config|
|
data/lib/txdb/downloader.rb
CHANGED
@@ -20,8 +20,8 @@ module Txdb
|
|
20
20
|
|
21
21
|
def download_all
|
22
22
|
database.tables.each do |table|
|
23
|
-
locales.each do |locale|
|
24
|
-
next if locale ==
|
23
|
+
database.locales.each do |locale|
|
24
|
+
next if locale == database.source_locale
|
25
25
|
download_table(table, locale)
|
26
26
|
end
|
27
27
|
end
|
@@ -67,11 +67,5 @@ module Txdb
|
|
67
67
|
Txgh::TxResource.from_api_response(project_slug, resource_hash)
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
71
|
-
def locales
|
72
|
-
@locales ||= database.transifex_api
|
73
|
-
.get_languages(database.transifex_project.project_slug)
|
74
|
-
.map { |locale| locale['language_code'] }
|
75
|
-
end
|
76
70
|
end
|
77
71
|
end
|
@@ -5,7 +5,7 @@ module Txdb
|
|
5
5
|
class PullHandler < Handler
|
6
6
|
def handle
|
7
7
|
handle_safely do
|
8
|
-
locales.each do |locale|
|
8
|
+
database.locales.each do |locale|
|
9
9
|
downloader.download_table(table, locale)
|
10
10
|
end
|
11
11
|
|
@@ -18,12 +18,6 @@ module Txdb
|
|
18
18
|
def downloader
|
19
19
|
@downloader ||= Downloader.new(database)
|
20
20
|
end
|
21
|
-
|
22
|
-
def locales
|
23
|
-
database.transifex_api
|
24
|
-
.get_languages(database.transifex_project.project_slug)
|
25
|
-
.map { |locale| locale['language_code'] }
|
26
|
-
end
|
27
21
|
end
|
28
22
|
|
29
23
|
end
|
data/lib/txdb/table.rb
CHANGED
@@ -3,13 +3,11 @@ require 'txgh'
|
|
3
3
|
module Txdb
|
4
4
|
class Table
|
5
5
|
attr_reader :database, :name, :columns
|
6
|
-
attr_reader :source_lang
|
7
6
|
|
8
7
|
def initialize(database, options = {})
|
9
8
|
@database = database
|
10
9
|
@name = options.fetch(:name)
|
11
10
|
@columns = options.fetch(:columns)
|
12
|
-
@source_lang = options.fetch(:source_lang)
|
13
11
|
end
|
14
12
|
|
15
13
|
def connection
|
data/lib/txdb/version.rb
CHANGED
@@ -11,11 +11,11 @@ describe Globalize::Writer, globalize_config: true do
|
|
11
11
|
|
12
12
|
describe '#write_content' do
|
13
13
|
let(:base_resource) do
|
14
|
-
# project_slug, resource_slug, type,
|
14
|
+
# project_slug, resource_slug, type, source_locale, source_file,
|
15
15
|
# lang_map, translation_file
|
16
16
|
Txgh::TxResource.new(
|
17
17
|
'project_slug', 'resource_slug', Globalize::Backend::RESOURCE_TYPE,
|
18
|
-
'
|
18
|
+
'source_locale', 'source_file', nil, nil
|
19
19
|
)
|
20
20
|
end
|
21
21
|
|
data/spec/config_spec.rb
CHANGED
@@ -16,7 +16,6 @@ describe Txdb::Config do
|
|
16
16
|
Txdb::TestConfigurator.base_config.tap do |base_config|
|
17
17
|
base_config[:tables] << {
|
18
18
|
name: 'my_table',
|
19
|
-
source_lang: 'en',
|
20
19
|
columns: []
|
21
20
|
}
|
22
21
|
end
|
@@ -69,9 +68,9 @@ describe Txdb::Config do
|
|
69
68
|
# method loops over more than one db, yielding tables from each
|
70
69
|
config[:databases] << config[:databases].first.merge(
|
71
70
|
database: 'spec/test2.sqlite3',
|
71
|
+
source_locale: 'en',
|
72
72
|
tables: [
|
73
73
|
name: 'another_table',
|
74
|
-
source_lang: 'en',
|
75
74
|
columns: %w(col1 col2)
|
76
75
|
]
|
77
76
|
)
|
@@ -33,17 +33,15 @@ describe PullHandler, test_config: true do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'downloads the table for each locale' do
|
36
|
-
locales = [{ 'language_code' => 'es' }, { 'language_code' => 'ja' }]
|
37
36
|
content = { 'phrase' => 'trans' }
|
38
37
|
|
39
|
-
expect(database.transifex_api).to receive(:get_languages).and_return(locales)
|
40
38
|
allow(database.transifex_api).to receive(:download).and_return(YAML.dump(content))
|
41
39
|
expect(database.transifex_api).to receive(:get_resources).and_return(
|
42
40
|
[Txdb::TestBackend.resource.to_api_h]
|
43
41
|
)
|
44
42
|
|
45
43
|
expect { patch('/pull', params) }.to(
|
46
|
-
change { Txdb::TestBackend.writes.size }.from(0).to(2)
|
44
|
+
change { Txdb::TestBackend.writes.size }.from(0).to(2) # ja and es
|
47
45
|
)
|
48
46
|
|
49
47
|
expect(last_response.status).to eq(200)
|
@@ -66,7 +64,7 @@ describe PullHandler, test_config: true do
|
|
66
64
|
end
|
67
65
|
|
68
66
|
it 'reports errors' do
|
69
|
-
expect(database
|
67
|
+
expect(database).to receive(:locales).and_raise('jelly beans')
|
70
68
|
patch '/pull', params
|
71
69
|
expect(last_response.status).to eq(500)
|
72
70
|
expect(JSON.parse(last_response.body)).to eq(
|
@@ -63,6 +63,8 @@ module Txdb
|
|
63
63
|
username: 'username',
|
64
64
|
password: 'password',
|
65
65
|
name: 'spec/test.sqlite3',
|
66
|
+
locales: %w(es ja),
|
67
|
+
source_locale: 'en',
|
66
68
|
transifex: {
|
67
69
|
organization: 'myorg',
|
68
70
|
project_slug: 'myproject',
|
@@ -95,7 +97,7 @@ module Txdb
|
|
95
97
|
end
|
96
98
|
|
97
99
|
class TableCreator
|
98
|
-
attr_reader :name, :database, :columns
|
100
|
+
attr_reader :name, :database, :columns
|
99
101
|
|
100
102
|
def initialize(name, database, &block)
|
101
103
|
@name = name
|
@@ -117,14 +119,10 @@ module Txdb
|
|
117
119
|
add_column(column, :integer, *args)
|
118
120
|
end
|
119
121
|
|
120
|
-
def source_lang(lang)
|
121
|
-
@source_lang = lang
|
122
|
-
end
|
123
|
-
|
124
122
|
def table
|
125
123
|
Txdb::Table.new(
|
126
124
|
database, {
|
127
|
-
name: name.to_s, columns: columns
|
125
|
+
name: name.to_s, columns: columns
|
128
126
|
}
|
129
127
|
)
|
130
128
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: txdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cameron Dutro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|