benchmark_harness 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{benchmark_harness}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Daniel Higginbotham"]
@@ -43,14 +43,15 @@ class BenchmarkHarness
43
43
  else
44
44
  raise ArgumentError, "your signature must contain a method"
45
45
  end
46
-
46
+
47
47
  constant_name, method_name = signature.split(split_on)
48
+ method_name_safe = method_name.gsub(/[\W\D]/, '') # trip out ie !
48
49
  constant = get_constant(constant_name)
49
50
 
50
51
  method_definition = <<-END
51
- alias :#{method_name}_pre_benchmark_harness :#{method_name}
52
+ alias :#{method_name_safe}_pre_benchmark_harness :#{method_name}
52
53
  def #{method_name}(*args, &block)
53
- BenchmarkHarness.measure(:#{collection_name}){result = #{method_name}_pre_benchmark_harness(*args, &block)}
54
+ BenchmarkHarness.measure(:#{collection_name}){result = #{method_name_safe}_pre_benchmark_harness(*args, &block)}
54
55
  end
55
56
  END
56
57
 
@@ -69,7 +70,7 @@ class BenchmarkHarness
69
70
  if parent_constant.const_defined?(piece)
70
71
  parent_constant = parent_constant.const_get(piece)
71
72
  else
72
- raise NameError, "#{name} contains an undefined constant"
73
+ raise NameError, "#{name} contains an undefined constant; it may be autoloaded"
73
74
  end
74
75
  end
75
76
  parent_constant
@@ -95,6 +95,12 @@ describe "BenchmarkHarness" do
95
95
  NestedExample::OneLevelDown.new.subtract
96
96
  BenchmarkHarness.collections[:subtract].should_not be_empty
97
97
  end
98
+
99
+ it "should wrap a method with an '!' in the name" do
100
+ BenchmarkHarness.wrap_method("NestedExample#important!", :important)
101
+ NestedExample.new.important!
102
+ BenchmarkHarness.collections[:important].should_not be_empty
103
+ end
98
104
  end
99
105
 
100
106
  describe "#flush" do
@@ -1,4 +1,4 @@
1
- module NestedExample
1
+ class NestedExample
2
2
  class OneLevelDown
3
3
  class << self
4
4
  def add
@@ -10,4 +10,8 @@ module NestedExample
10
10
  1 - 1
11
11
  end
12
12
  end
13
+
14
+ def important!
15
+ return nil
16
+ end
13
17
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: benchmark_harness
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Daniel Higginbotham