Class: Dragnet::Exporter
- Inherits:
-
Object
- Object
- Dragnet::Exporter
- Defined in:
- lib/dragnet/exporter.rb
Overview
The base exporter class, receives an array of test records, an array of errors and an array of file names and exports the results to the given files. (For each file the format is deduced from its file name).
Constant Summary collapse
- KNOWN_FORMATS =
{ 'HTML' => { extensions: %w[.html .htm], exporter: Dragnet::Exporters::HTMLExporter }, 'JSON' => { extensions: %w[.json], exporter: Dragnet::Exporters::JSONExporter } }.freeze
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
-
#test_records ⇒ Object
readonly
Returns the value of attribute test_records.
Instance Method Summary collapse
-
#export ⇒ Object
Starts the export process.
-
#initialize(test_records:, errors:, repository:, targets:, logger:) ⇒ Exporter
constructor
Creates a new instance of the class.
Constructor Details
#initialize(test_records:, errors:, repository:, targets:, logger:) ⇒ Exporter
Creates a new instance of the class.
30 31 32 33 34 35 36 |
# File 'lib/dragnet/exporter.rb', line 30 def initialize(test_records:, errors:, repository:, targets:, logger:) @test_records = test_records @errors = errors @repository = repository @targets = targets @logger = logger end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
18 19 20 |
# File 'lib/dragnet/exporter.rb', line 18 def errors @errors end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
18 19 20 |
# File 'lib/dragnet/exporter.rb', line 18 def logger @logger end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
18 19 20 |
# File 'lib/dragnet/exporter.rb', line 18 def repository @repository end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
18 19 20 |
# File 'lib/dragnet/exporter.rb', line 18 def targets @targets end |
#test_records ⇒ Object (readonly)
Returns the value of attribute test_records.
18 19 20 |
# File 'lib/dragnet/exporter.rb', line 18 def test_records @test_records end |
Instance Method Details
#export ⇒ Object
Starts the export process.
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dragnet/exporter.rb', line 42 def export logger.info 'Starting export process...' log_target_files formats.each do |format, targets| exporter = KNOWN_FORMATS.dig(format, :exporter).new( test_records: test_records, errors: errors, repository: repository, logger: logger ) text = exporter.export write_output(text, format, targets) end end |