Class: Naginegi::Embulk

Inherits:
Object
  • Object
show all
Defined in:
lib/naginegi/embulk.rb

Instance Method Summary collapse

Constructor Details

#initialize(log_level, embulk_run_option) ⇒ Embulk

Returns a new instance of Embulk.



5
6
7
8
9
10
11
# File 'lib/naginegi/embulk.rb', line 5

def initialize(log_level, embulk_run_option)
  @logger = Logger.new(STDOUT)
  @logger.datetime_format = '%Y-%m-%d %H:%M:%S'

  @log_level = log_level
  @embulk_run_option = embulk_run_option
end

Instance Method Details

#run(db_configs, all_table_configs, bq_config, target_table_names = []) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/naginegi/embulk.rb', line 13

def run(db_configs, all_table_configs, bq_config, target_table_names = [])
  error_tables = []
  db_configs.keys.each do |db_name|
    table_configs = select_table_configs(all_table_configs[db_name], target_table_names)
    error_tables += run_by_database(
      db_name,
      table_configs,
      bq_config,
      db_configs[db_name]['bq_dataset']
    )
  end
  error_tables
end

#select_table_configs(table_configs, target_table_names) ⇒ Object



27
28
29
30
# File 'lib/naginegi/embulk.rb', line 27

def select_table_configs(table_configs, target_table_names)
  return table_configs if target_table_names.empty?
  table_configs.select { |table_config| target_table_names.include?(table_config.name) }
end