myronmarston-test_benchmarker 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/test_benchmarker/core_ext.rb +41 -39
- data/lib/test_benchmarker/test_suite.rb +1 -1
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -1,46 +1,48 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
1
|
+
unless String.method_defined?(:constantize)
|
2
|
+
class String
|
3
|
+
# ported from ActiveSupport, so that we don't have to require all of active support for this gem.
|
4
|
+
# http://github.com/rails/rails/blob/dd2eb1ea7c34eb6496feaf7e42100f37a8dae76b/activesupport/lib/active_support/inflector.rb#L335-376
|
5
|
+
# Ruby 1.9 introduces an inherit argument for Module#const_get and
|
6
|
+
# #const_defined? and changes their default behavior.
|
7
|
+
if Module.method(:const_get).arity == 1
|
8
|
+
# Tries to find a constant with the name specified in the argument string:
|
9
|
+
#
|
10
|
+
# "Module".constantize # => Module
|
11
|
+
# "Test::Unit".constantize # => Test::Unit
|
12
|
+
#
|
13
|
+
# The name is assumed to be the one of a top-level constant, no matter whether
|
14
|
+
# it starts with "::" or not. No lexical context is taken into account:
|
15
|
+
#
|
16
|
+
# C = 'outside'
|
17
|
+
# module M
|
18
|
+
# C = 'inside'
|
19
|
+
# C # => 'inside'
|
20
|
+
# "C".constantize # => 'outside', same as ::C
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# NameError is raised when the name is not in CamelCase or the constant is
|
24
|
+
# unknown.
|
25
|
+
def constantize
|
26
|
+
names = self.split('::')
|
27
|
+
names.shift if names.empty? || names.first.empty?
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
constant = Object
|
30
|
+
names.each do |name|
|
31
|
+
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
32
|
+
end
|
33
|
+
constant
|
31
34
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
names = self.split('::')
|
37
|
-
names.shift if names.empty? || names.first.empty?
|
35
|
+
else
|
36
|
+
def constantize
|
37
|
+
names = self.split('::')
|
38
|
+
names.shift if names.empty? || names.first.empty?
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
constant = Object
|
41
|
+
names.each do |name|
|
42
|
+
constant = constant.const_get(name, false) || constant.const_missing(name)
|
43
|
+
end
|
44
|
+
constant
|
42
45
|
end
|
43
|
-
constant
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
@@ -18,7 +18,7 @@ if ENV['BENCHMARK_TESTS'] || ENV['TEST_BENCHMARKS_FILE']
|
|
18
18
|
if @@run_count == 0
|
19
19
|
results = TestBenchmarker::TestBenchmarks.results
|
20
20
|
if ENV['TEST_BENCHMARKS_FILE']
|
21
|
-
File.open(ENV['TEST_BENCHMARKS_FILE'], '
|
21
|
+
File.open(ENV['TEST_BENCHMARKS_FILE'], 'a') { |f| f << results }
|
22
22
|
else
|
23
23
|
puts results
|
24
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myronmarston-test_benchmarker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myron Marston
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-01 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|