tracia 0.2.5 → 0.2.6

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: 1749c13c95b1ecd54e9b6e812bea86021d95960e1d6b07f093a748fc594bc440
4
- data.tar.gz: c4bec7a75c6c67e8fc683c475444b902e18bac414730d80a142f8448b1cbe3da
3
+ metadata.gz: 7e8c70f863ced4e60aeeb7d6dc343f568a88df17cb67d039adc7c921fa8149a8
4
+ data.tar.gz: f60c5dc69ccfe8318d5ba951dfbe546e013c87eb0d3641345aaffe96d416d524
5
5
  SHA512:
6
- metadata.gz: 7b05410f5cc503504f15daf3fd4dbc833c47677be0032eb9355dd7cd7f4af6ae1d24a292d587afb128ddd6952b17fc2c3012c1adb5ce65efbdd326d911aaa67d
7
- data.tar.gz: 4a8492aed4a2e71165e7c7e2bf11ecda59d93cac7fb174175364d6969cfd09add1aa98bcbc6619b78a5fcfac984fb82167081f4df50e2f2b0e8df53157e31b0b
6
+ metadata.gz: 998c2b5b36a92167c085ca15a0898002c06c5419f9e484342f7b7aa0607bdb8fbdd63c08af26eb219c77d3021828e2bc9a4776cd2d893798d7e0a4d8bb5fd803
7
+ data.tar.gz: 86aa94fb518e44b9498562212c3ad91dbafaadd08af53eb3580b4ae8d07452b5274369d5d99e7b87c93ab38fc9468d17a3e0280f3dca9e5622908ccd227b3978
data/README.md CHANGED
@@ -45,9 +45,9 @@ end
45
45
  By default, Tracia writes result to STDOUT, you can set it somewhere else
46
46
 
47
47
  ```ruby
48
- file = File.new('/path/to/log.txt', 'w+')
48
+ file = File.new('/path/to/log.html', 'w+')
49
49
 
50
- Tracia.start(logger: Tracia::DefaultLogger.new(out: file)) do
50
+ Tracia.start(logger: Tracia::DefaultLogger.new(out: file, html: true)) do
51
51
  # ...
52
52
  end
53
53
  ```
data/lib/tracia/frame.rb CHANGED
@@ -50,7 +50,16 @@ class Tracia
50
50
  "#{klass}#{call_sym}#{method_name}"
51
51
  end
52
52
 
53
+ INSTANCE_METHOD_SHARP = '#'
54
+
53
55
  def source_location
56
+ if @file == nil
57
+ meth = call_sym == INSTANCE_METHOD_SHARP ? klass.instance_method(method_name) : klass.method(method_name)
58
+ src_loc = meth.source_location
59
+ @file = src_loc[0]
60
+ @lineno = src_loc[1]
61
+ end
62
+
54
63
  "#{GemPaths.shorten(@file)}:#{@lineno}"
55
64
  end
56
65
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Tracia
4
- VERSION = "0.2.5"
4
+ VERSION = "0.2.6"
5
5
  end
data/lib/tracia.rb CHANGED
@@ -10,8 +10,6 @@ require "binding_of_callers"
10
10
  class Tracia
11
11
  class Error < StandardError; end
12
12
 
13
- INSTANCE_METHOD_SHARP = '#'
14
-
15
13
  attr_accessor :level, :error, :depth
16
14
 
17
15
  class << self
@@ -32,13 +30,14 @@ class Tracia
32
30
  trc.log if trc.level == 0
33
31
  end
34
32
 
35
- def add(info)
33
+ def add(info = nil, &block)
36
34
  trc = Thread.current[:_tracia_]
37
35
  return unless trc
38
36
 
39
37
  backtrace = binding.partial_callers(-trc.depth)
40
38
  backtrace.reverse!
41
39
  backtrace.pop
40
+ info = block.call if block
42
41
  trc.add(backtrace, info)
43
42
  end
44
43
  end
@@ -141,6 +140,8 @@ class Tracia
141
140
  @frames_to_reject.any?{ |rj| rj =~ raw_frame.file }
142
141
  end
143
142
 
143
+ EMPTY_SRC_LOC = []
144
+
144
145
  def convert_to_frames(callers)
145
146
  callers.map! do |c|
146
147
  _binding = c._binding
@@ -150,8 +151,9 @@ class Tracia
150
151
 
151
152
  source_location =
152
153
  if _binding.frame_type == :method
153
- meth = call_symbol == INSTANCE_METHOD_SHARP ? klass.instance_method(frame_env) : klass.method(frame_env)
154
- meth.source_location
154
+ # meth = call_symbol == INSTANCE_METHOD_SHARP ? klass.instance_method(frame_env) : klass.method(frame_env)
155
+ # meth.source_location
156
+ EMPTY_SRC_LOC
155
157
  else
156
158
  _binding.source_location
157
159
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-21 00:00:00.000000000 Z
11
+ date: 2022-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.2.3
69
- description:
69
+ description:
70
70
  email:
71
71
  - block24block@gmail.com
72
72
  executables: []
@@ -88,7 +88,7 @@ homepage: https://github.com/turnon/tracia
88
88
  licenses:
89
89
  - MIT
90
90
  metadata: {}
91
- post_install_message:
91
+ post_install_message:
92
92
  rdoc_options: []
93
93
  require_paths:
94
94
  - lib
@@ -103,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubygems_version: 3.1.6
107
- signing_key:
106
+ rubygems_version: 3.3.7
107
+ signing_key:
108
108
  specification_version: 4
109
109
  summary: bottum-up tracing
110
110
  test_files: []