Class: Cucover::CliCommands::CoverageOf
- Inherits:
-
Object
- Object
- Cucover::CliCommands::CoverageOf
- Defined in:
- lib/cucover/cli_commands/coverage_of.rb
Constant Summary collapse
- CODE_COLUMN_WIDTH =
15
Instance Method Summary collapse
- #coverage(line_number) ⇒ Object
- #execute ⇒ Object
-
#initialize(cli_args) ⇒ CoverageOf
constructor
A new instance of CoverageOf.
- #recordings ⇒ Object
Constructor Details
#initialize(cli_args) ⇒ CoverageOf
Returns a new instance of CoverageOf.
6 7 8 9 |
# File 'lib/cucover/cli_commands/coverage_of.rb', line 6 def initialize(cli_args) @filespec = cli_args[1] @store = Store.new end |
Instance Method Details
#coverage(line_number) ⇒ Object
28 29 30 |
# File 'lib/cucover/cli_commands/coverage_of.rb', line 28 def coverage(line_number) recordings.select{ |r| r.covers_line?(@filespec, line_number) }.map{ |r| r.file_colon_line } end |
#execute ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cucover/cli_commands/coverage_of.rb', line 11 def execute load_cucumber_enviroment return unless recordings.any? File.open(@filespec).each_with_index do |line_content, index| line_number = index + 1 coverage_text = coverage(line_number).join(', ') line_content.rstrip! if line_content.length > CODE_COLUMN_WIDTH truncated_line_content = "#{line_content[0..(CODE_COLUMN_WIDTH - 1)]}.." else truncated_line_content = "#{line_content} " end puts "#{line_number} #{truncated_line_content.ljust(CODE_COLUMN_WIDTH + 2)} #{coverage_text}" end end |
#recordings ⇒ Object
32 33 34 |
# File 'lib/cucover/cli_commands/coverage_of.rb', line 32 def recordings @recordings ||= @store.recordings_covering(@filespec) end |