hotch 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/hotch.gemspec +1 -1
- data/lib/hotch.rb +20 -13
- data/lib/hotch/minitest.rb +15 -6
- data/lib/hotch/version.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe917b25f6086e27f2ee1a3480a9799cf544a7b7
|
4
|
+
data.tar.gz: cfa25132e4ce2f7ac32a4c11d58890a9f9baba1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 108abb9f4f02c719daa08a3789ab3371063c46b6ba3490a8d3d254d09434791fb7c21bb923907a8aae80cd83d735e9a24e3b22d510ce25418b93c40250da3ab3
|
7
|
+
data.tar.gz: 42ded157f0a1c13c15877033be0538780f4a0d04a87e5865fb33a878f5584e203d4c51ec9f65b835b5696f1818faaf69b688a424f91a57bfab20c2db17276186
|
data/README.md
CHANGED
@@ -81,6 +81,11 @@ Load `hotch/minitest` in your `test/test_helper.rb` like this:
|
|
81
81
|
```ruby
|
82
82
|
require 'minitest/autorun'
|
83
83
|
require 'hotch/minitest'
|
84
|
+
|
85
|
+
Hotch::Minitest.run
|
86
|
+
Hotch::Minitest.run(filter: /MyClass/)
|
87
|
+
Hotch::Minitest.run(options: <stackprof options>)
|
88
|
+
Hotch::Minitest.run(options: { limit: 200 })
|
84
89
|
```
|
85
90
|
|
86
91
|
## Caveat
|
data/hotch.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "stackprof", "~> 0.2.
|
21
|
+
spec.add_runtime_dependency "stackprof", "~> 0.2.8"
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.7"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/hotch.rb
CHANGED
@@ -4,13 +4,15 @@ require 'tmpdir'
|
|
4
4
|
require 'hotch/monkey_patches'
|
5
5
|
|
6
6
|
class Hotch
|
7
|
-
attr_reader :name, :viewer, :filter
|
7
|
+
attr_reader :name, :viewer, :filter, :options
|
8
8
|
|
9
|
-
def initialize(name, viewer: nil, filter: nil)
|
9
|
+
def initialize(name, viewer: nil, filter: nil, options: {})
|
10
10
|
@name = name
|
11
11
|
@viewer = viewer
|
12
|
-
@
|
12
|
+
@options = options
|
13
13
|
@reports = []
|
14
|
+
|
15
|
+
@options[:filter] = Regexp.new(filter) if filter
|
14
16
|
end
|
15
17
|
|
16
18
|
def start(*args)
|
@@ -73,19 +75,15 @@ class Hotch
|
|
73
75
|
end
|
74
76
|
|
75
77
|
def report_dump(report, dir, file)
|
76
|
-
|
77
|
-
File.open(path, 'wb') do |fh|
|
78
|
+
write_file(dir, file) do |fh|
|
78
79
|
report.print_dump(fh)
|
79
80
|
end
|
80
|
-
path
|
81
81
|
end
|
82
82
|
|
83
83
|
def report_dot(report, dir, file)
|
84
|
-
|
85
|
-
|
86
|
-
report.print_graphviz(filter && Regexp.new(filter), fh)
|
84
|
+
write_file(dir, file) do |fh|
|
85
|
+
report.print_graphviz(options, fh)
|
87
86
|
end
|
88
|
-
path
|
89
87
|
end
|
90
88
|
|
91
89
|
def convert_svg(dir, dot, file)
|
@@ -93,14 +91,23 @@ class Hotch
|
|
93
91
|
system("dot", "-Tsvg", "-o", svg, dot) or raise "dot failed"
|
94
92
|
svg
|
95
93
|
end
|
94
|
+
|
95
|
+
def write_file(dir, file)
|
96
|
+
path = File.join(dir, file)
|
97
|
+
File.open(path, 'wb') do |fh|
|
98
|
+
yield fh
|
99
|
+
end
|
100
|
+
path
|
101
|
+
end
|
96
102
|
end
|
97
103
|
|
98
|
-
def Hotch(name: $0, aggregate: true, viewer: ENV['HOTCH_VIEWER'], filter: ENV['HOTCH_FILTER'])
|
104
|
+
def Hotch(name: $0, aggregate: true, viewer: ENV['HOTCH_VIEWER'], filter: ENV['HOTCH_FILTER'], options: {})
|
99
105
|
hotch = if aggregate
|
100
|
-
$hotch ||= Hotch.new(name, viewer: viewer, filter: filter)
|
106
|
+
$hotch ||= Hotch.new(name, viewer: viewer, filter: filter, options: options)
|
101
107
|
else
|
102
108
|
caller = Kernel.caller_locations(1).first
|
103
|
-
|
109
|
+
name = "#{name}:#{caller.path}:#{caller.lineno}"
|
110
|
+
Hotch.new(name, viewer: viewer, filter: filter, options: options)
|
104
111
|
end
|
105
112
|
|
106
113
|
hotch.report_at_exit
|
data/lib/hotch/minitest.rb
CHANGED
@@ -1,13 +1,25 @@
|
|
1
|
+
require "hotch"
|
2
|
+
|
1
3
|
class Hotch
|
2
4
|
module Minitest
|
3
5
|
# Usage in test/test_helper.rb:
|
4
6
|
#
|
5
7
|
# require 'hotch/minitest'
|
6
8
|
#
|
7
|
-
|
9
|
+
# Hotch::Minitest.run
|
10
|
+
# Hotch::Minitest.run(filter: /MyClass/)
|
11
|
+
# Hotch::Minitest.run(options: <stackprof options>)
|
12
|
+
# Hotch::Minitest.run(options: { limit: 200 })
|
13
|
+
#
|
14
|
+
def self.run(**options)
|
15
|
+
::Minitest.singleton_class.prepend Hotch::Minitest.aggregate(**options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.aggregate(**options)
|
8
19
|
Module.new do
|
9
|
-
|
10
|
-
|
20
|
+
define_method(:run_one_method) do |*args|
|
21
|
+
options[:aggregate] = true
|
22
|
+
Hotch(**options) do
|
11
23
|
super(*args)
|
12
24
|
end
|
13
25
|
end
|
@@ -15,6 +27,3 @@ class Hotch
|
|
15
27
|
end
|
16
28
|
end
|
17
29
|
end
|
18
|
-
|
19
|
-
require "hotch"
|
20
|
-
Minitest.singleton_class.prepend Hotch::Minitest.aggregate
|
data/lib/hotch/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Suschlik
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.
|
19
|
+
version: 0.2.8
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.
|
26
|
+
version: 0.2.8
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,9 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
95
|
+
rubygems_version: 2.4.8
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Profile helper
|
99
99
|
test_files: []
|
100
|
-
has_rdoc:
|