trace_location 0.9.6 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b99f37cfbaa87f60634dcecdc9d318da8a650ceaa49e8250fb1a2f845ba41143
4
- data.tar.gz: 359e39f882d890826b351bbc55137d97b035d3e60df84944743ebd2bfc6472b1
3
+ metadata.gz: b1e2f74ef8aefad64a0a962c2a77dbd4a47d8992ca5ef027d0acf47da19e7c2a
4
+ data.tar.gz: ad9b606d32f96289cb629f0c58f7324e9d9704e084f61fc9bbf2d689836eabee
5
5
  SHA512:
6
- metadata.gz: 60a6a07c494abe8c796880792ba05616551f884e89f8a1ebb0199d9fc4c03751b26d2a68e67e9f931433914dc571bfee44ca65ba63b0b48dc72b8545531e77a3
7
- data.tar.gz: 1db632d2595a66baf34facbe56ca976e530a385d37646f847176bfbd146164682c76859ff4140ea17f7b5b55bd07ddc581abda866a5636c2a1c43c2bf89b8a22
6
+ metadata.gz: 9835516aba4ce712bd1ef3311947e315e052de1c6cd102967d06d740db127c459754339b92221b7a2904046a8fdfe8391e105ff8001af915b9cd67eef79da1b2
7
+ data.tar.gz: 24d753f05e76317957adf43a6ab02024558af46f623a4ac548f22130b6bc7d450d238fca16d303986d3d70791b3f112919808f5de750a520c01978880826fe08
@@ -3,5 +3,11 @@ sudo: false
3
3
  language: ruby
4
4
  cache: bundler
5
5
  rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 2.0.1
6
+ - 2.6.6
7
+ - 2.7.1
8
+ - ruby-head
9
+ before_install: gem install bundler -v 2.1.4
10
+
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: ruby-head
@@ -1,25 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trace_location (0.9.6)
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.9.2)
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 (12.3.2)
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.0.1
53
+ 2.1.4
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # TraceLocation
2
2
 
3
+ [![Build Status](https://travis-ci.org/yhirano55/trace_location.svg?branch=master)](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
@@ -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
- $stdout.puts "Failure: #{e.message}"
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
- caller_path, caller_lineno = trace_point.binding.of_caller(2).source_location
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: remove_indent(mes.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: remove_indent(mes.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.split("\n").first.match(/\A(\s+).+\z/)[1]
85
- source.split("\n").map { |line| line.gsub(/\A#{indent}/, '') }.join("\n")
89
+ indent = source[/\A(\s*)/, 1]
90
+ source.gsub(/^#{indent}/, '')
86
91
  end
87
92
  end
88
93
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TraceLocation
4
- VERSION = '0.9.6'
4
+ VERSION = '0.10.0'
5
5
  end
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.require_paths = ['lib']
24
24
  s.required_ruby_version = '>= 2.6.0'
25
25
 
26
- s.add_dependency 'binding_of_caller'
27
26
  s.add_dependency 'method_source'
28
27
 
29
28
  s.add_development_dependency 'bundler'
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.9.6
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: 2019-08-01 00:00:00.000000000 Z
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.0.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