trace_location 0.9.6 → 0.10.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 +8 -2
- data/Gemfile.lock +4 -8
- data/README.md +2 -0
- data/lib/trace_location.rb +2 -1
- data/lib/trace_location/collector.rb +11 -6
- data/lib/trace_location/version.rb +1 -1
- data/trace_location.gemspec +0 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1e2f74ef8aefad64a0a962c2a77dbd4a47d8992ca5ef027d0acf47da19e7c2a
|
4
|
+
data.tar.gz: ad9b606d32f96289cb629f0c58f7324e9d9704e084f61fc9bbf2d689836eabee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9835516aba4ce712bd1ef3311947e315e052de1c6cd102967d06d740db127c459754339b92221b7a2904046a8fdfe8391e105ff8001af915b9cd67eef79da1b2
|
7
|
+
data.tar.gz: 24d753f05e76317957adf43a6ab02024558af46f623a4ac548f22130b6bc7d450d238fca16d303986d3d70791b3f112919808f5de750a520c01978880826fe08
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,25 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
trace_location (0.
|
5
|
-
binding_of_caller
|
4
|
+
trace_location (0.10.0)
|
6
5
|
method_source
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
10
9
|
specs:
|
11
10
|
ast (2.4.0)
|
12
|
-
binding_of_caller (0.8.0)
|
13
|
-
debug_inspector (>= 0.0.1)
|
14
|
-
debug_inspector (0.0.3)
|
15
11
|
diff-lcs (1.3)
|
16
12
|
jaro_winkler (1.5.2)
|
17
|
-
method_source (0.
|
13
|
+
method_source (1.0.0)
|
18
14
|
parallel (1.17.0)
|
19
15
|
parser (2.6.3.0)
|
20
16
|
ast (~> 2.4.0)
|
21
17
|
rainbow (3.0.0)
|
22
|
-
rake (
|
18
|
+
rake (13.0.1)
|
23
19
|
rspec (3.8.0)
|
24
20
|
rspec-core (~> 3.8.0)
|
25
21
|
rspec-expectations (~> 3.8.0)
|
@@ -54,4 +50,4 @@ DEPENDENCIES
|
|
54
50
|
trace_location!
|
55
51
|
|
56
52
|
BUNDLED WITH
|
57
|
-
2.
|
53
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# TraceLocation
|
2
2
|
|
3
|
+
[](https://travis-ci.org/yhirano55/trace_location)
|
4
|
+
|
3
5
|
TraceLocation helps you get tracing the source location of codes, and helps you can get reading the huge open souce libraries in Ruby.
|
4
6
|
|
5
7
|
## Installation
|
data/lib/trace_location.rb
CHANGED
@@ -21,7 +21,8 @@ module TraceLocation # :nodoc:
|
|
21
21
|
Report.build(result.events, result.return_value, options).generate
|
22
22
|
true
|
23
23
|
rescue StandardError => e
|
24
|
-
$
|
24
|
+
$stderr.puts "Failure: TraceLocation got an unexpected error."
|
25
|
+
$stderr.puts e.full_message
|
25
26
|
false
|
26
27
|
end
|
27
28
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'binding_of_caller'
|
4
3
|
require 'method_source'
|
5
4
|
|
6
5
|
module TraceLocation
|
@@ -14,16 +13,22 @@ module TraceLocation
|
|
14
13
|
hierarchy = 0
|
15
14
|
id = 0
|
16
15
|
cache = {}
|
16
|
+
method_source_cache = {}
|
17
17
|
|
18
18
|
tracer = TracePoint.new(:call, :return) do |trace_point|
|
19
19
|
next if match && !trace_point.path.to_s.match?(/#{Array(match).join('|')}/)
|
20
20
|
next if ignore && trace_point.path.to_s.match?(/#{Array(ignore).join('|')}/)
|
21
21
|
|
22
22
|
id += 1
|
23
|
-
|
23
|
+
caller_loc = caller_locations(2, 1)[0]
|
24
|
+
caller_path = caller_loc.absolute_path
|
25
|
+
caller_lineno = caller_loc.lineno
|
24
26
|
location_cache_key = "#{caller_path}:#{caller_lineno}"
|
25
27
|
|
26
28
|
mes = extract_method_from(trace_point)
|
29
|
+
next if mes.source_location[0] == '<internal:prelude>'
|
30
|
+
|
31
|
+
method_source = method_source_cache[mes] ||= remove_indent(mes.source)
|
27
32
|
|
28
33
|
case trace_point.event
|
29
34
|
when :call
|
@@ -38,7 +43,7 @@ module TraceLocation
|
|
38
43
|
caller_lineno: caller_lineno,
|
39
44
|
owner: mes.owner,
|
40
45
|
name: mes.name,
|
41
|
-
source:
|
46
|
+
source: method_source,
|
42
47
|
hierarchy: hierarchy,
|
43
48
|
is_module: trace_point.self.is_a?(Module)
|
44
49
|
)
|
@@ -56,7 +61,7 @@ module TraceLocation
|
|
56
61
|
caller_lineno: caller_lineno,
|
57
62
|
owner: mes.owner,
|
58
63
|
name: mes.name,
|
59
|
-
source:
|
64
|
+
source: method_source,
|
60
65
|
hierarchy: hierarchy,
|
61
66
|
is_module: trace_point.self.is_a?(Module)
|
62
67
|
)
|
@@ -81,8 +86,8 @@ module TraceLocation
|
|
81
86
|
end
|
82
87
|
|
83
88
|
def remove_indent(source)
|
84
|
-
indent = source
|
85
|
-
source.
|
89
|
+
indent = source[/\A(\s*)/, 1]
|
90
|
+
source.gsub(/^#{indent}/, '')
|
86
91
|
end
|
87
92
|
end
|
88
93
|
end
|
data/trace_location.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trace_location
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoshiyuki Hirano
|
@@ -9,22 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-06-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: binding_of_caller
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - ">="
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '0'
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '0'
|
28
14
|
- !ruby/object:Gem::Dependency
|
29
15
|
name: method_source
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
134
|
- !ruby/object:Gem::Version
|
149
135
|
version: '0'
|
150
136
|
requirements: []
|
151
|
-
rubygems_version: 3.
|
137
|
+
rubygems_version: 3.1.2
|
152
138
|
signing_key:
|
153
139
|
specification_version: 4
|
154
140
|
summary: helps you get tracing the source location of codes
|