Class: FlayGauntlet

Inherits:
Gauntlet
  • Object
show all
Defined in:
lib/gauntlet_flay.rb

Overview

:stopdoc:

Constant Summary collapse

MY_PROJECTS =
Regexp.union(*my_projects)

Instance Method Summary collapse

Instance Method Details

#display_report(max) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/gauntlet_flay.rb', line 38

def display_report max
  good_data  = {}
  bad_count  = 0
  zero_count = 0

  @data.each do |name, flay|
    case
    when flay < 0 then
      bad_count += 1
    when flay == 0 then
      zero_count += 1
    else
      good_data[name] = flay
    end
  end

  scores = good_data.values

  # SWEET JESUS:
  #
  # without zeros:
  #   average flay: 1487.23 +/- 7800.16
  # with zeros:
  #   average flay:  988.69 +/- 6398.45

  puts "broken projects : %d" % bad_count
  puts "great projects  : %d" % zero_count
  puts "bad projects    : %d" % good_data.size
  puts "average flay    : %.2f +/- %.2f" % [scores.average, scores.stddev]

  top = good_data.sort_by { |name,flay| -flay }.first max

  puts
  top.each_with_index do |(name, flay), i|
    puts "%3d: %10.2f: %s" % [ i, flay, name ]
  end
end

#run(name) ⇒ Object



32
33
34
35
36
# File 'lib/gauntlet_flay.rb', line 32

def run name
  warn name
  self.data[name] = score_for "."
  self.dirty = true
end

#score_for(dir) ⇒ Object

OTHER



80
81
82
83
84
85
86
87
88
89
# File 'lib/gauntlet_flay.rb', line 80

def score_for dir
  dirs = %w(app lib test spec).reject { |f| ! File.directory? f }

  flay = Flay.run dirs
  flay.total
rescue Interrupt
  # let us break out
rescue Exception
  -1
end