Class: TestProf::RSpecStamp::Stamper

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/test_prof/rspec_stamp.rb

Overview

Stamper collects statistics about applying tags to examples.

Constant Summary

Constants included from Logging

Logging::COLORS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

#build_log_msg, #colorize, #log

Constructor Details

#initializeStamper

Returns a new instance of Stamper.



56
57
58
59
60
# File 'lib/test_prof/rspec_stamp.rb', line 56

def initialize
  @total = 0
  @failed = 0
  @ignored = 0
end

Instance Attribute Details

#failedObject (readonly)

Returns the value of attribute failed.



54
55
56
# File 'lib/test_prof/rspec_stamp.rb', line 54

def failed
  @failed
end

#ignoredObject (readonly)

Returns the value of attribute ignored.



54
55
56
# File 'lib/test_prof/rspec_stamp.rb', line 54

def ignored
  @ignored
end

#totalObject (readonly)

Returns the value of attribute total.



54
55
56
# File 'lib/test_prof/rspec_stamp.rb', line 54

def total
  @total
end

Instance Method Details

#stamp_file(file, lines) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/test_prof/rspec_stamp.rb', line 62

def stamp_file(file, lines)
  @total += lines.size
  return if ignored?(file)

  log :info, "(dry-run) Patching #{file}" if dry_run?

  code = File.readlines(file)

  @failed += RSpecStamp.apply_tags(code, lines, RSpecStamp.config.tags)

  File.write(file, code.join) unless dry_run?
end