benchmark_methods 0.6 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/benchmark_methods.rb +4 -5
- data/lib/benchmark_methods/version.rb +1 -1
- data/lib/string_ext.rb +7 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24fe7a39cefe5ab4723fea43dd71544d8fdf02c2
|
4
|
+
data.tar.gz: 8c32f0a8535f0e176374ed80f0c83f2661a419ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14e86f6188129566bd543921084af947339c002e3ba0b3e8893e307afb883951c2375244e525cdc71e1088c3ae07dece8b4bf6d40e31a38cca91f39513f00cdd
|
7
|
+
data.tar.gz: cc0252fd70e26e4f87418f4c822374d1dcc8124543c42509ddb12eca4a064485984a102a1a239eab87379bfede2c71b0f7f88e4b5b5e6d082469c0785cef30e9
|
data/lib/benchmark_methods.rb
CHANGED
@@ -4,12 +4,11 @@ require_relative 'string_ext.rb'
|
|
4
4
|
require 'benchmark_methods/version'
|
5
5
|
|
6
6
|
module BenchmarkMethods
|
7
|
-
using StringExt
|
8
7
|
|
9
8
|
def self.included(base_klass)
|
10
|
-
unless const_defined?("#{base_klass.name.
|
9
|
+
unless const_defined?("#{base_klass.name.demodulize_for_bm}Interceptor")
|
11
10
|
base_klass.extend(ClassMethods)
|
12
|
-
interceptor = const_set("#{base_klass.name.
|
11
|
+
interceptor = const_set("#{base_klass.name.demodulize_for_bm}Interceptor", Module.new)
|
13
12
|
base_klass.send(:prepend, interceptor)
|
14
13
|
end
|
15
14
|
end
|
@@ -42,7 +41,7 @@ module BenchmarkMethods
|
|
42
41
|
module ClassMethods
|
43
42
|
|
44
43
|
def cbenchmark(*cmethods)
|
45
|
-
interceptor = const_get("#{name.
|
44
|
+
interceptor = const_get("#{name.demodulize_for_bm}Interceptor")
|
46
45
|
klass = const_get(name)
|
47
46
|
helper = const_set("BenchmarkMethods#{SecureRandom.hex}Helper", Module.new)
|
48
47
|
cmethods.each do |method_name|
|
@@ -62,7 +61,7 @@ module BenchmarkMethods
|
|
62
61
|
end
|
63
62
|
|
64
63
|
def benchmark(*cmethods)
|
65
|
-
interceptor = const_get("#{name.
|
64
|
+
interceptor = const_get("#{name.demodulize_for_bm}Interceptor")
|
66
65
|
klass = const_get(name)
|
67
66
|
cmethods.each do |method_name|
|
68
67
|
interceptor.module_eval do
|
data/lib/string_ext.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
path
|
9
|
-
end
|
1
|
+
class String
|
2
|
+
def demodulize_for_bm
|
3
|
+
path = self
|
4
|
+
if i = path.rindex('::')
|
5
|
+
path[(i+2)..-1]
|
6
|
+
else
|
7
|
+
path
|
10
8
|
end
|
11
9
|
end
|
12
10
|
end
|