Class: Rspeckled::Reporting::Outputs::Csv

Inherits:
Object
  • Object
show all
Defined in:
lib/rspeckled/reporting/outputs/csv.rb

Constant Summary collapse

FIELDS =
%w{
  branch
  commit_hash
  date
  file
  line_number
  status
  exception
  time
  query_count
  query_time
  query_percentage
  request_count
  request_time
  request_percentage
  description
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCsv

Returns a new instance of Csv.



30
31
32
33
34
# File 'lib/rspeckled/reporting/outputs/csv.rb', line 30

def initialize
  FileUtils.mkdir_p('log')

  self.output = CSV.open('log/rspec_report.csv', 'a').tap { |csv| csv << FIELDS }
end

Instance Attribute Details

#outputObject

Returns the value of attribute output.



28
29
30
# File 'lib/rspeckled/reporting/outputs/csv.rb', line 28

def output
  @output
end

Instance Method Details

#insert(data) ⇒ Object



36
37
38
39
40
# File 'lib/rspeckled/reporting/outputs/csv.rb', line 36

def insert(data)
  output << FIELDS.map do |field|
    data.fetch(field.to_sym)
  end
end