Class: DcovBuilder

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/dcov_builder.rb

Overview

Construction de la tache dcov (couverture rdoc) author: Vincent Dubois date: 06 fevrier 2009

Instance Method Summary collapse

Methods included from Utils

build_name, erb_run, flog_caracteristics, flog_score_to_css_style, percent_to_css_style, run_command, verify_gem_presence

Instance Method Details

#build(project_name, auto_install, proxy_option) ⇒ Object

Implementation de la construction de la tache



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/dcov_builder.rb', line 129

def build(project_name, auto_install, proxy_option)
  # On verifie la presence de dcov
  Utils.verify_gem_presence("dcov", auto_install, proxy_option)
  # On lance la generation
  puts " Building dcov rdoc coverage report..."
  files = Array.new
  files << Dir.glob("app/**/*.rb")
  files << Dir.glob("lib/**/*.rb")
  files.flatten!
  options = {
    :path => RAILS_ROOT,
    :output_format => 'html',
    :files => files
  }
  Dcov::Analyzer.new(options)
  if !File.exist?("#{Continuous4r::WORK_DIR}/dcov/coverage.html")
    raise " Execution of dcov failed.\n BUILD FAILED."
  end
end

#quality_indicator_nameObject

Nom de l’indicateur de qualité



161
162
163
# File 'lib/dcov_builder.rb', line 161

def quality_indicator_name
  "rdoc coverage"
end

#quality_percentageObject

Methode qui permet d’extraire le pourcentage de qualité extrait d’un builder



150
151
152
153
154
155
156
157
158
# File 'lib/dcov_builder.rb', line 150

def quality_percentage
  require 'hpricot'
  doc = Hpricot(File.read("#{Continuous4r::WORK_DIR}/dcov/coverage.html"))
  doc.search('//h3') do |h3|
    if h3.inner_text.match(/^Global coverage percentage/)
      return h3.inner_text.split(/Global coverage percentage : /)[1].split(/%/)[0]
    end
  end
end