dev_suite 0.2.12 → 0.2.13

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: 89babbbfc8efcac3d35e1f60db7c5c880183eb7b77f5d43cd0a9380081815795
4
- data.tar.gz: 34000a8d5129edf959325eaf30244333484128f399a72cc07e91329597a719fe
3
+ metadata.gz: 6c4f76e1bde363b53c6e0e76616ce4589f37e17af746b6e1d77019aa0d2c58d9
4
+ data.tar.gz: b93fd9c938777e4c5c366b34b761b38d5e3bfb38231b345b125f41f5655576ab
5
5
  SHA512:
6
- metadata.gz: 9aef9871a87ca4f4c076ad72191a179dc894acf9667b5ef1f1ca52389ce0c08dda75477d5f59fc611bbe2b0c6c26ef19df8a9ec0f4bfe1b025d83809390d6c1c
7
- data.tar.gz: 0f99342d6399fde0bd6c7f3104bbcd490b64ae67f450d706f4518057c2534110660e420a24f2d38b5481a17757a97092e79f9d6bca450ea0b88273eeae959dda
6
+ metadata.gz: a8c153fb7c5fa8f73a03e1ae33cc8fbc71b825150c557dad9d0f2bc9e2a1b3e8054b7d334b02bfe51cb4e72c10d13732bbb0247be3c5235ece0c639338aa370e
7
+ data.tar.gz: f42462a700acc328deca1071c7a9cccd63c93eba44928c3510707afe4173b7ea6c478328103d47abfe30ce86d2e7430d120ecc5c3a46fa95f3e9355d5b27c377
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dev_suite (0.2.12)
4
+ dev_suite (0.2.13)
5
5
  benchmark (~> 0.1)
6
6
  csv (~> 3.0)
7
7
  get_process_mem (~> 1.0)
@@ -5,8 +5,6 @@ module DevSuite
5
5
  module Logger
6
6
  class << self
7
7
  def log_method_call(tp, tracer)
8
- tracer.depth += 1
9
-
10
8
  # Store the start time for execution time calculation
11
9
  tracer.start_times[tp.method_id] = Time.now
12
10
 
@@ -19,9 +17,6 @@ module DevSuite
19
17
 
20
18
  message = build_return_message(tp, tracer, duration)
21
19
  Utils::Logger.log(message, emoji: :finish, color: :cyan)
22
-
23
- # Decrement depth safely
24
- tracer.depth = [tracer.depth - 1, 0].max
25
20
  end
26
21
 
27
22
  private
@@ -34,8 +29,8 @@ module DevSuite
34
29
  def build_call_message(tp, tracer)
35
30
  method_name = colorize_text(Helpers.format_method_name(tp), :blue)
36
31
  params_str = tracer.show_params ? colorize_text(Helpers.format_params(tp), :yellow) : ""
37
- indent = Helpers.calculate_indent(tracer.depth)
38
- depth_str = colorize_text("#depth:#{tracer.depth}", :magenta)
32
+ indent = Helpers.calculate_indent(tracer.current_depth)
33
+ depth_str = colorize_text("#depth:#{tracer.current_depth}", :magenta)
39
34
 
40
35
  "#{indent}#{depth_str} > #{method_name} at #{tp.path}:#{tp.lineno} #{params_str}"
41
36
  end
@@ -57,8 +52,8 @@ module DevSuite
57
52
  else
58
53
  ""
59
54
  end
60
- indent = Helpers.calculate_indent(tracer.depth)
61
- depth_str = colorize_text("#depth:#{tracer.depth}", :magenta)
55
+ indent = Helpers.calculate_indent(tracer.current_depth)
56
+ depth_str = colorize_text("#depth:#{tracer.current_depth}", :magenta)
62
57
 
63
58
  "#{indent}#{depth_str} < #{method_name}#{result_str} at #{tp.path}:#{tp.lineno}#{exec_time_str}"
64
59
  end
@@ -4,7 +4,7 @@ module DevSuite
4
4
  module MethodTracer
5
5
  class Tracer
6
6
  attr_reader :show_params, :show_results, :show_execution_time, :max_depth
7
- attr_accessor :depth, :trace_point, :start_times
7
+ attr_accessor :current_depth, :trace_point, :start_times
8
8
 
9
9
  def initialize(
10
10
  show_params: false,
@@ -16,8 +16,8 @@ module DevSuite
16
16
  @show_results = show_results
17
17
  @show_execution_time = show_execution_time
18
18
  @max_depth = max_depth
19
- @depth = 0
20
19
  @start_times = {}
20
+ @current_depth = 0
21
21
  end
22
22
 
23
23
  def trace(&block)
@@ -50,15 +50,23 @@ module DevSuite
50
50
  end
51
51
 
52
52
  def handle_call_event(tp)
53
- Logger.log_method_call(tp, self) if depth_within_limit?
53
+ @current_depth += 1
54
+
55
+ if current_depth_within_limit?
56
+ Logger.log_method_call(tp, self)
57
+ end
54
58
  end
55
59
 
56
60
  def handle_return_event(tp)
57
- Logger.log_method_return(tp, self) if depth_within_limit?
61
+ if current_depth_within_limit?
62
+ Logger.log_method_return(tp, self)
63
+ end
64
+
65
+ @current_depth -= 1
58
66
  end
59
67
 
60
- def depth_within_limit?
61
- max_depth.nil? || @depth < max_depth
68
+ def current_depth_within_limit?
69
+ max_depth.nil? || current_depth <= max_depth
62
70
  end
63
71
  end
64
72
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DevSuite
4
- VERSION = "0.2.12"
4
+ VERSION = "0.2.13"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev_suite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huy Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-05 00:00:00.000000000 Z
11
+ date: 2024-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark