Class: FlayGauntlet

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

Constant Summary collapse

MY_PROJECTS =
Regexp.union(*my_projects)

Instance Method Summary collapse

Instance Method Details

#display_report(max) ⇒ Object



37
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
# File 'lib/gauntlet_flay.rb', line 37

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



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

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

#score_for(dir) ⇒ Object

OTHER



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

def score_for dir
  # files = `find #{dir} -name \\*.rb | grep -v gen.*templ`.split(/\n/)
  flayer = Flay.new

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

  flay = Flay.new
  flay.process(*Flay.expand_dirs_to_files(dirs))
  flay.total
rescue Interrupt
  # let us break out
rescue Exception
  -1
end