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 +4 -4
- data/lib/nrepl-lazuli/connection.rb +9 -1
- data/lib/nrepl-lazuli/server.rb +32 -6
- data/lib/nrepl-lazuli.rb +1 -0
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e7940230b6c771925c5ee557cecd7a98e043cbe94fed89efe8dee2ce77611c5
|
4
|
+
data.tar.gz: e36fda8c9c90cdb098e8e5e8307ce487cb28776d3c0de28e075964fea7acb4ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
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'],
|
data/lib/nrepl-lazuli/server.rb
CHANGED
@@ -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!
|
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
|
-
|
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
|
-
|
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
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
|
+
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:
|
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.
|
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: []
|