Class: Cucover::Recording::CoveredFile

Inherits:
Object
  • Object
show all
Defined in:
lib/cucover/recording/covered_file.rb

Defined Under Namespace

Modules: HasLineNumberDetail

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_filename, rcov_marked_info, recording) ⇒ CoveredFile

Returns a new instance of CoveredFile.



5
6
7
8
9
10
11
12
# File 'lib/cucover/recording/covered_file.rb', line 5

def initialize(full_filename, rcov_marked_info, recording)
  @full_filename    = full_filename
  @rcov_marked_info = rcov_marked_info
  @recording        = recording
  @file = File.expand_path(full_filename).gsub(/^#{Dir.pwd}\//, '')

  extend HasLineNumberDetail if @rcov_marked_info
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



3
4
5
# File 'lib/cucover/recording/covered_file.rb', line 3

def file
  @file
end

Instance Method Details

#==(other) ⇒ Object



26
27
28
# File 'lib/cucover/recording/covered_file.rb', line 26

def ==(other)
  other == file
end

#covers_line?(line_number) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/cucover/recording/covered_file.rb', line 22

def covers_line?(line_number)
  covered_lines.include?(line_number)
end

#dirty?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
# File 'lib/cucover/recording/covered_file.rb', line 14

def dirty?
  Cucover.logger.debug("#{file}     last modified at #{File.mtime(@full_filename)}")
  Cucover.logger.debug("#{file} recording started at #{@recording.start_time}")
  result = File.mtime(@full_filename).to_i >= @recording.start_time.to_i
  Cucover.logger.debug("verdict: #{(result ? "dirty" : "not dirty")}")
  result
end

#to_sObject



30
31
32
# File 'lib/cucover/recording/covered_file.rb', line 30

def to_s
  "#{file}:#{covered_lines.join(':')}"
end