Sha256: 47b449b13a70742e5209606ddf9673a14c0f76f8502687195387757007538f5f

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module MetricFu
  class Roodi < Generator

    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]}" : ""
      command = %Q(metric_fu-roodi #{config} #{files.join(" ")})
      mf_debug "** #{command}"
      @output = `#{command}`
    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

    def per_file_info(out)
      @matches.each do |match|
        out[match[:file]] ||= {}
        out[match[:file]][match[:line]] ||= []
        out[match[:file]][match[:line]] << {:type => :roodi, :description => match[:problem]}
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metric_fu-2.1.4.pre2 lib/metric_fu/metrics/roodi/roodi.rb
metric_fu-2.1.4.pre lib/metric_fu/metrics/roodi/roodi.rb