Sha256: 2b86d62a427a5b4f21fe454d1881c5766e50311c78cbc23fbb4fa9e5ffa3432f
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
require 'flog' module AnalDiffist class FlogParser def initialize paths, threshold = 10.0 @paths = paths @flog_threshold = threshold end def problems f = Flog.new f.flog(@paths) problems = [] f.each_by_score{|class_method, score, ignore_for_now| problems << FlogProblem.new(class_method, score, @flog_threshold)} problems #problems.select {|p| p.score >= @flog_threshold} end end class FlogProblem attr_accessor :context, :score def initialize class_method, score, threshold = 10 @context = class_method || '(none)' @score = score.round(1) @flog_threshold = threshold end def type 'flog score' end def diff other return nil if score < @flog_threshold return FlogDiff.new(@context, 0, score) if other.nil? return nil if other.score >= score FlogDiff.new(@context, other.score, score) end def description "Flog: #{score}" end end class FlogDiff attr_accessor :context, :score def initialize context, previous_score, current_score @context = context @current_score = current_score @previous_score = previous_score end def score (@current_score - @previous_score).round(1) end def description(mode = :added) indicator = (mode == :added) ? "+" : "-" "Flog: #{@current_score.round(1)} (#{indicator}#{(@current_score - @previous_score).round(1)})" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
analdiffist-0.3.0 | lib/analdiffist/flog_parser.rb |