Class: Coverage::HTMLPrinter
- Inherits:
-
Object
- Object
- Coverage::HTMLPrinter
- Extended by:
- Forwardable
- Defined in:
- lib/coverage/html_printer.rb
Defined Under Namespace
Modules: Utility Classes: Detail, Index, Line, PathSettings
Instance Attribute Summary collapse
-
#output_directory ⇒ Object
Returns the value of attribute output_directory.
-
#project_name ⇒ Object
Returns the value of attribute project_name.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ HTMLPrinter
constructor
A new instance of HTMLPrinter.
- #install_files ⇒ Object
- #print(result) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ HTMLPrinter
Returns a new instance of HTMLPrinter.
63 64 65 66 67 68 69 |
# File 'lib/coverage/html_printer.rb', line 63 def initialize yield self if block_given? output_directory ||= Pathname.pwd + "coverage" @path_settings = PathSettings.new(output_directory) FileUtils.mkdir_p(output_directory) @project_name ||= base_directory.basename end |
Instance Attribute Details
#output_directory ⇒ Object
Returns the value of attribute output_directory.
59 60 61 |
# File 'lib/coverage/html_printer.rb', line 59 def output_directory @output_directory end |
#project_name ⇒ Object
Returns the value of attribute project_name.
59 60 61 |
# File 'lib/coverage/html_printer.rb', line 59 def project_name @project_name end |
Instance Method Details
#install_files ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/coverage/html_printer.rb', line 87 def install_files stylesheets_directory.each_child do |path| FileUtils.install(path, output_directory) end javascripts_directory.each_child do |path| FileUtils.install(path, output_directory) end end |
#print(result) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/coverage/html_printer.rb', line 71 def print(result) target_files = Dir.glob("#{base_directory}/**/*.rb") statistics_list = [] files = [] result.each do |path, counts| next unless target_files.include?(path) next if Regexp.new("#{base_directory}/(?:test|spec|vendor)") =~ path files << Detail.new(@path_settings, @project_name, path, counts) end files.sort_by!{|detail| detail.path } files.each(&:print) index = Index.new(@path_settings, @project_name, files) index.print install_files end |