Skip to content

Commit

Permalink
Merge pull request #16 from pschambacher/master
Browse files Browse the repository at this point in the history
Avoid slow file output with JRuby/Windows
  • Loading branch information
bf4 committed Jul 10, 2014
2 parents 0b53716 + 94884d9 commit 903c37b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/simplecov-html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,23 @@ def format(result)
FileUtils.cp_r(path, asset_output_path)
end

File.open(File.join(output_path, "index.html"), "w+") do |file|
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

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

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."
Expand Down

0 comments on commit 903c37b

Please sign in to comment.