Sha256: 6174b7a5b50d2bcc29852226a1dc09601a83b1f00501590ff5578060ae418bf3

Contents?: true

Size: 515 Bytes

Versions: 1

Compression:

Stored size: 515 Bytes

Contents

require "csv"

module RspecOverview
  module Output
    class Csv
      def initialize(headings:, rows:)
        @headings = headings
        @rows = rows
      end

      def to_s
        csv_content
      end

      private

      attr_reader :headings, :rows

      def csv_content
        CSV.generate(**csv_options, headers: headings) do |csv|
          rows.each { |row| csv << row }
        end
      end

      def csv_options
        { write_headers: true, force_quotes: true }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec_overview-0.3.0 lib/rspec_overview/output/csv.rb