class SimpleCov::Formatter::WorkspaceLcovFormatter
Constants
- VERSION
Public Class Methods
config() { |config| ... }
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 22 def config @config ||= Configuration.new yield @config if block_given? @config end
Public Instance Methods
format(result)
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 9 def format(result) create_output_directory! if report_with_single_file? write_lcov_to_single_file!(result.files) else result.files.each { |file| write_lcov!(file) } end puts "Lcov style coverage report generated for #{result.command_name} to #{lcov_results_path}" end
Private Instance Methods
create_output_directory!()
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 53 def create_output_directory! return if Dir.exist?(output_directory) FileUtils.mkdir_p(output_directory) end
filtered_lines(file)
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 86 def filtered_lines(file) file.lines.reject(&:never?).reject(&:skipped?) end
format_file(file)
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 75 def format_file(file) filename = file.filename.gsub("#{root_path}/", './') "SF:#{filename}\n#{format_lines(file)}\nend_of_record\n" end
format_line(line)
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 90 def format_line(line) "DA:#{line.number},#{line.coverage}" end
format_lines(file)
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 80 def format_lines(file) filtered_lines(file) .map { |line| format_line(line) } .join("\n") end
lcov_results_path()
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 37 def lcov_results_path report_with_single_file? ? single_report_path : output_directory end
output_directory()
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 33 def output_directory self.class.config.output_directory end
output_filename(filename)
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 70 def output_filename(filename) filename.gsub("#{SimpleCov.root}/", '').gsub('/', '-') .tap { |name| name << '.lcov' } end
report_with_single_file?()
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 41 def report_with_single_file? self.class.config.report_with_single_file? end
root_path()
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 49 def root_path self.class.config.workspace_path end
single_report_path()
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 45 def single_report_path self.class.config.single_report_path end
write_lcov!(file)
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 58 def write_lcov!(file) File.open(File.join(output_directory, output_filename(file.filename)), 'w') do |f| f.write format_file(file) end end
write_lcov_to_single_file!(files)
click to toggle source
# File lib/simplecov-workspace-lcov.rb, line 64 def write_lcov_to_single_file!(files) File.open(single_report_path, 'w') do |f| files.each { |file| f.write format_file(file) } end end