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

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

Overview

Writes report of all empty fields in files at the paths specified by the registry entries selected by the given tags

Since:

  • 7.0.0

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

Since:

  • 7.0.0



21
22
23
24
25
# File 'lib/kiba/extend/command/project/empty_field_report.rb', line 21

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

Instance Attribute Details

#booleanObject (readonly)

Since:

  • 7.0.0



15
16
17
# File 'lib/kiba/extend/command/project/empty_field_report.rb', line 15

def boolean
  @boolean
end

#outputObject (readonly)

Since:

  • 7.0.0



15
16
17
# File 'lib/kiba/extend/command/project/empty_field_report.rb', line 15

def output
  @output
end

#tagsObject (readonly)

Since:

  • 7.0.0



15
16
17
# File 'lib/kiba/extend/command/project/empty_field_report.rb', line 15

def tags
  @tags
end

Class Method Details

.callObject

Since:

  • 7.0.0



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

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

Instance Method Details

#callObject

Since:

  • 7.0.0



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/kiba/extend/command/project/empty_field_report.rb', line 27

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