Sha256: 29c40252b2108c78da9741b9bfc123548487382861b47136464ef0a53b538e3b

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module MasterDataTool
  module Verify
    class Executor
      def initialize(spec_config:, verify_config: nil, silent: false, override_identifier: nil, report_printer: nil)
        @spec_config = spec_config
        @verify_config = verify_config || MasterDataTool::Verify::Config.default_config
        @silent = silent
        @override_identifier = override_identifier
        @report_printer = report_printer || MasterDataTool::Report::DefaultPrinter.new(spec_config: spec_config)
        @report_printer.silent = silent
      end

      def execute
        master_data_collection = build_master_data_collection
        master_data_collection.each do |master_data|
          next if verify_config.skip_table?(master_data.table_name)

          report = master_data.verify!(verify_config: verify_config, ignore_fail: false)
          report.print(printer: report_printer)
        end
      end

      private

      attr_reader :spec_config, :verify_config, :silent, :override_identifier, :report_printer

      def build_master_data_collection
        MasterDataCollection.new.tap do |collection|
          MasterDataTool::MasterDataFileCollection.new(spec_name: spec_config.spec_name, override_identifier: override_identifier).each do |master_data_file|
            master_data = MasterData.build(spec_config: spec_config, master_data_file: master_data_file, load: true)
            collection.append(master_data: master_data)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
master_data_tool-0.23.0 lib/master_data_tool/verify/executor.rb