Class: NCoverReport

Inherits:
Object
  • Object
show all
Includes:
Albacore::RunCommand, Albacore::Task
Defined in:
lib/albacore/ncoverreport.rb

Instance Attribute Summary

Attributes included from Albacore::RunCommand

#command, #working_directory

Attributes included from Logging

#current_log_device, #logger

Instance Method Summary collapse

Methods included from Albacore::RunCommand

#get_command, #run_command

Methods included from AttrMethods

#attr_array, #attr_hash

Methods included from Albacore::Task

clean_dirname, create_rake_task, include_config, included

Methods included from UpdateAttributes

#<<, #update_attributes

Methods included from YAMLConfig

#configure, #load_config_by_task_name

Methods included from Logging

#create_logger, #log_device=, #log_level, #log_level=

Methods included from Failure

#fail_with_message

Constructor Details

#initializeNCoverReport

Returns a new instance of NCoverReport.



10
11
12
13
14
15
16
17
# File 'lib/albacore/ncoverreport.rb', line 10

def initialize
  @coverage_files = []
  @reports = []
  @required_coverage = []
  @filters = []
  super()
  update_attributes Albacore.configuration.ncoverreport.to_hash
end

Instance Method Details

#build_coverage_filesObject



44
45
46
# File 'lib/albacore/ncoverreport.rb', line 44

def build_coverage_files
  @coverage_files.map{|f| "\"#{f}\""}.join(" ")
end

#build_filtersObject



40
41
42
# File 'lib/albacore/ncoverreport.rb', line 40

def build_filters
  @filters.map{|f| "//cf #{f.get_filter_options}"}.join(" ")
end

#build_reportsObject



48
49
50
51
52
53
54
55
# File 'lib/albacore/ncoverreport.rb', line 48

def build_reports
  @reports.map{|r|
    report = "//or #{r.report_type}"
    report << ":#{r.report_format}" unless r.report_format.nil?
    report << ":\"#{r.output_path}\"" unless r.output_path.nil?
    report
  }.join(" ")
end

#build_required_coverageObject



57
58
59
60
61
# File 'lib/albacore/ncoverreport.rb', line 57

def build_required_coverage
  @required_coverage.map{|c|
    coverage = "//mc #{c.get_coverage_options}"
  }.join(" ")
end

#check_commandObject



34
35
36
37
38
# File 'lib/albacore/ncoverreport.rb', line 34

def check_command
  return true if @command
  fail_with_message 'NCoverReport.command cannot be nil.'
  return false
end

#executeObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/albacore/ncoverreport.rb', line 19

def execute
  return unless check_command
  
  command_parameters = []
  command_parameters << build_coverage_files unless @coverage_files.empty?
  command_parameters << build_reports unless @reports.empty?
  command_parameters << build_required_coverage unless @required_coverage.empty?
  command_parameters << build_filters unless @filters.empty?
  
  result = run_command "NCover.Reporting", command_parameters.join(" ")
  
  failure_msg = 'Code Coverage Reporting Failed. See Build Log For Detail.'
  fail_with_message failure_msg if !result
end