Class: MetricFu::Rcov
Defined Under Namespace
Classes: Line
Constant Summary collapse
- NEW_FILE_MARKER =
/^={80}$/.freeze
Instance Attribute Summary
Attributes inherited from Generator
Instance Method Summary collapse
Methods inherited from Generator
class_name, #create_data_dir_if_missing, #create_metric_dir_if_missing, #create_output_dir_if_missing, generate_report, #generate_report, #initialize, #metric_directory, metric_directory, #remove_excluded_files, #round_to_tenths, #to_graph
Constructor Details
This class inherits a constructor from MetricFu::Generator
Instance Method Details
#analyze ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/generators/rcov.rb', line 36 def analyze output_file = MetricFu.rcov[:external] ? MetricFu.rcov[:external] : MetricFu::Rcov.metric_directory + '/rcov.txt' output = File.open(output_file).read output = output.split(NEW_FILE_MARKER) output.shift # Throw away the first entry - it's the execution time etc. files = assemble_files(output) @global_total_lines = 0 @global_total_lines_run = 0 @rcov = add_coverage_percentage(files) end |
#emit ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/rcov.rb', line 21 def emit unless MetricFu.rcov[:external] FileUtils.rm_rf(MetricFu::Rcov.metric_directory, :verbose => false) Dir.mkdir(MetricFu::Rcov.metric_directory) test_files = FileList[*MetricFu.rcov[:test_files]].join(' ') rcov_opts = MetricFu.rcov[:rcov_opts].join(' ') output = ">> #{MetricFu::Rcov.metric_directory}/rcov.txt" mf_debug "** Running the specs/tests in the [#{MetricFu.rcov[:environment]}] environment" command = %Q(RAILS_ENV=#{MetricFu.rcov[:environment]} rcov #{test_files} #{rcov_opts} #{output}) mf_debug "** #{command}" `#{command}` end end |
#to_h ⇒ Object
51 52 53 54 55 |
# File 'lib/generators/rcov.rb', line 51 def to_h global_percent_run = ((@global_total_lines_run.to_f / @global_total_lines.to_f) * 100) add_method_data {:rcov => @rcov.merge({:global_percent_run => round_to_tenths(global_percent_run) })} end |