Sha256: 5d2b5584c07489d93e435055eaec46c55bf98c501d1fc96a2c01618c6f752dd1

Contents?: true

Size: 813 Bytes

Versions: 17

Compression:

Stored size: 813 Bytes

Contents

require 'generator'
module MetricFu
  
  class Flay < Generator

    def emit
      files_to_flay = MetricFu.flay[:dirs_to_flay].map{|dir| Dir[File.join(dir, "**/*.rb")] }
      @output = `flay #{files_to_flay.join(" ")}`
    end

    def analyze
      @matches = @output.chomp.split("\n\n").map{|m| m.split("\n  ") }
    end

    def to_h
      target = []
      total_score = @matches.shift.first.split('=').last.strip
      @matches.each do |problem|
        reason = problem.shift.strip
        lines_info = problem.map do |full_line|
          name, line = full_line.split(":")
          {:name => name.strip, :line => line.strip}
        end
        target << [:reason => reason, :matches => lines_info]
      end
      {:flay => {:total_score => total_score, :matches => target.flatten}}
    end
  end
end

Version data entries

17 entries across 17 versions & 3 rubygems

Version Path
edouard-metric_fu-1.0.3.3 lib/generators/flay.rb
edouard-metric_fu-1.0.3.4 lib/generators/flay.rb
edouard-metric_fu-1.0.3.5 lib/generators/flay.rb
edouard-metric_fu-1.0.3.6 lib/generators/flay.rb
edouard-metric_fu-1.0.3.7 lib/generators/flay.rb
edouard-metric_fu-1.0.3.8 lib/generators/flay.rb
edouard-metric_fu-1.0.4.1 lib/generators/flay.rb
edouard-metric_fu-1.0.4.2 lib/generators/flay.rb
edouard-metric_fu-1.0.4.3 lib/generators/flay.rb
edouard-metric_fu-1.0.4.4 lib/generators/flay.rb
edouard-metric_fu-1.0.4.5 lib/generators/flay.rb
edouard-metric_fu-1.0.4 lib/generators/flay.rb
jscruggs-metric_fu-1.0.0 lib/generators/flay.rb
jscruggs-metric_fu-1.0.1 lib/generators/flay.rb
jscruggs-metric_fu-1.0.2 lib/generators/flay.rb
khall-metric_fu-1.0.2.1 lib/generators/flay.rb
khall-metric_fu-1.0.2.2 lib/generators/flay.rb