Class: CoverMe::DirectoryReport

Inherits:
Object
  • Object
show all
Defined in:
lib/cover_me/directory_report.rb

Overview

Used to represent the directory summary.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, reports) ⇒ DirectoryReport

:nodoc:



8
9
10
11
12
13
14
15
16
17
# File 'lib/cover_me/directory_report.rb', line 8

def initialize(name, reports) # :nodoc:
  self.name = name
  self.reports = reports
  self.lines_of_code = 0
  self.lines_executed = 0
  reports.each do |report|
    self.lines_of_code += report.lines_of_code
    self.lines_executed += report.lines_executed
  end
end

Instance Attribute Details

#lines_executedObject

Returns the value of attribute lines_executed.



6
7
8
# File 'lib/cover_me/directory_report.rb', line 6

def lines_executed
  @lines_executed
end

#lines_of_codeObject

Returns the value of attribute lines_of_code.



5
6
7
# File 'lib/cover_me/directory_report.rb', line 5

def lines_of_code
  @lines_of_code
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/cover_me/directory_report.rb', line 3

def name
  @name
end

#reportsObject

Returns the value of attribute reports.



4
5
6
# File 'lib/cover_me/directory_report.rb', line 4

def reports
  @reports
end

Class Method Details

.summarize(reports) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/cover_me/directory_report.rb', line 20

def summarize(reports)
  reports_by_dir = reports.group_by do |report|
    dir_for_file(report.filename)
  end

  reports_by_dir.map do |dir,reports|
    self.new(dir, reports)
  end
end