Sha256: e648eef4d77f7cc5c3c103aba345d519cf9c4260bd3eecc52337f51ff0dc102c

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'fileutils'

module Rspeckled
module Reporting
module Outputs
class  Text
  FIELDS = {
    branch:             '%-<branch>s',
    commit_hash:        '%-8.8<commit_hash>s',
    date:               '%-<date>s',
    file:               '%-80.80<file>s',
    status:             '%-7.7<status>s',
    time:               '%7.4<time>f',
    query_count:        '%3<query_count>d',
    query_time:         '%7.4<query_time>f',
    query_percentage:   '%5.2<query_percentage>f%%',
    request_count:      '%3<request_count>d',
    request_time:       '%7.4<request_time>f',
    request_percentage: '%5.2<request_percentage>f%%',
    description:        '%-80.80<description>s',
  }.freeze

  private_constant :FIELDS

  attr_accessor :output

  def initialize
    FileUtils.mkdir_p('log')

    self.output = File.open('log/rspec_report.txt', 'a')
  end

  def insert(data)
    data[:file] = "#{data[:file].gsub(%r{^\./spec/}, './')}:#{data[:line_number]}"

    format_string = "#{FIELDS.values.join(' - ')}\n"

    output.printf(format_string, data)
  end
end
end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspeckled-2.1.1 lib/rspeckled/reporting/outputs/text.rb
rspeckled-2.1.0 lib/rspeckled/reporting/outputs/text.rb