Class: XDep::CSVOutput

Inherits:
Output
  • Object
show all
Defined in:
lib/xdep/output.rb

Direct Known Subclasses

Npm::CSVOutput, Ruby::CSV

Constant Summary collapse

HEADER =
%w[Language Name Version Description Homepage License].freeze

Instance Method Summary collapse

Methods inherited from Output

accepts?, #initialize

Constructor Details

This class inherits a constructor from XDep::Output

Instance Method Details

#process(input, output) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/xdep/output.rb', line 27

def process(input, output)
  rows = get_rows(input)
  rows.sort_by! { |r| r[1] }

  mode = output.pos.zero? ? "w" : "a"
  CSV.open(output, mode) do |csv|
    csv << HEADER if output.pos.zero?
    rows.each { |r| csv << r }
  end
end