lib/tasks/flog.rake in indirect-metric_fu-0.8.2 vs lib/tasks/flog.rake in indirect-metric_fu-0.9.0

- old
+ new

@@ -1,24 +1,26 @@ begin - FLOG_DIR = File.join(MetricFu::BASE_DIRECTORY, 'flog') def flog(output, directory) + metric_dir = MetricFu::Flog::Generator.metric_dir Dir.glob("#{directory}/**/*.rb").each do |filename| - output_dir = "#{FLOG_DIR}/#{filename.split("/")[0..-2].join("/")}" + output_dir = "#{metric_dir}/#{filename.split("/")[0..-2].join("/")}" mkdir_p(output_dir, :verbose => false) unless File.directory?(output_dir) - `flog #{filename} > #{FLOG_DIR}/#{filename.split('.')[0]}.txt` if MetricFu::MD5Tracker.file_changed?(filename, FLOG_DIR) + if MetricFu::MD5Tracker.file_changed?(filename, metric_dir) + `flog #{filename} > #{metric_dir}/#{filename.split('.')[0]}.txt` + end end end namespace :metrics do task :flog => ['flog:all'] do end namespace :flog do desc "Delete aggregate flog data." - task(:clean) { rm_rf(FLOG_DIR, :verbose => false) } + task(:clean) { rm_rf(MetricFu::Flog.metric_dir, :verbose => false) } desc "Flog code in app/models" task :models do flog "models", "app/models" end @@ -38,23 +40,21 @@ flog "lib", "lib" end desc "Generate a flog report from specified directories" task :custom do - MetricFu::CODE_DIRS.each { |directory| flog(directory, directory) } - MetricFu::FlogReporter::Generator.generate_report(FLOG_DIR) + MetricFu::flog[:dirs_to_flog].each { |directory| flog(directory, directory) } + MetricFu.generate_flog_report end desc "Generate and open flog report" if MetricFu::RAILS task :all => [:models, :controllers, :helpers, :lib] do - MetricFu::FlogReporter::Generator.generate_report(FLOG_DIR) - system("open #{FLOG_DIR}/index.html") if PLATFORM['darwin'] + MetricFu.generate_flog_report end else task :all => [:custom] do - MetricFu::FlogReporter::Generator.generate_report(FLOG_DIR) - system("open #{FLOG_DIR}/index.html") if PLATFORM['darwin'] + MetricFu.generate_flog_report end end end \ No newline at end of file