Class: Kiba::Extend::Command::Project::EmptyFieldReport

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/extend/command/project/empty_field_report.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tags:, output:, boolean: :and) ⇒ EmptyFieldReport

Returns a new instance of EmptyFieldReport.

Parameters:

  • tags (Array<Symbol>)

    used to identify registry entries to report on

  • output (String)

    path to output file

  • boolean (:and, :or) (defaults to: :and)

    used to combine multiple tags



18
19
20
21
22
# File 'lib/kiba/extend/command/project/empty_field_report.rb', line 18

def initialize(tags:, output:, boolean: :and)
  @tags = tags
  @output = output
  @boolean = boolean
end

Instance Attribute Details

#booleanObject (readonly)

Returns the value of attribute boolean.



12
13
14
# File 'lib/kiba/extend/command/project/empty_field_report.rb', line 12

def boolean
  @boolean
end

#outputObject (readonly)

Returns the value of attribute output.



12
13
14
# File 'lib/kiba/extend/command/project/empty_field_report.rb', line 12

def output
  @output
end

#tagsObject (readonly)

Returns the value of attribute tags.



12
13
14
# File 'lib/kiba/extend/command/project/empty_field_report.rb', line 12

def tags
  @tags
end

Class Method Details

.callObject



8
9
10
# File 'lib/kiba/extend/command/project/empty_field_report.rb', line 8

def self.call(...)
  new(...).call
end

Instance Method Details

#callObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/kiba/extend/command/project/empty_field_report.rb', line 24

def call
  headers = %i[table field]
  CSV.open(output, "w", headers: headers,
    write_headers: true) do |csv|
    entries.map { |entry| id_empty_fields(entry) }
      .flatten
      .each { |row| csv << row.values_at(*headers) }
  end

  puts "Wrote empty field report to #{output}"
end