nrepl-lazuli 0.4.0 → 0.5.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: 8c38f3cd330d07e579fff5971c656a12c4ee9f9a1488aba33d8183dd80b1236c
4
- data.tar.gz: a63be29edddccc449e4a5bbdd9f80a05e2fb2fa0b3ca0b271ee50830da521118
3
+ metadata.gz: 7e7940230b6c771925c5ee557cecd7a98e043cbe94fed89efe8dee2ce77611c5
4
+ data.tar.gz: e36fda8c9c90cdb098e8e5e8307ce487cb28776d3c0de28e075964fea7acb4ed
5
5
  SHA512:
6
- metadata.gz: 2d75413ea25c513b6107daacd4f4128649c7696fc170f8536d8f636a166ce5fcb9ba675a4c218de9b9ec906f488c7cc9dfbdd48afbce0e828677d08c0bc96283
7
- data.tar.gz: a3bb98a1bc7d9ba46d9bbc0cd1ea3b30dfa186da9444a80acf03015c427430962d4bf3f14dfc0d695b7050fe8caf632b14c1bac0a92edbe65ee9fd0f04a803c5
6
+ metadata.gz: e7a121b406ed724c1c433cd9a854f6082d1628b0557ebc9fb9bbd6f9e6c8a26c2f9c0390708f954ef3154b107d5234d7a332e343911426585c7fb9ec82b35247
7
+ data.tar.gz: e183f6dc2766a16297f27fbf08b7c164b9b43e8c88b753fff43bedb96b1a3ef2b7649187a53703a6d591e18c6c1d3fc7d578f7af9ac4b5b39b87c861b392f490
@@ -3,12 +3,16 @@ module NREPL
3
3
  @@debug_counter = 0
4
4
 
5
5
  def initialize(
6
- input, debug: false, out: input,
6
+ input,
7
+ server:,
8
+ debug: false,
9
+ out: input,
7
10
  binding: nil,
8
11
  bindings: {},
9
12
  bindings_by_id: {}
10
13
  )
11
14
  @debug = debug
15
+ @server = server
12
16
  @in = input
13
17
  @out = out
14
18
  @pending_evals = {}
@@ -135,6 +139,10 @@ module NREPL
135
139
  'rows' => rows_bindings.keys.sort,
136
140
  'op' => msg['op']
137
141
  }))
142
+ when 'set_trace'
143
+ disable = msg['trace'] == 0
144
+ disable ? @server.call_trace.disable : @server.call_trace.enable
145
+ send_msg(response_for(msg, { 'op' => msg['op'], 'status' => ['done'] }))
138
146
  else
139
147
  send_msg(response_for(msg, {
140
148
  'op' => msg['op'],
@@ -10,7 +10,7 @@ require_relative 'fake_stdout'
10
10
 
11
11
  module NREPL
12
12
  class Server
13
- attr_reader :debug, :port, :host
13
+ attr_reader :debug, :port, :host, :call_trace
14
14
  alias debug? debug
15
15
 
16
16
  def self.spawn(args = {})
@@ -35,7 +35,8 @@ module NREPL
35
35
  debug: false,
36
36
  binding: nil,
37
37
  pwd: Dir.pwd,
38
- tracing: true
38
+ tracing: true,
39
+ loader: nil
39
40
  )
40
41
  @port = port
41
42
  @pwd = pwd
@@ -56,6 +57,7 @@ module NREPL
56
57
  }
57
58
  }
58
59
  @tracing = tracing
60
+ @loader = loader
59
61
  Thread.current[:nrepl_server] = self
60
62
  NREPL.class_variable_set(:@@connections, @connections)
61
63
  NREPL.class_variable_set(:@@bindings, @bindings)
@@ -76,7 +78,7 @@ module NREPL
76
78
  @old_out, @old_err = $stdout, $stderr
77
79
  $stdout = FakeStdout.new(@connections, STDOUT, "out")
78
80
  $stderr = FakeStdout.new(@connections, STDERR, "err")
79
- auto_create_bindings! if @tracing
81
+ auto_create_bindings!
80
82
 
81
83
  Signal.trap("INT") { stop }
82
84
  Signal.trap("TERM") { stop }
@@ -87,7 +89,8 @@ module NREPL
87
89
  Thread.start(@socket.accept) do |client|
88
90
  connection = Connection.new(
89
91
  client,
90
- debug: debug?,
92
+ server: self,
93
+ debug: @debug,
91
94
  binding: @binding,
92
95
  bindings_by_id: @bindings_by_id,
93
96
  bindings: @bindings
@@ -105,7 +108,7 @@ module NREPL
105
108
 
106
109
  def auto_create_bindings!
107
110
  dir_regex = Regexp.new("^#{Regexp.escape(@pwd)}")
108
- @call_trace = TracePoint.new(:class, :call) do |tp|
111
+ trace_proc = proc do |tp|
109
112
  path = tp.path
110
113
  next if tp.path =~ /^(\<|.eval)/
111
114
  path = File.join(@pwd, path) if File.dirname(path) == '.'
@@ -115,6 +118,13 @@ module NREPL
115
118
  @bindings[path] ||= {}
116
119
  @bindings[path][tp.lineno-1] ||= {}
117
120
  @bindings[path][tp.lineno-1][id] = b
121
+ path
122
+ end
123
+ @class_trace = TracePoint.new(:class, &trace_proc)
124
+ @class_trace.enable
125
+
126
+ @call_trace = TracePoint.new(:call) do |tp|
127
+ path = trace_proc.call(tp)
118
128
  if path =~ dir_regex
119
129
  @connections.each do |connection|
120
130
  connection.send_msg(
@@ -126,7 +136,23 @@ module NREPL
126
136
  end
127
137
  end
128
138
  end
129
- @call_trace.enable
139
+ @call_trace.enable if @tracing
140
+
141
+ if @loader
142
+ need_to_pause = true
143
+ original_trace = nil
144
+ @loader.on_load do
145
+ next unless need_to_pause
146
+ need_to_pause = false
147
+ original_trace = call_trace.enabled?
148
+ @call_trace.disable
149
+ Thread.new do
150
+ sleep 5
151
+ @call_trace.enable if original_trace
152
+ need_to_pause = true
153
+ end
154
+ end
155
+ end
130
156
 
131
157
  @ex_trace = TracePoint.new(:raise) do |tp|
132
158
  e = tp.raised_exception
data/lib/nrepl-lazuli.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require 'set'
2
3
 
3
4
  module NREPL
4
5
  VERSION = '0.1.0'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nrepl-lazuli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maurício Szabo
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-11-13 00:00:00.000000000 Z
10
+ date: 2025-04-04 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: A Ruby nREPL server, made to be used with Lazuli plug-in (but can be
14
13
  used with any nREPL client too)
@@ -26,7 +25,6 @@ licenses:
26
25
  - MIT
27
26
  metadata:
28
27
  source_code_uri: https://gitlab.com/clj-editors/nrepl-lazuli
29
- post_install_message:
30
28
  rdoc_options: []
31
29
  require_paths:
32
30
  - lib
@@ -41,8 +39,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
39
  - !ruby/object:Gem::Version
42
40
  version: '0'
43
41
  requirements: []
44
- rubygems_version: 3.5.11
45
- signing_key:
42
+ rubygems_version: 3.6.2
46
43
  specification_version: 4
47
44
  summary: A Ruby nREPL server
48
45
  test_files: []