Class: Integrity::Grader
- Inherits:
-
Object
- Object
- Integrity::Grader
- Defined in:
- lib/integrity/grader.rb
Class Method Summary collapse
-
.grade(_build, data_directory, report_directory, logger) ⇒ Object
Adapted from report_card to apply metric_fu to each just-completed build.
Instance Method Summary collapse
- #configure ⇒ Object
- #directory ⇒ Object
- #generate ⇒ Object
- #grade ⇒ Object
-
#initialize(build, data_directory, report_directory, logger) ⇒ Grader
constructor
A new instance of Grader.
- #start ⇒ Object
- #success? ⇒ Boolean
- #wrapup ⇒ Object
Constructor Details
#initialize(build, data_directory, report_directory, logger) ⇒ Grader
Returns a new instance of Grader.
14 15 16 17 18 19 |
# File 'lib/integrity/grader.rb', line 14 def initialize(build, data_directory, report_directory, logger) @build = build @data_directory = data_directory @report_directory = report_directory || "metrics" @logger = logger end |
Class Method Details
.grade(_build, data_directory, report_directory, logger) ⇒ Object
Adapted from report_card to apply metric_fu to each just-completed build. Reports are saved to /metrics/:project/output and previous data stored in /metrics/:project/report.yml. Everything else is standard metric_fu.
10 11 12 |
# File 'lib/integrity/grader.rb', line 10 def self.grade(_build, data_directory, report_directory, logger) new(_build, data_directory, report_directory, logger).grade end |
Instance Method Details
#configure ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/integrity/grader.rb', line 39 def configure MetricFu::Configuration.run do |config| config.reset config.template_class = AwesomeTemplate config.file_globs_to_ignore = ['lib/generators/**/*'] config.code_dirs << 'vendor/extensions' config.rcov = { :test_files => ['test/**/*_test.rb', 'spec/**/*_spec.rb' ], :rcov_opts => ["--sort coverage", "--no-html", "--text-coverage", "--no-color", "--profile", "--rails", "--include test", "--exclude /gems/,/usr/local/lib/site_ruby/1.8/,spec"]} end MetricFu.report.instance_variable_set(:@report_hash, {}) end |
#directory ⇒ Object
35 36 37 |
# File 'lib/integrity/grader.rb', line 35 def directory @directory ||= @data_directory.join(@build.id.to_s) end |
#generate ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/integrity/grader.rb', line 58 def generate begin MetricFu.metrics.each { |metric| MetricFu.report.add(metric) } MetricFu.graphs.each { |graph| MetricFu.graph.add(graph, :bluff) } MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.base_directory, 'report.yml') MetricFu.report.save_output(MetricFu.report.to_yaml, MetricFu.data_directory, "#{Time.now.strftime("%Y%m%d")}.yml") MetricFu.report.save_templatized_report MetricFu.graph.generate @success = true rescue Exception => e @logger.error "Problem generating the reports: #{e}" @success = false end end |
#grade ⇒ Object
21 22 23 24 25 26 |
# File 'lib/integrity/grader.rb', line 21 def grade start configure generate wrapup end |
#start ⇒ Object
28 29 30 31 32 33 |
# File 'lib/integrity/grader.rb', line 28 def start @logger.info "Build metrics for #{@build.project.name}" ENV['CC_BUILD_ARTIFACTS'] = File.join("../../public/", @report_directory, @build.project.permalink) @old_dir = Dir.getwd Dir.chdir directory end |
#success? ⇒ Boolean
77 78 79 |
# File 'lib/integrity/grader.rb', line 77 def success? @success end |
#wrapup ⇒ Object
73 74 75 |
# File 'lib/integrity/grader.rb', line 73 def wrapup Dir.chdir @old_dir end |