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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e82d6b46459095203aa62a7333fa25ab91230431
4
- data.tar.gz: 12e5f597f31938450a506bcc887dba4e3ef1842f
3
+ metadata.gz: e667f045b627932973bb7818c2c3fc6a3f7450a1
4
+ data.tar.gz: 9bc577d40f8abe15dc27136b7add5b3813b93e8c
5
5
  SHA512:
6
- metadata.gz: 04ec157dbc55d7329a11b3c45e0906cce182f58b7cecd4225f94cb0e345a00aeadd0e315f9ce95df18c7c27ddcd51f1e7dc59484c6d10c728c7c96da228bdfb4
7
- data.tar.gz: 3216bf771d840636770338661da646139b81d624a729ee09c463a353095f33739930884039b646183e2e580183700460d9944602ac3def5869aaf12a313eff6d
6
+ metadata.gz: 0e52080a119b57b13a4badf68056ffe6e92c31b7e67e9d240b8891cad7f3583d0463e790ef1d9e5dbef26f700247b3468c9ed160d86bb9b854ac8ae0738e43b1
7
+ data.tar.gz: b22a32d057449f8688228c33148475049d2219e2a02d7ce9399ba682fd6481ee7c93a8e8444b4471fa4aa988f1b5a3e4b7038bfce40718f1f9d22e7a4b462db1
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Samidare
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: samidare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryoji Kobori