trace_location 0.10.0 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1e2f74ef8aefad64a0a962c2a77dbd4a47d8992ca5ef027d0acf47da19e7c2a
4
- data.tar.gz: ad9b606d32f96289cb629f0c58f7324e9d9704e084f61fc9bbf2d689836eabee
3
+ metadata.gz: 010e65cd3a2447cb0816fd31bb62eec1acb6546a0cc2d8667df523027d24abd4
4
+ data.tar.gz: 9bce85eda13a6836c0195d05265dcaf9794d4f2356d6a0b5ad5cf25d915db5b9
5
5
  SHA512:
6
- metadata.gz: 9835516aba4ce712bd1ef3311947e315e052de1c6cd102967d06d740db127c459754339b92221b7a2904046a8fdfe8391e105ff8001af915b9cd67eef79da1b2
7
- data.tar.gz: 24d753f05e76317957adf43a6ab02024558af46f623a4ac548f22130b6bc7d450d238fca16d303986d3d70791b3f112919808f5de750a520c01978880826fe08
6
+ metadata.gz: 274ae1e802b7eb65e81cabd20fc66bd7b8ba2c7427e6eb2e5e6dee0a9415350a26cad2827f670151b9e94329b4702bca8086432b94179c20b15e48fca3a5265e
7
+ data.tar.gz: 367ae84388dd7a5b331ed780b99e6539a9f895aa5be06acdde803501a1bef8f24c155b7334031d4dc6314272332511773dfe4139ac825c63c53df5dc346c6c91
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trace_location (0.10.0)
4
+ trace_location (0.11.0)
5
5
  method_source
6
6
 
7
7
  GEM
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'trace_location'
4
+ require 'trace_location/cli'
5
+
6
+ TraceLocation::CLI.new(ARGV).run
@@ -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
@@ -26,7 +26,7 @@ module TraceLocation
26
26
  location_cache_key = "#{caller_path}:#{caller_lineno}"
27
27
 
28
28
  mes = extract_method_from(trace_point)
29
- next if mes.source_location[0] == '<internal:prelude>'
29
+ next if mes.source_location[0].match?(/\A(?:<internal:.+>|\(eval\))\z/)
30
30
 
31
31
  method_source = method_source_cache[mes] ||= remove_indent(mes.source)
32
32
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TraceLocation
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.0'
5
5
  end
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.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoshiyuki Hirano
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-06-20 00:00:00.000000000 Z
12
+ date: 2020-08-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