Sha256: c973b95b8dde85aa809325d47a1bf2bc87b323685b69f9ceef1079a119d7c3fd

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require 'fileutils'

namespace :metrics do

  desc "A cyclomatic complexity report using Saikuro"
  task :saikuro do
    SAIKURO_DIR = File.join(MetricFu.configuration.base_directory, 'saikuro')
    SAIKURO = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'vendor', 'saikuro', 'saikuro.rb'))

    raise "SAIKURO_OPTIONS is now MetricFu::SAIKURO_OPTIONS" if defined?(SAIKURO_OPTIONS)
    options = { :output_directory => SAIKURO_DIR,
                        :input_directory => MetricFu.code_dirs,
                        :cyclo => "",
                        :filter_cyclo => "0",
                        :warn_cyclo => "5",
                        :error_cyclo => "7"}

    options.merge!(MetricFu::SAIKURO_OPTIONS) if defined?(MetricFu::SAIKURO_OPTIONS)
    options_string = options.inject(""){ |o, h| o + "--#{h.join(' ')} " }

    sh %{ruby "#{SAIKURO}" #{options_string}} do |ok, response|
      unless ok
        puts "Saikuro failed with exit status: #{response.exitstatus}"
        exit 1
      end
    end

    if File.exist? "#{SAIKURO_DIR}/index_cyclo.html"
      mv "#{SAIKURO_DIR}/index_cyclo.html",
         "#{SAIKURO_DIR}/index.html"
    end

    system("open #{SAIKURO_DIR}/index.html") if MetricFu.open_in_browser?
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
p8-metric_fu-0.9.0.4 lib/tasks/saikuro.rake
p8-metric_fu-0.9.0.5 lib/tasks/saikuro.rake
p8-metric_fu-0.9.0.6 lib/tasks/saikuro.rake
p8-metric_fu-0.9.0.7 lib/tasks/saikuro.rake