hyper-trace 1.0.alpha1.3 → 1.0.alpha1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/Gemfile +1 -0
- data/hyper-trace.gemspec +3 -2
- data/lib/hyper_trace/hyper_trace.rb +82 -48
- data/lib/hyper_trace/version.rb +1 -1
- metadata +25 -18
- data/Gemfile.lock +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a22c24fb1118d3a13c8918174b6d16a961dd959938dd26023b0ca721d726046
|
4
|
+
data.tar.gz: 290bc4e8cf9230f37882546edf9ff85da60bd1a098a45f9140294f1df8ae2837
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e833fe34affd757cf911425635569fa92fa90c7c0e279d6fcc9942fc2865c731f649742da718bbadb041c4e07cd288eb86103857a21f7f84d761483e6763bbe
|
7
|
+
data.tar.gz: 5c1abe9dad2cc411546e50202f7977de825fcc66d38c4f8ff2a66e55116750d6c6d54ff0ad29e41f27a06f85f689c7fc71e098f5c2b9432ba39faee770018f46
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/hyper-trace.gemspec
CHANGED
@@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency 'hyperstack-config', HyperTrace::VERSION
|
22
|
-
spec.add_development_dependency
|
22
|
+
spec.add_development_dependency 'hyper-spec', HyperTrace::VERSION
|
23
|
+
spec.add_development_dependency "bundler"
|
23
24
|
spec.add_development_dependency 'chromedriver-helper'
|
24
|
-
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rake"
|
25
26
|
end
|
@@ -6,17 +6,7 @@ class Class
|
|
6
6
|
alias hypertrace hyper_trace
|
7
7
|
end
|
8
8
|
|
9
|
-
class Method
|
10
|
-
def parameters
|
11
|
-
/.*function[^(]*\(([^)]*)\)/
|
12
|
-
.match(`#{@method}.toString()`)[1]
|
13
|
-
.split(',')
|
14
|
-
.collect { |param| [:req, param.strip.to_sym] }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
9
|
module HyperTrace
|
19
|
-
|
20
10
|
class Config
|
21
11
|
def initialize(klass, instrument_class, opts, &block)
|
22
12
|
@klass = klass
|
@@ -116,15 +106,11 @@ module HyperTrace
|
|
116
106
|
def instrumentation_off(config)
|
117
107
|
if config.instrument_class?
|
118
108
|
config.klass.methods.grep(/^__hyper_trace_pre_.+$/).each do |method|
|
119
|
-
config.klass.
|
120
|
-
class << self
|
121
|
-
alias_method method.gsub(/^__hyper_trace_pre_/, ''), method
|
122
|
-
end
|
123
|
-
end
|
109
|
+
config.klass.singleton_class.alias_method method.gsub(/^__hyper_trace_pre_/, ''), method
|
124
110
|
end
|
125
111
|
else
|
126
112
|
config.klass.instance_methods.grep(/^__hyper_trace_pre_.+$/).each do |method|
|
127
|
-
config.klass.
|
113
|
+
config.klass.alias_method method.gsub(/^__hyper_trace_pre_/, ''), method
|
128
114
|
end
|
129
115
|
end
|
130
116
|
end
|
@@ -145,17 +131,12 @@ module HyperTrace
|
|
145
131
|
|
146
132
|
def instrument_method(method, config)
|
147
133
|
if config.instrument_class?
|
148
|
-
config.klass.
|
149
|
-
|
150
|
-
alias_method "__hyper_trace_pre_#{method}", method unless method_defined? "__pre_hyper_trace_#{method}"
|
151
|
-
end
|
134
|
+
unless config.klass.singleton_class.method_defined? "__pre_hyper_trace_#{method}" # is this right?
|
135
|
+
config.klass.singleton_class.alias_method "__hyper_trace_pre_#{method}", method
|
152
136
|
end
|
153
|
-
add_hyper_trace_method(method, config)
|
154
137
|
else
|
155
138
|
unless config.klass.method_defined? "__pre_hyper_trace_#{method}"
|
156
|
-
config.klass.
|
157
|
-
alias_method "__hyper_trace_pre_#{method}", method
|
158
|
-
end
|
139
|
+
config.klass.alias_method "__hyper_trace_pre_#{method}", method
|
159
140
|
end
|
160
141
|
end
|
161
142
|
add_hyper_trace_method(method, config)
|
@@ -194,28 +175,77 @@ module HyperTrace
|
|
194
175
|
end
|
195
176
|
end
|
196
177
|
|
178
|
+
def required(arity, actual_length)
|
179
|
+
if arity.negative?
|
180
|
+
req_count = - arity - 1
|
181
|
+
raise ArgumentError, "missing required arguments: #{actual_length} for #{req_count}" if req_count > actual_length
|
182
|
+
else
|
183
|
+
req_count = arity
|
184
|
+
raise ArgumentError, "incorrect number of arguments, expected #{req_count} got #{actual_length}" if req_count != actual_length
|
185
|
+
end
|
186
|
+
req_count
|
187
|
+
end
|
188
|
+
|
189
|
+
# [["req", "x"], ["opt", "y"], ["rest"], ["keyreq", "z"], ["key", "opt"], ["block", "flop"]]
|
190
|
+
|
191
|
+
def map_parameters(instance, name, actual, format = true)
|
192
|
+
method = instance.method("__hyper_trace_pre_#{name}")
|
193
|
+
map_with_specs(method, actual.dup, format) || map_without_specs(actual, format)
|
194
|
+
end
|
195
|
+
|
196
|
+
def key?(actual, key)
|
197
|
+
actual&.last&.respond_to?(:key?) && actual.last.key?(key)
|
198
|
+
end
|
199
|
+
|
200
|
+
def map_with_specs(method, actual, show_blank_rest)
|
201
|
+
specs = method.parameters
|
202
|
+
req_count = required(method.arity, actual.length)
|
203
|
+
args = {}
|
204
|
+
|
205
|
+
specs.each do |type, key|
|
206
|
+
case type
|
207
|
+
when :req
|
208
|
+
args[key] = actual.shift
|
209
|
+
req_count -= 1
|
210
|
+
when :opt
|
211
|
+
args[key] = actual.shift if actual.length > req_count
|
212
|
+
when (key || show_blank_rest) && :rest
|
213
|
+
args[key || '*'] = [*actual[0..-req_count - 1]]
|
214
|
+
when :keyreq
|
215
|
+
raise ArgumentError, "missing keyword argument: #{key}" unless key?(actual, key)
|
216
|
+
|
217
|
+
args[key] = actual.last[key]
|
218
|
+
when key?(actual, key) && :key
|
219
|
+
args[key] = actual.last[key]
|
220
|
+
end
|
221
|
+
end
|
222
|
+
args
|
223
|
+
rescue ArgumentError, Interrupt, SignalException => e
|
224
|
+
raise e
|
225
|
+
rescue Exception => e
|
226
|
+
nil
|
227
|
+
end
|
228
|
+
|
229
|
+
def map_without_specs(actual, format)
|
230
|
+
args = {}
|
231
|
+
prefix = 'p' unless format
|
232
|
+
actual.each_with_index { |value, i| args["#{prefix}#{i + 1}"] = value }
|
233
|
+
args
|
234
|
+
end
|
235
|
+
|
197
236
|
def format_head(instance, name, args, &block)
|
198
237
|
@formatting = true
|
199
|
-
method = instance.method("__hyper_trace_pre_#{name}")
|
200
238
|
if args.any?
|
201
239
|
group(" #{name}(...)#{instance_tag(instance)}") do
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
arg = args[i..-1]
|
209
|
-
else
|
210
|
-
arg = args[i]
|
211
|
-
end
|
212
|
-
if safe_i(arg).length > 30 || show_js_object(arg)
|
213
|
-
group "#{arg_name}: #{safe_s(arg)}"[0..29], collapsed: true do
|
214
|
-
puts safe_i(arg)
|
215
|
-
log arg if show_js_object(arg)
|
240
|
+
group("args: (#{args.length})", collapsed: true) do
|
241
|
+
map_parameters(instance, name, args).each do |arg, value|
|
242
|
+
if safe_i(value).length > 30 || show_js_object(value)
|
243
|
+
group "#{arg}: #{safe_s(value)}"[0..29], collapsed: true do
|
244
|
+
puts safe_i(value)
|
245
|
+
log value if show_js_object(value)
|
216
246
|
end
|
217
247
|
else
|
218
|
-
group "#{
|
248
|
+
group "#{arg}: #{safe_i(value)}"
|
219
249
|
end
|
220
250
|
end
|
221
251
|
end
|
@@ -286,7 +316,10 @@ module HyperTrace
|
|
286
316
|
@formatting = true
|
287
317
|
if safe_i(result).length > 40
|
288
318
|
group "raised: #{safe_s(result)}"[0..40], collapsed: true do
|
289
|
-
puts
|
319
|
+
puts result.backtrace[0]
|
320
|
+
result.backtrace[1..-1].each do |line|
|
321
|
+
log line
|
322
|
+
end
|
290
323
|
end
|
291
324
|
else
|
292
325
|
group "raised: #{safe_i(result)}"
|
@@ -305,24 +338,23 @@ module HyperTrace
|
|
305
338
|
|
306
339
|
def breakpoint(location, config, name, args, instance, result = nil)
|
307
340
|
if should_break? location, config, name, args, instance, result
|
308
|
-
|
341
|
+
params = map_parameters(instance, name, args, false)
|
309
342
|
fn_def = ['RESULT']
|
310
|
-
fn_def +=
|
343
|
+
fn_def += params.keys
|
311
344
|
fn_def += ["//break on #{location} of #{name}\nvar self = this;\ndebugger;\n;"]
|
312
345
|
puts "break on #{location} of #{name}"
|
313
346
|
fn = `Function.apply(#{self}, #{fn_def}).bind(#{instance})`
|
314
|
-
fn.call(result, *
|
347
|
+
fn.call(result, *params.values)
|
315
348
|
end
|
316
349
|
end
|
317
350
|
|
318
|
-
def call_original(instance, method,
|
351
|
+
def call_original(instance, method, args, &block)
|
319
352
|
@formatting = false
|
320
353
|
instance.send "__hyper_trace_pre_#{method}", *args, &block
|
321
354
|
ensure
|
322
355
|
@formatting = true
|
323
356
|
end
|
324
357
|
|
325
|
-
|
326
358
|
def add_hyper_trace_method(method, config)
|
327
359
|
def_method = config.instrument_class? ? :define_singleton_method : :define_method
|
328
360
|
config.klass.send(def_method, method) do |*args, &block|
|
@@ -330,7 +362,7 @@ module HyperTrace
|
|
330
362
|
if HyperTrace.formatting?
|
331
363
|
begin
|
332
364
|
send "__hyper_trace_pre_#{method}", *args, &block
|
333
|
-
rescue
|
365
|
+
rescue StandardError
|
334
366
|
"???"
|
335
367
|
end
|
336
368
|
else
|
@@ -338,11 +370,13 @@ module HyperTrace
|
|
338
370
|
HyperTrace.format_head(self, method, args) do
|
339
371
|
HyperTrace.format_instance_internal(self)
|
340
372
|
HyperTrace.breakpoint(:enter, config, method, args, self)
|
341
|
-
result = HyperTrace.call_original self, method,
|
373
|
+
result = HyperTrace.call_original self, method, args, &block
|
342
374
|
HyperTrace.format_result(result)
|
343
375
|
HyperTrace.breakpoint(:exit, config, method, args, self, result)
|
344
376
|
result
|
345
377
|
end
|
378
|
+
rescue Interrupt, SignalException => e
|
379
|
+
raise e
|
346
380
|
rescue Exception => e
|
347
381
|
HyperTrace.format_exception(e)
|
348
382
|
debugger unless HyperTrace.exclusions[self.class][:rescue].include? :method
|
data/lib/hyper_trace/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyper-trace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.alpha1.
|
4
|
+
version: 1.0.alpha1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- catmando
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hyperstack-config
|
@@ -16,34 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.alpha1.
|
19
|
+
version: 1.0.alpha1.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: 1.0.alpha1.
|
26
|
+
version: 1.0.alpha1.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hyper-spec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.alpha1.8
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.alpha1.8
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
-
- - "<"
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: '2.1'
|
47
|
+
version: '0'
|
37
48
|
type: :development
|
38
49
|
prerelease: false
|
39
50
|
version_requirements: !ruby/object:Gem::Requirement
|
40
51
|
requirements:
|
41
52
|
- - ">="
|
42
53
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
44
|
-
- - "<"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '2.1'
|
54
|
+
version: '0'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: chromedriver-helper
|
49
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -62,16 +70,16 @@ dependencies:
|
|
62
70
|
name: rake
|
63
71
|
requirement: !ruby/object:Gem::Requirement
|
64
72
|
requirements:
|
65
|
-
- - "
|
73
|
+
- - ">="
|
66
74
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
75
|
+
version: '0'
|
68
76
|
type: :development
|
69
77
|
prerelease: false
|
70
78
|
version_requirements: !ruby/object:Gem::Requirement
|
71
79
|
requirements:
|
72
|
-
- - "
|
80
|
+
- - ">="
|
73
81
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
82
|
+
version: '0'
|
75
83
|
description:
|
76
84
|
email:
|
77
85
|
- mitch@catprint.com
|
@@ -83,7 +91,6 @@ files:
|
|
83
91
|
- CODE_OF_CONDUCT.md
|
84
92
|
- DOCS.md
|
85
93
|
- Gemfile
|
86
|
-
- Gemfile.lock
|
87
94
|
- Rakefile
|
88
95
|
- hyper-trace.gemspec
|
89
96
|
- lib/hyper-trace.rb
|
@@ -109,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
116
|
- !ruby/object:Gem::Version
|
110
117
|
version: 1.3.1
|
111
118
|
requirements: []
|
112
|
-
rubygems_version: 3.0.
|
119
|
+
rubygems_version: 3.0.8
|
113
120
|
signing_key:
|
114
121
|
specification_version: 4
|
115
122
|
summary: Method tracing and conditional breakpoints for Opal Ruby
|
data/Gemfile.lock
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ../hyperstack-config
|
3
|
-
specs:
|
4
|
-
hyperstack-config (1.0.alpha1.3)
|
5
|
-
listen (~> 3.0)
|
6
|
-
mini_racer (~> 0.2.4)
|
7
|
-
opal (>= 0.11.0, < 0.12.0)
|
8
|
-
opal-browser (~> 0.2.0)
|
9
|
-
uglifier
|
10
|
-
websocket
|
11
|
-
|
12
|
-
PATH
|
13
|
-
remote: .
|
14
|
-
specs:
|
15
|
-
hyper-trace (1.0.alpha1.3)
|
16
|
-
hyperstack-config (= 1.0.alpha1.3)
|
17
|
-
|
18
|
-
GEM
|
19
|
-
remote: https://rubygems.org/
|
20
|
-
specs:
|
21
|
-
archive-zip (0.11.0)
|
22
|
-
io-like (~> 0.3.0)
|
23
|
-
ast (2.4.0)
|
24
|
-
chromedriver-helper (2.1.0)
|
25
|
-
archive-zip (~> 0.10)
|
26
|
-
nokogiri (~> 1.8)
|
27
|
-
execjs (2.7.0)
|
28
|
-
ffi (1.10.0)
|
29
|
-
hike (1.2.3)
|
30
|
-
io-like (0.3.0)
|
31
|
-
libv8 (6.7.288.46.1)
|
32
|
-
listen (3.1.5)
|
33
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
34
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
35
|
-
ruby_dep (~> 1.2)
|
36
|
-
mini_portile2 (2.3.0)
|
37
|
-
mini_racer (0.2.4)
|
38
|
-
libv8 (>= 6.3)
|
39
|
-
nokogiri (1.8.5)
|
40
|
-
mini_portile2 (~> 2.3.0)
|
41
|
-
opal (0.11.4)
|
42
|
-
ast (>= 2.3.0)
|
43
|
-
hike (~> 1.2)
|
44
|
-
parser (= 2.3.3.1)
|
45
|
-
sourcemap (~> 0.1.0)
|
46
|
-
opal-browser (0.2.0)
|
47
|
-
opal
|
48
|
-
paggio
|
49
|
-
paggio (0.2.6)
|
50
|
-
parser (2.3.3.1)
|
51
|
-
ast (~> 2.2)
|
52
|
-
rake (10.5.0)
|
53
|
-
rb-fsevent (0.10.3)
|
54
|
-
rb-inotify (0.10.0)
|
55
|
-
ffi (~> 1.0)
|
56
|
-
ruby_dep (1.5.0)
|
57
|
-
sourcemap (0.1.1)
|
58
|
-
uglifier (4.1.20)
|
59
|
-
execjs (>= 0.3.0, < 3)
|
60
|
-
websocket (1.2.8)
|
61
|
-
|
62
|
-
PLATFORMS
|
63
|
-
ruby
|
64
|
-
|
65
|
-
DEPENDENCIES
|
66
|
-
bundler (>= 1.17.3, < 2.1)
|
67
|
-
chromedriver-helper
|
68
|
-
hyper-trace!
|
69
|
-
hyperstack-config!
|
70
|
-
rake (~> 10.0)
|
71
|
-
|
72
|
-
BUNDLED WITH
|
73
|
-
2.0.1
|