Sha256: 9965ab2b011c5d05763c497dd27166bfaaab68989408fcd3757568b180bc9c9d

Contents?: true

Size: 903 Bytes

Versions: 11

Compression:

Stored size: 903 Bytes

Contents

module MetricFu

  class FlayGenerator < Generator

    def self.metric
      :flay
    end

    def emit
      minimum_score_parameter = options[:minimum_score] ? "--mass #{options[:minimum_score]} " : ""
      args =  "#{minimum_score_parameter} #{options[:dirs_to_flay].join(" ")}"
      @output = run!(args)
    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

11 entries across 11 versions & 1 rubygems

Version Path
metric_fu-4.10.0 lib/metric_fu/metrics/flay/flay.rb
metric_fu-4.9.0 lib/metric_fu/metrics/flay/flay.rb
metric_fu-4.8.0 lib/metric_fu/metrics/flay/flay.rb
metric_fu-4.7.4 lib/metric_fu/metrics/flay/flay.rb
metric_fu-4.7.3 lib/metric_fu/metrics/flay/flay.rb
metric_fu-4.7.2 lib/metric_fu/metrics/flay/flay.rb
metric_fu-4.7.1 lib/metric_fu/metrics/flay/flay.rb
metric_fu-4.7.0 lib/metric_fu/metrics/flay/flay.rb
metric_fu-4.6.0 lib/metric_fu/metrics/flay/flay.rb
metric_fu-4.5.2 lib/metric_fu/metrics/flay/flay.rb
metric_fu-4.5.1 lib/metric_fu/metrics/flay/flay.rb