Sha256: d3adf6386fd9c5773b5c628563a6f4f3bfcf9522fc24321efae1b4f53aaccb6f

Contents?: true

Size: 1.71 KB

Versions: 3

Compression:

Stored size: 1.71 KB

Contents

begin

  def flog(output, directory)
    Dir.glob("#{directory}/**/*.rb").each do |filename|
      output_dir = "#{MetricFu::FLOG_DIR}/#{filename.split("/")[0..-2].join("/")}"
      mkdir_p(output_dir, :verbose => false) unless File.directory?(output_dir)
      puts `flog #{filename} > #{MetricFu::FLOG_DIR}/#{filename.split('.')[0]}.txt` if MetricFu::MD5Tracker.file_changed?(filename, MetricFu::FLOG_DIR)
    end
  end

  namespace :metrics do

    task :flog => ['flog:all'] do
    end

    namespace :flog do
      desc "Delete aggregate flog data."
      task(:clean) { rm_rf(MetricFu::FLOG_DIR, :verbose => false) }

      desc "Flog code in app/models"
      task :models do
        flog "models", "app/models"
      end

      desc "Flog code in app/controllers"
      task :controllers do
        flog "controllers", "app/controllers"
      end

      desc "Flog code in app/helpers"
      task :helpers do
        flog "helpers", "app/helpers"
      end

      desc "Flog code in lib"
      task :lib do
        flog "lib", "lib"
      end

      desc "Generate a flog report from specified directories"
      task :custom do
        MetricFu::CODE_DIRS.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.generate_flog_report
        end
      else
        task :all => [:custom] do
          MetricFu.generate_flog_report
        end
      end

    end

  end
rescue LoadError
  if RUBY_PLATFORM =~ /java/
    puts 'running in jruby - flog tasks not available'
  else
    puts 'sudo gem install flog # if you want the flog tasks'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
p8-metric_fu-0.8.4.7 lib/tasks/flog.rake
p8-metric_fu-0.8.4.8 lib/tasks/flog.rake
p8-metric_fu-0.8.4.9 lib/tasks/flog.rake