Class: MetricFu::RcovGenerator

Inherits:
Generator show all
Defined in:
lib/metric_fu/metrics/rcov/generator.rb

Instance Attribute Summary

Attributes inherited from Generator

#options, #result, #template

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Generator

#generate_result, generators, get_generator, #initialize, #metric, #metric_config, metric_directory, #metric_directory, not_implemented, #remove_excluded_files, #round_to_tenths, #run!

Constructor Details

This class inherits a constructor from MetricFu::Generator

Class Method Details

.metricObject



10
11
12
# File 'lib/metric_fu/metrics/rcov/generator.rb', line 10

def self.metric
  :rcov
end

Instance Method Details

#analyzeObject



43
44
45
46
47
# File 'lib/metric_fu/metrics/rcov/generator.rb', line 43

def analyze
  rcov_text = load_output
  formatter = MetricFu::RCovFormatCoverage.new(rcov_text)
  @rcov = formatter.to_h
end

#commandObject



22
23
24
# File 'lib/metric_fu/metrics/rcov/generator.rb', line 22

def command
  @command ||= default_command
end

#command=(command) ⇒ Object



26
27
28
# File 'lib/metric_fu/metrics/rcov/generator.rb', line 26

def command=(command)
  @command = command
end

#default_commandObject



35
36
37
38
39
40
41
# File 'lib/metric_fu/metrics/rcov/generator.rb', line 35

def default_command
  require "rake"
  reset_output_location
  test_files = FileList[*options[:test_files]].join(" ")
  rcov_opts = options[:rcov_opts].join(" ")
  %(RAILS_ENV=#{options[:environment]} rcov #{test_files} #{rcov_opts} >> #{default_output_file})
end

#emitObject



14
15
16
17
18
19
20
# File 'lib/metric_fu/metrics/rcov/generator.rb', line 14

def emit
  if run_rcov?
    mf_debug "** Running the specs/tests in the [#{options[:environment]}] environment"
    mf_debug "** #{command}"
    `#{command}`
  end
end

#reset_output_locationObject



30
31
32
33
# File 'lib/metric_fu/metrics/rcov/generator.rb', line 30

def reset_output_location
  MetricFu::Utility.rm_rf(metric_directory, verbose: false)
  MetricFu::Utility.mkdir_p(metric_directory)
end

#to_hObject



49
50
51
52
53
# File 'lib/metric_fu/metrics/rcov/generator.rb', line 49

def to_h
  {
    rcov: @rcov
  }
end