minitest-ruby_golf_metrics 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,6 +9,7 @@ game by its rules:
9
9
  * your tasks are tested in the minitest class ```RubyGolfTest```
10
10
  * the contestants implement their solutions as module methods in the module
11
11
  ```RubyGolf```
12
+ * the test methods are called test_hole_<x>_<method_name>[_<numeric_suffix>]
12
13
 
13
14
  That's it.
14
15
 
@@ -11,40 +11,42 @@ module Minitest
11
11
  end
12
12
 
13
13
  def record(erg)
14
- method_name = erg.location.
14
+ method_definition = erg.location.
15
15
  gsub("RubyGolfTest#test_", "").
16
16
  gsub(/ .*$/, "").
17
- gsub(/_[0-9]+/, "")
18
- @ergs[method_name] ||= []
19
- @ergs[method_name] << erg.passed?
17
+ gsub(/_[0-9]$/, "").
18
+ gsub(/(hole)_([0-9]+)_/, "\\1 \\2#")
19
+ @ergs[method_definition] ||= []
20
+ @ergs[method_definition] << erg.passed?
20
21
  end
21
22
 
22
23
  def report
23
24
  io.puts "\nRuby Golf Metrics"
24
- @ergs.sort.each do |method_name, ergs|
25
+ @ergs.sort.each do |method_definition, ergs|
26
+ (hole, method_name) = method_definition.split("#")
25
27
  begin
26
28
  if ergs.all?
27
29
  begin
28
30
  counter = CharacterCounter.new(method_name)
29
- msg = " #{colorize(method_name, 32)}: #{counter.cumulative_size} character(s)"
31
+ msg = " #{colorize(hole, method_name, 32)}: #{counter.cumulative_size} character(s)"
30
32
  msg << " (#{counter.called_method_sizes.join(", ")})" if !counter.self_contained?
31
33
  io.puts msg
32
34
  rescue NoMethodError
33
- io.puts " #{colorize(method_name, 31)}: UNDEFINED"
35
+ io.puts " #{colorize(hole, method_name, 31)}: UNDEFINED"
34
36
  end
35
37
  else
36
- io.puts " #{colorize(method_name, 31)}: FAILED"
38
+ io.puts " #{colorize(hole, method_name, 31)}: FAILED"
37
39
  end
38
40
  rescue
39
- io.puts " #{colorize(method_name, 31)}: there was an error counting your characters"
41
+ io.puts " #{colorize(hole, method_name, 31)}: there was an error counting your characters"
40
42
  end
41
43
  end
42
44
  end
43
45
 
44
46
  private
45
47
 
46
- def colorize(text, color)
47
- options[:nocolor] ? text : "\e[#{color}m#{text}\e[0m"
48
+ def colorize(hole, method_name, color)
49
+ options[:nocolor] ? text : "\e[#{color}m#{hole} - #{method_name}\e[0m"
48
50
  end
49
51
 
50
52
  end
@@ -1,5 +1,5 @@
1
1
  module Minitest
2
2
  module RubyGolfMetrics
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-ruby_golf_metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-12 00:00:00.000000000 Z
12
+ date: 2013-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  segments:
112
112
  - 0
113
- hash: 227485318531602933
113
+ hash: 210727395796915245
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  none: false
116
116
  requirements:
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  segments:
121
121
  - 0
122
- hash: 227485318531602933
122
+ hash: 210727395796915245
123
123
  requirements: []
124
124
  rubyforge_project:
125
125
  rubygems_version: 1.8.23