trace_location 0.10.0 → 0.12.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/Gemfile.lock +33 -26
- data/README.md +2 -1
- data/exe/trace_location +6 -0
- data/lib/trace_location/cli.rb +59 -0
- data/lib/trace_location/collector.rb +4 -2
- data/lib/trace_location/version.rb +1 -1
- data/lib/trace_location.rb +2 -1
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f72080e074e711ead889178f5bf03db6f01b2d1f2baee4c7a0017c8e1b374e2
|
4
|
+
data.tar.gz: 83d066fd0c05fd30488ab17a213d2e6cc871a6b2274e155dd3ee87f2c12cf7a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5ea1a2a317eeddd8a02b6013150a8969db58738b724004775f99d4a284cfdc394d620a81bff79063cd07cf295f42f4be98d62b3150c62da83fed95b3f51e6dc
|
7
|
+
data.tar.gz: 9fae9ec4eb6e18de78ffec2e94718fd8eb7b3d3fb8f46964aecce96da4fedfc5efe161d2ce2f514a201e0cb556b3e2759e1f7136a0c9c0b9ef655419e4bedd2a
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,43 +1,50 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
trace_location (0.
|
4
|
+
trace_location (0.12.0)
|
5
5
|
method_source
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
ast (2.4.
|
11
|
-
diff-lcs (1.
|
12
|
-
|
10
|
+
ast (2.4.2)
|
11
|
+
diff-lcs (1.5.0)
|
12
|
+
json (2.6.3)
|
13
13
|
method_source (1.0.0)
|
14
|
-
parallel (1.
|
15
|
-
parser (
|
16
|
-
ast (~> 2.4.
|
17
|
-
rainbow (3.
|
18
|
-
rake (13.0.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
rspec-
|
23
|
-
|
24
|
-
rspec-
|
25
|
-
rspec-
|
14
|
+
parallel (1.22.1)
|
15
|
+
parser (3.1.3.0)
|
16
|
+
ast (~> 2.4.1)
|
17
|
+
rainbow (3.1.1)
|
18
|
+
rake (13.0.6)
|
19
|
+
regexp_parser (2.6.1)
|
20
|
+
rexml (3.2.5)
|
21
|
+
rspec (3.12.0)
|
22
|
+
rspec-core (~> 3.12.0)
|
23
|
+
rspec-expectations (~> 3.12.0)
|
24
|
+
rspec-mocks (~> 3.12.0)
|
25
|
+
rspec-core (3.12.0)
|
26
|
+
rspec-support (~> 3.12.0)
|
27
|
+
rspec-expectations (3.12.0)
|
26
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
-
rspec-support (~> 3.
|
28
|
-
rspec-mocks (3.
|
29
|
+
rspec-support (~> 3.12.0)
|
30
|
+
rspec-mocks (3.12.1)
|
29
31
|
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
-
rspec-support (~> 3.
|
31
|
-
rspec-support (3.
|
32
|
-
rubocop (
|
33
|
-
|
32
|
+
rspec-support (~> 3.12.0)
|
33
|
+
rspec-support (3.12.0)
|
34
|
+
rubocop (1.40.0)
|
35
|
+
json (~> 2.3)
|
34
36
|
parallel (~> 1.10)
|
35
|
-
parser (>= 2.
|
37
|
+
parser (>= 3.1.2.1)
|
36
38
|
rainbow (>= 2.2.2, < 4.0)
|
39
|
+
regexp_parser (>= 1.8, < 3.0)
|
40
|
+
rexml (>= 3.2.5, < 4.0)
|
41
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
37
42
|
ruby-progressbar (~> 1.7)
|
38
|
-
unicode-display_width (>= 1.4.0, <
|
39
|
-
|
40
|
-
|
43
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
44
|
+
rubocop-ast (1.24.0)
|
45
|
+
parser (>= 3.1.1.0)
|
46
|
+
ruby-progressbar (1.11.0)
|
47
|
+
unicode-display_width (2.3.0)
|
41
48
|
|
42
49
|
PLATFORMS
|
43
50
|
ruby
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/yhirano55/trace_location)
|
4
4
|
|
5
|
-
TraceLocation helps you
|
5
|
+
TraceLocation helps you trace the source location to ease reading huge open-source libraries in Ruby.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -42,6 +42,7 @@ Then you can get logs like this: [.md](https://github.com/yhirano55/trace_locati
|
|
42
42
|
| format | `:md`, `:log`, `:csv` (default: `:md`) | `:md` |
|
43
43
|
| match | Regexp, Symbol, String or Array for allow list | `[:activerecord, :activesupport]` |
|
44
44
|
| ignore | Regexp, Symbol, String or Array for deny list | `/bootsnap\|activesupport/` |
|
45
|
+
| methods | Symbol or Array of method names | `[:call]` |
|
45
46
|
|
46
47
|
## More examples
|
47
48
|
|
data/exe/trace_location
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module TraceLocation
|
4
|
+
class CLI
|
5
|
+
attr_reader :argv
|
6
|
+
|
7
|
+
def initialize(argv)
|
8
|
+
@argv = argv
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
opt = OptionParser.new
|
13
|
+
opt.on('-f FORMAT', '--format=FORMAT', 'Report format (default: :md)', &:to_sym)
|
14
|
+
opt.on('-m REGEXP', '--match=REGEXP') { |str| Regexp.new(str) }
|
15
|
+
opt.on('-i REGEXP', '--ignore=REGEXP') { |str| Regexp.new(str) }
|
16
|
+
opt.on('-d DIR', '--dest-dir=DIR')
|
17
|
+
opt.on('-e code')
|
18
|
+
|
19
|
+
params = {}
|
20
|
+
opt.order!(argv, into: params)
|
21
|
+
params.transform_keys! { |k| k.to_s.gsub('-', '_').to_sym }
|
22
|
+
|
23
|
+
if code = params.delete(:e)
|
24
|
+
exec_code code, params
|
25
|
+
else
|
26
|
+
file = argv.shift
|
27
|
+
unless file
|
28
|
+
puts opt.help
|
29
|
+
exit 1
|
30
|
+
end
|
31
|
+
|
32
|
+
exec_command file, params
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def exec_command(cmd, params)
|
39
|
+
path =
|
40
|
+
if File.exist?(cmd)
|
41
|
+
cmd
|
42
|
+
else
|
43
|
+
`which #{cmd}`.chomp
|
44
|
+
end
|
45
|
+
|
46
|
+
$PROGRAM_NAME = cmd
|
47
|
+
|
48
|
+
TraceLocation.trace(params) do
|
49
|
+
load path
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def exec_code(code, params)
|
54
|
+
TraceLocation.trace(params) do
|
55
|
+
eval code
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -8,7 +8,8 @@ module TraceLocation
|
|
8
8
|
Result = Struct.new(:events, :return_value)
|
9
9
|
|
10
10
|
class << self
|
11
|
-
def collect(match:, ignore:, &block)
|
11
|
+
def collect(match:, ignore:, methods:, &block)
|
12
|
+
methods = Array(methods) if methods
|
12
13
|
events = []
|
13
14
|
hierarchy = 0
|
14
15
|
id = 0
|
@@ -18,6 +19,7 @@ module TraceLocation
|
|
18
19
|
tracer = TracePoint.new(:call, :return) do |trace_point|
|
19
20
|
next if match && !trace_point.path.to_s.match?(/#{Array(match).join('|')}/)
|
20
21
|
next if ignore && trace_point.path.to_s.match?(/#{Array(ignore).join('|')}/)
|
22
|
+
next if methods && !methods.include?(trace_point.method_id)
|
21
23
|
|
22
24
|
id += 1
|
23
25
|
caller_loc = caller_locations(2, 1)[0]
|
@@ -26,7 +28,7 @@ module TraceLocation
|
|
26
28
|
location_cache_key = "#{caller_path}:#{caller_lineno}"
|
27
29
|
|
28
30
|
mes = extract_method_from(trace_point)
|
29
|
-
next if mes.source_location[0]
|
31
|
+
next if mes.source_location[0].match?(/\A(?:<internal:.+>|\(eval\))\z/)
|
30
32
|
|
31
33
|
method_source = method_source_cache[mes] ||= remove_indent(mes.source)
|
32
34
|
|
data/lib/trace_location.rb
CHANGED
@@ -16,8 +16,9 @@ module TraceLocation # :nodoc:
|
|
16
16
|
def self.trace(options = {}, &block)
|
17
17
|
match = options.delete(:match)
|
18
18
|
ignore = options.delete(:ignore)
|
19
|
+
methods = options.delete(:methods)
|
19
20
|
|
20
|
-
result = Collector.collect(match: match, ignore: ignore, &block)
|
21
|
+
result = Collector.collect(match: match, ignore: ignore, methods: methods, &block)
|
21
22
|
Report.build(result.events, result.return_value, options).generate
|
22
23
|
true
|
23
24
|
rescue StandardError => e
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trace_location
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshiyuki Hirano
|
8
8
|
- Misaki Shioi
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: method_source
|
@@ -72,7 +72,8 @@ description: TraceLocation helps you get tracing the source location of codes, a
|
|
72
72
|
email:
|
73
73
|
- yhirano@me.com
|
74
74
|
- shioi.mm@gmail.com
|
75
|
-
executables:
|
75
|
+
executables:
|
76
|
+
- trace_location
|
76
77
|
extensions: []
|
77
78
|
extra_rdoc_files: []
|
78
79
|
files:
|
@@ -102,7 +103,9 @@ files:
|
|
102
103
|
- examples/rendering_process/result.csv
|
103
104
|
- examples/rendering_process/result.log
|
104
105
|
- examples/rendering_process/result.md
|
106
|
+
- exe/trace_location
|
105
107
|
- lib/trace_location.rb
|
108
|
+
- lib/trace_location/cli.rb
|
106
109
|
- lib/trace_location/collector.rb
|
107
110
|
- lib/trace_location/config.rb
|
108
111
|
- lib/trace_location/event.rb
|
@@ -119,7 +122,7 @@ homepage: https://github.com/yhirano55/trace_location
|
|
119
122
|
licenses:
|
120
123
|
- MIT
|
121
124
|
metadata: {}
|
122
|
-
post_install_message:
|
125
|
+
post_install_message:
|
123
126
|
rdoc_options: []
|
124
127
|
require_paths:
|
125
128
|
- lib
|
@@ -134,8 +137,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
137
|
- !ruby/object:Gem::Version
|
135
138
|
version: '0'
|
136
139
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
138
|
-
signing_key:
|
140
|
+
rubygems_version: 3.3.26
|
141
|
+
signing_key:
|
139
142
|
specification_version: 4
|
140
143
|
summary: helps you get tracing the source location of codes
|
141
144
|
test_files: []
|