Class: SimpleCov::Formatter::Bootstrap

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov-html.rb

Instance Method Summary collapse

Instance Method Details

#file_mode_formatObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/simplecov-html.rb', line 24

def file_mode_format
  format = 'w+'

  # On JRuby/Windows it tries to convert all \n into \r\n in w+ mode.
  # b mode is binary and outputs "as is".
  if defined?(JRUBY_VERSION) && !!(RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/i)
    format = 'wb+'
  end

  format
end

#format(result) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/simplecov-html.rb', line 13

def format(result)
  Dir[File.join(File.dirname(__FILE__), '../public/*')].each do |path|
    FileUtils.cp_r(path, asset_output_path)
  end

  File.open(File.join(output_path, "index.html"), file_mode_format) do |file|
    file.puts template('layout').result(binding)
  end
  puts output_message(result)
end

#output_message(result) ⇒ Object



36
37
38
# File 'lib/simplecov-html.rb', line 36

def output_message(result)
  "Coverage report generated for #{result.command_name} to #{output_path}. #{result.covered_lines} / #{result.total_lines} LOC (#{result.covered_percent.round(2)}%) covered."
end