Sha256: 1854027965bd6e52ee7a299944ce8d98dc923c7105ab42c53c649ae90c77b995
Contents?: true
Size: 944 Bytes
Versions: 1
Compression:
Stored size: 944 Bytes
Contents
require 'generator' module MetricFu class Flay < Generator def self.verify_dependencies! raise "Missing flay gem. Please 'gem install flay'" unless system('flay --help') end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alexrothenberg-metric_fu-1.0.2 | lib/generators/flay.rb |