Sha256: a1630eaf63fff90298d14e0f9b2d4276ebd8321fdeffaa87e6970040392ed5ed

Contents?: true

Size: 993 Bytes

Versions: 3

Compression:

Stored size: 993 Bytes

Contents

module MetricFu
  class Roodi < Generator

    def self.verify_dependencies!
      `roodi --help`
      raise 'sudo gem install roodi # if you want the roodi tasks' unless $?.success?
    end

    
    def emit
      files_to_analyze = MetricFu.roodi[:dirs_to_roodi].map{|dir| Dir[File.join(dir, "**/*.rb")] }
      files = remove_excluded_files(files_to_analyze.flatten)
      config = MetricFu.roodi[:roodi_config] ? "-config=#{MetricFu.roodi[:roodi_config]}" : ""
      @output = `roodi #{config} #{files.join(" ")}`
    end

    def analyze
      @matches = @output.chomp.split("\n").map{|m| m.split(" - ") }
      total = @matches.pop
      @matches.reject! {|array| array.empty? }
      @matches.map! do |match|
        file, line = match[0].split(':')
        problem = match[1]
        {:file => file, :line => line, :problem => problem}
      end
      @roodi_results = {:total => total, :problems => @matches}
    end

    def to_h
      {:roodi => @roodi_results}
    end
  end
end

Version data entries

3 entries across 3 versions & 3 rubygems

Version Path
metric_fu-1.4.0 lib/generators/roodi.rb
cdd-metric_fu-1.3.1 lib/generators/roodi.rb
devver-metric_fu-1.3.3 lib/generators/roodi.rb