lib/attractor/calculators/base_calculator.rb in attractor-2.4.0 vs lib/attractor/calculators/base_calculator.rb in attractor-2.5.0

- old
+ new

@@ -7,16 +7,17 @@ module Attractor # calculates churn and complexity class BaseCalculator attr_reader :type - def initialize(file_prefix: "", ignores: "", file_extension: "rb", minimum_churn_count: 3, start_ago: "5y") + def initialize(file_prefix: "", ignores: "", file_extension: "rb", minimum_churn_count: 3, start_ago: "5y", verbose: false) @file_prefix = file_prefix @file_extension = file_extension @minimum_churn_count = minimum_churn_count @start_date = Date.today - Attractor::DurationParser.new(start_ago).duration @ignores = ignores + @verbose = verbose end def calculate churn = ::Churn::ChurnCalculator.new( file_extension: @file_extension, @@ -24,11 +25,11 @@ minimum_churn_count: @minimum_churn_count, start_date: @start_date, ignores: @ignores ).report(false) - puts "Calculating churn and complexity values for #{churn[:churn][:changes].size} #{type} files" + puts "Calculating churn and complexity values for #{churn[:churn][:changes].size} #{type} files" if @verbose values = churn[:churn][:changes].map do |change| history = git_history_for_file(file_path: change[:file_path]) commit = history&.first&.first @@ -45,16 +46,16 @@ details: details, history: history) Cache.write(file_path: change[:file_path], value: value) end - print "." + print "." if @verbose value end Cache.persist! - print "\n\n" + print "\n\n" if @verbose values end private