samidare 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/samidare.rb +10 -3
- data/lib/samidare/version.rb +1 -1
- data/spec/samidare_spec.rb +23 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e667f045b627932973bb7818c2c3fc6a3f7450a1
|
4
|
+
data.tar.gz: 9bc577d40f8abe15dc27136b7add5b3813b93e8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e52080a119b57b13a4badf68056ffe6e92c31b7e67e9d240b8891cad7f3583d0463e790ef1d9e5dbef26f700247b3468c9ed160d86bb9b854ac8ae0738e43b1
|
7
|
+
data.tar.gz: b22a32d057449f8688228c33148475049d2219e2a02d7ce9399ba682fd6481ee7c93a8e8444b4471fa4aa988f1b5a3e4b7038bfce40718f1f9d22e7a4b462db1
|
data/lib/samidare.rb
CHANGED
@@ -7,19 +7,21 @@ module Samidare
|
|
7
7
|
Samidare::EmbulkUtility::ConfigGenerator.new(config).generate_config
|
8
8
|
end
|
9
9
|
|
10
|
-
def run(config)
|
10
|
+
def run(config, target_tables = [])
|
11
11
|
db_infos = Samidare::EmbulkUtility::DBInfo.generate_db_infos
|
12
12
|
table_infos = Samidare::EmbulkUtility::TableInfo.generate_table_infos
|
13
13
|
db_infos.keys.each do |db_name|
|
14
|
-
embulk_run(db_name, db_infos[db_name]['bq_dataset'], table_infos[db_name], config)
|
14
|
+
embulk_run(db_name, db_infos[db_name]['bq_dataset'], table_infos[db_name], config, target_tables)
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
|
-
def embulk_run(db_name, bq_dataset, tables, config)
|
19
|
+
def embulk_run(db_name, bq_dataset, tables, config, target_tables)
|
20
20
|
process_times = []
|
21
21
|
big_query = Samidare::BigQueryUtility.new(config)
|
22
22
|
tables.each do |table|
|
23
|
+
next unless target_table?(table.name, target_tables)
|
24
|
+
|
23
25
|
start_time = Time.now
|
24
26
|
log "table: #{table.name} - start"
|
25
27
|
|
@@ -44,6 +46,11 @@ module Samidare
|
|
44
46
|
process_times.each { |process_time| log process_time }
|
45
47
|
end
|
46
48
|
|
49
|
+
def target_table?(table, target_tables)
|
50
|
+
return true if target_tables.empty?
|
51
|
+
target_tables.include?(table)
|
52
|
+
end
|
53
|
+
|
47
54
|
def log(message)
|
48
55
|
puts "[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] #{message}"
|
49
56
|
end
|
data/lib/samidare/version.rb
CHANGED
data/spec/samidare_spec.rb
CHANGED
@@ -4,4 +4,27 @@ describe Samidare do
|
|
4
4
|
it 'has a version number' do
|
5
5
|
expect(Samidare::VERSION).not_to be nil
|
6
6
|
end
|
7
|
+
|
8
|
+
describe Samidare::EmbulkClient do
|
9
|
+
describe '#target_table?' do
|
10
|
+
subject { Samidare::EmbulkClient.new.send(:target_table?, table, target_tables) }
|
11
|
+
context 'target_tables is empty' do
|
12
|
+
let(:table) { 'hoge' }
|
13
|
+
let(:target_tables) { [] }
|
14
|
+
it { expect(subject).to be_truthy }
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'is included' do
|
18
|
+
let(:table) { 'hoge' }
|
19
|
+
let(:target_tables) { ['hoge'] }
|
20
|
+
it { expect(subject).to be_truthy }
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'is not included' do
|
24
|
+
let(:table) { 'hoge' }
|
25
|
+
let(:target_tables) { ['fuga'] }
|
26
|
+
it { expect(subject).to be_falsy }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
7
30
|
end
|