Module: Hoe::History
- Defined in:
- lib/hoe/history.rb
Overview
History plugin for Hoe. Allows you to calculate all of the flog & flay scores over the releases of your project in an SCM independent way.
Instance Method Summary collapse
-
#define_history_tasks ⇒ Object
:nodoc:.
-
#flog_flay ⇒ Object
Calculate the flog and flay score for a Hoe project.
-
#history(versions) ⇒ Object
Calculate the history across all versions.
-
#load_history ⇒ Object
Load cached history.
-
#save_history(data) ⇒ Object
Save cached history.
Instance Method Details
#define_history_tasks ⇒ Object
:nodoc:
7 8 9 |
# File 'lib/hoe/history.rb', line 7 def define_history_tasks # :nodoc: # do nothing end |
#flog_flay ⇒ Object
Calculate the flog and flay score for a Hoe project.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/hoe/history.rb', line 14 def flog_flay flog = `flog -s -c $(cat Manifest.txt | grep -v txt$) 2>/dev/null` flay = `flay -s $(cat Manifest.txt | grep -v txt$) 2>/dev/null` flog_total = flog[/([\d\.]+): flog total/, 1].to_f flog_avg = flog[/([\d\.]+): flog\/method average/, 1].to_f flay_total = flay[/Total score .lower is better. = (\d+)/, 1].to_i return flog_total, flog_avg, flay_total end |
#history(versions) ⇒ Object
Calculate the history across all versions. Uses ‘versions` from an SCM plugin to figure out how to deal with the SCM.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/hoe/history.rb', line 47 def history versions history = load_history history.delete "dev" # FIX: this is p4 specific - make a variable? flog_total = flog_avg = flay_total = nil puts "version\tflog\tavg\tflay" versions.each do |version| history[version] = yield(version) unless history[version] flog_total, flog_avg, flay_total = history[version] puts "%s\t%.1f\t%.1f\t%d" % [version, flog_total, flog_avg, flay_total] end ensure save_history history end |
#load_history ⇒ Object
Load cached history.
28 29 30 31 |
# File 'lib/hoe/history.rb', line 28 def load_history require "yaml" YAML.load_file(".history.yaml") rescue {} end |
#save_history(data) ⇒ Object
Save cached history.
36 37 38 39 40 41 |
# File 'lib/hoe/history.rb', line 36 def save_history data require "yaml" File.open ".history.yaml", "w" do |f| YAML.dump data, f end end |