display progress for installing patches, autorefresh the index page
[opensuse:yast-web-client.git] / Rakefile
1 require 'fileutils'
2
3 env = ENV.map { |key,val| ENV[key] ? %(#{key}="#{ENV[key]}") : nil }.reject {|x| x.nil?}.join(' ')
4
5 plugins = Dir.glob('plugins/*')#.reject{|x| ['users'].include?(File.basename(x))}
6 PROJECTS = ['webclient', *plugins]
7 desc 'Run all tests by default'
8 task :default => :test
9
10
11 %w(fetch_po makemo updatepot test test:ui rdoc pgem package release install install_policies check_syntax package-local buildrpm buildrpm-local test:test:rcov).each do |task_name|
12   desc "Run #{task_name} task for all projects"
13
14   task task_name do
15     #remove translation statistik
16     File.delete(File.join("pot", "translation_status.yaml")) if task_name == "fetch_po" && File.exist?("pot/translation_status.yaml")
17
18     PROJECTS.each do |project|
19       system %(cd #{project} && #{env} #{$0} #{task_name})
20       raise "Error on execute task #{task_name} on #{project}" if $?.exitstatus != 0
21     end
22
23     if task_name == "fetch_po"
24       #remove translations which have not at least 80 percent translated text
25       limit = Float(80)
26       result = Hash.new
27       result = YAML.load(File.open(File.join("pot", "translation_status.yaml"))) if File.exists?(File.join("pot", "translation_status.yaml"))
28       result.each {|key,value|
29         translated = un_translated = Float(0)
30         translated = value["translated"].to_f if value.has_key? "translated"
31         un_translated += value["untranslated"].to_f if value.has_key? "untranslated"
32         un_translated += value["fuzzy"].to_f if value.has_key? "fuzzy"
33         limit_eval = translated/(un_translated+translated) 
34         if limit_eval < limit/100
35           puts "Language #{key} should be deleted cause it has only #{(limit_eval*100).to_i} percent translation reached."
36           Dir.glob("**/#{key}/").each {|po_dir|
37             unless po_dir.include? "lang_helper" #do not delete translations for language selections
38 #              puts "deleting #{po_dir}"
39 #              remove_dir(po_dir, true) #force=true
40             end
41           }
42         end      
43      }
44     end
45   end
46
47 end
48  
49 desc "Run doc to generate whole documentation"
50 task :doc do
51   #clean old documentation
52   puts "cleaning old doc"
53   system "rm -rf doc"
54   
55   Dir.mkdir 'doc'
56   copy 'index.html.template', "doc/index.html"
57   #handle rest service separate from plugins
58   puts "create framework documentation"
59   Dir.chdir('webclient') do
60     system "rake doc:app"
61   end
62     system "cp -r webclient/doc/app doc/webclient"
63   puts "create plugins documentation"
64   plugins_names = []
65   Dir.chdir('plugins') do
66     plugins_names = Dir.glob '*'
67   end
68   plugins_names.each do |plugin|
69     Dir.chdir("plugins/#{plugin}") do
70       system "rake doc:app"
71     end
72     system "cp -r plugins/#{plugin}/doc/app doc/#{plugin}"
73   end
74   puts "generate links for plugins"
75   code = ""
76   plugins_names.sort.each do |plugin|
77     code = "#{code}<a href=\"./#{plugin}/index.html\"><b>#{plugin}</b></a><br>"
78   end
79   system "sed -i 's:%%PLUGINS%%:#{code}:' doc/index.html"
80   puts "documentation successfully generated"
81 end
82
83 =begin
84 require 'metric_fu'
85 MetricFu::Configuration.run do |config|
86         #define which metrics you want to use
87         config.metrics  = [:churn, :saikuro, :flog, :reek, :roodi, :rcov] #missing flay and stats both not working
88         config.graphs   = [:flog, :reek, :roodi, :rcov]
89         config.flay     = { :dirs_to_flay => ['webclient', 'plugins']  } 
90         config.flog     = { :dirs_to_flog => ['webclient', 'plugins']  }
91         config.reek     = { :dirs_to_reek => ['webclient', 'plugins']  }
92         config.roodi    = { :dirs_to_roodi => ['webclient', 'plugins'] }
93         config.saikuro  = { :output_directory => 'scratch_directory/saikuro', 
94                             :input_directory => ['webclient', 'plugins'],
95                             :cyclo => "",
96                             :filter_cyclo => "0",
97                             :warn_cyclo => "5",
98                             :error_cyclo => "7",
99                             :formater => "text"} #this needs to be set to "text"
100         config.churn    = { :start_date => "1 year ago", :minimum_churn_count => 10}
101         config.rcov     = { :test_files => ['webclient/test/**/*_test.rb', 
102                                             'plugins/**/test/**/*_test.rb'],
103                             :rcov_opts => ["--sort coverage", 
104                                            "--no-html", 
105                                            "--text-coverage",
106                                            "--no-color",
107                                            "--profile",
108                                            "--rails",
109                                            "--exclude /gems/,/Library/,spec"]}
110     end
111 =end
112