Module: Continuous4r
- Includes:
- Utils
- Defined in:
- lib/continuous4r.rb
Overview
Classe modelisant un fichier de description de projet Ruby on Rails
- Author
-
Vincent Dubois
Date : 03 decembre 2007 - version 0.0.1
03 fevrier 2009 - version 0.0.2
25 fevrier 2009 - version 0.0.3
03 mars 2009 - version 0.0.4
Constant Summary collapse
- VERSION =
'0.0.4'- URL =
"http://github.com/vdubois/continuous4r/tree/master"- WORK_DIR =
Support de CruiseControl.rb
"#{ENV['CC_BUILD_ARTIFACTS'].nil? ? "tmp/continuous4r" : "#{ENV['CC_BUILD_ARTIFACTS']}/continuous4r"}"- TASKS =
['rdoc','dcov','rcov','stats','changelog','flog','xdoclet','flay','reek','roodi','saikuro','tests','zentest']
- METRICS_HASH =
TASKS = [‘rdoc’, ‘dcov’, ‘rcov’, ‘stats’, ‘flog’, ‘xdoclet’, ‘flay’, ‘reek’] TASKS = [‘reek’]
Hash.new
Class Method Summary collapse
-
.build_name ⇒ Object
Méthode qui permet de récupérer le nom du build pour la construction du template notamment.
-
.build_task(task, project_name, auto_install, proxy_option) ⇒ Object
Methode qui permet de construire une tache de nom donne.
-
.generate_site ⇒ Object
Methode de generation du site au complet.
Methods included from Utils
erb_run, flog_caracteristics, flog_score_to_css_style, percent_to_css_style, run_command, verify_gem_presence
Class Method Details
.build_name ⇒ Object
Méthode qui permet de récupérer le nom du build pour la construction du template notamment
39 40 41 |
# File 'lib/continuous4r.rb', line 39 def self.build_name @build_name ||= "no build name found" end |
.build_task(task, project_name, auto_install, proxy_option) ⇒ Object
Methode qui permet de construire une tache de nom donne
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/continuous4r.rb', line 151 def self.build_task task, project_name, auto_install, proxy_option require "#{task}_builder.rb" task_class = Object.const_get("#{task.capitalize}Builder") task_builder = task_class.new if task_builder.respond_to?(:prerequisite_met?) if !task_builder.prerequisite_met? puts task_builder. return end end task_builder.build(project_name, auto_install, proxy_option) if task_builder.respond_to?(:quality_percentage) METRICS_HASH[task_builder.quality_indicator_name] = task_builder.quality_percentage end end |
.generate_site ⇒ Object
Methode de generation du site au complet
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/continuous4r.rb', line 44 def self.generate_site @build_name = Utils.build_name tasks = TASKS project = XmlElements.fromString(File.read("#{RAILS_ROOT}/continuous4r-project.xml")) generation_date = DateTime.now auto_install = project['auto-install-tools'] auto_install ||= "false" puts "=====================================================================" puts " Continuous Integration for Ruby, starting website generation..." puts "---------------------------------------------------------------------" puts " Project name : #{project['name']}" puts " Project URL : #{project.url.text}" puts " Generation date : #{generation_date}" puts "---------------------------------------------------------------------" # Récupération des paramètres de proxy s'ils existent proxy_option = "" if File.exist?("#{(Config::CONFIG['host_os'] =~ /mswin/ ? ENV['USERPROFILE'] : ENV['HOME'])}/.continuous4r/proxy.yml") require 'YAML' = YAML.load_file("#{(Config::CONFIG['host_os'] =~ /mswin/ ? ENV['USERPROFILE'] : ENV['HOME'])}/.continuous4r/proxy.yml") proxy_option = " -p \"http://#{['proxy']['login']}:#{['proxy']['password']}@#{['proxy']['server']}:#{['proxy']['port']}\"" end # Vérification de présence et de la version de Rubygems puts " Checking presence and version of RubyGems..." rubygems_version = Utils.run_command("gem --version") if rubygems_version.empty? raise " You don't seem to have RubyGems installed, please go first to http://rubygems.rubyforge.org" end # Verification de la presence d'hpricot Utils.verify_gem_presence("hpricot", auto_install, proxy_option) # Chargement/Vérification des gems nécessaires à l'application puts " Checking gems for this project, please hold on..." begin project.gems.each('gem') do |gem| puts " Checking for #{gem['name']} gem, version #{gem['version']}..." gem_version = Utils.run_command("gem list #{gem['name']}") if gem_version.empty? or gem_version.index("#{gem['version']}").nil? if project['auto-install-gems'] == "false" raise " The #{gem['name']} gem with version #{gem['version']} is needed. Please run '#{"sudo " unless Config::CONFIG['host_os'] =~ /mswin/}gem install #{gem['name']} --version #{gem['version']}' to install it.\n BUILD FAILED." end gem_installed = Utils.run_command("#{"sudo " unless Config::CONFIG['host_os'] =~ /mswin/}gem install #{gem['name']} --version #{gem['version']}#{proxy_option} 2>&1") if !gem_installed.index("ERROR").nil? raise " Unable to install #{gem['name']} gem with version #{gem['version']}.\n BUILD FAILED." end end end rescue puts " No gems declared for this project, continuing..." end puts "---------------------------------------------------------------------" # Création du répertoire de travail if File.exist?(WORK_DIR) FileUtils.rm_rf(WORK_DIR) end FileUtils.mkdir_p WORK_DIR # Construction des taches tasks.each do |task| self.build_task task, project['name'], auto_install, proxy_option puts "\n---------------------------------------------------------------------" end puts " All tasks done." puts "\n---------------------------------------------------------------------" # On copie les feuilles de styles FileUtils.cp_r("#{File.dirname(__FILE__)}/site/style/", "#{WORK_DIR}/") # On copie la partie flash FileUtils.cp_r("#{File.dirname(__FILE__)}/site/charts/", "#{WORK_DIR}/") # Production du fichier XML des indicateurs de qualité page_file = File.open("#{Continuous4r::WORK_DIR}/build.xml", "w") erb = ERB.new(File.read("#{File.dirname(__FILE__)}/site/build.xml.erb")) page_file.write(erb.result) page_file.close # On copie les images FileUtils.cp_r("#{File.dirname(__FILE__)}/site/images/", "#{WORK_DIR}/") FileUtils.copy_file("#{File.dirname(__FILE__)}/site/images/continuous4r-logo.png", "#{WORK_DIR}/continuous4r-logo.png") puts " Building project information page..." Utils.erb_run "index", false puts " Building team list page..." Utils.erb_run "team-list", false puts " Building project dependencies page..." Utils.erb_run "dependencies", false puts " Building source control management page..." Utils.erb_run "scm-usage", false puts " Building issue tracking page..." Utils.erb_run "issue-tracking", false puts " Building project reports page..." Utils.erb_run "continuous4r-reports", false tasks.each do |task| task_class = Object.const_get("#{task.capitalize}Builder") task_builder = task_class.new next if task_builder.respond_to?(:prerequisite_met?) and !task_builder.prerequisite_met? puts " Building #{task} page..." Utils.erb_run task, true end puts "\n BUILD SUCCESSFUL." puts "=====================================================================" end |