nrepl-lazuli 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: e198f7aeaa4e73c02bb95aab3cc78233e64730eb9da1c7a7a3b81100dc2063b1
4
- data.tar.gz: f5bb2f932d3520450821ec746527c52c9a2aeb7bf2946cf37f7aa98d1b92f10e
3
+ metadata.gz: fb08e5429998d1320a2f3b4db07b336c389af0e3a1f008c67dbb4236af27af4a
4
+ data.tar.gz: 9eb7a44c8d716860eeb09f18025dd5dd47713554384e9be249683b1ec7b11bf9
5
5
  SHA512:
6
- metadata.gz: 8b4b0f03d9673e708b6aabad549544d812bd3d06e63748507e39595e748a02c5a2344ac5f1d6819cb501b462b667756c3225da6a6a1254b72488f0e1115f20ea
7
- data.tar.gz: 074bfe1128eac938c707fc33f2add4e388ab762ab0ecbd3113300829ffee2f67fe60f2246bf590953734065c68a40e8e398bd3a77b8104f7a81ce64a3f8bdf0a
6
+ metadata.gz: f3aec4c5b770994bb11be7f6fdfcbbaa4c0a1050e4964c0a10cd0cf4b95c6014ce0dd40cc765cad1815b93f429bb0c2a3a66a70aa03f730392d03bad0c71e29c
7
+ data.tar.gz: 33d341eddae865f76f8463353b2232aaec4edd480f12301856bf618223f8f23fe7b237397e5d39135e3d745e9c57cbf22c6e658b61f9fa68c9756ccc81c65c35
@@ -4,8 +4,9 @@ module NREPL
4
4
 
5
5
  def initialize(
6
6
  input, debug: false, out: input,
7
- watches: NREPL.class_variable_get(:@@watches), binding: nil,
8
- auto_bindings: {}
7
+ watches: NREPL.class_variable_get(:@@bindings),
8
+ binding: nil,
9
+ bindings: {}
9
10
  )
10
11
  @debug = debug
11
12
  @in = input
@@ -14,7 +15,7 @@ module NREPL
14
15
  @watches = watches
15
16
  @counter = 0
16
17
  @binding = binding
17
- @auto_bindings = auto_bindings
18
+ @bindings = bindings
18
19
  end
19
20
 
20
21
  def treat_messages!
@@ -84,7 +85,7 @@ module NREPL
84
85
  when 'watches_for_file'
85
86
  msg['id'] ||= "eval_#{@counter += 1}"
86
87
  file = msg['file']
87
- rows_bindings = @auto_bindings[file] || {}
88
+ rows_bindings = @bindings[file] || {}
88
89
  send_msg(response_for(msg, {
89
90
  'status' => ['done'],
90
91
  'rows' => rows_bindings.keys.sort,
@@ -109,6 +110,7 @@ module NREPL
109
110
  begin
110
111
  eval_msg(msg, stop)
111
112
  rescue Exception => e
113
+ puts e.backtrace
112
114
  send_exception(msg, e)
113
115
  ensure
114
116
  @pending_evals.delete(id) unless stop
@@ -165,10 +167,10 @@ module NREPL
165
167
  row = msg['line']
166
168
  return if !file || !row
167
169
 
168
- rows_bindings = @auto_bindings[file]
170
+ rows_bindings = @bindings[file]
169
171
  return unless rows_bindings
170
172
  found_row = row.downto(-1).find { |k| rows_bindings[k] }
171
- rows_bindings[found_row]
173
+ rows_bindings[found_row][:binding] if found_row
172
174
  end
173
175
 
174
176
  private def define_stop_function!(msg, method_name)
@@ -24,7 +24,8 @@ module NREPL
24
24
  nil
25
25
  end
26
26
 
27
- def write(text='')
27
+ def write(*texts)
28
+ text = texts.join('')
28
29
  @connections.each do |conn|
29
30
  conn.send_msg(
30
31
  @kind => text
@@ -28,8 +28,9 @@ module NREPL
28
28
  @debug = debug
29
29
  @connections = Set.new
30
30
  @binding = binding
31
- @auto_bindings = {}
31
+ @bindings = {}
32
32
  NREPL.class_variable_set(:@@connections, @connections)
33
+ NREPL.class_variable_set(:@@bindings, @bindings)
33
34
  end
34
35
 
35
36
  private def record_port
@@ -53,7 +54,7 @@ module NREPL
53
54
  s = TCPServer.new(host, port)
54
55
  loop do
55
56
  Thread.start(s.accept) do |client|
56
- connection = Connection.new(client, debug: debug?, binding: @binding, auto_bindings: @auto_bindings)
57
+ connection = Connection.new(client, debug: debug?, binding: @binding, bindings: @bindings)
57
58
  @connections << connection
58
59
  connection.treat_messages!
59
60
  @connections.delete(connection)
@@ -66,10 +67,9 @@ module NREPL
66
67
  def auto_create_bindings!
67
68
  dir_regex = Regexp.new("^#{Regexp.escape(@pwd)}")
68
69
  @call_trace = TracePoint.new(:call) do |tp|
69
- @auto_bindings[tp.path] ||= {}
70
- @auto_bindings[tp.path][tp.lineno-1] = tp.binding
70
+ @bindings[tp.path] ||= {}
71
+ @bindings[tp.path][tp.lineno-1] = {binding: tp.binding, id: "#{tp.path}:#{tp.lineno}"}
71
72
  if tp.path =~ dir_regex
72
- # puts "Tracing #{tp.path}:#{tp.lineno}"
73
73
  @connections.each do |connection|
74
74
  connection.send_msg(
75
75
  'op' => 'hit_auto_watch',
@@ -81,6 +81,12 @@ module NREPL
81
81
  end
82
82
  end
83
83
  @call_trace.enable
84
+
85
+ # @ex_trace = TracePoint.new(:raise) do |tp|
86
+ # $foo = [tp.lineno, tp.event, tp.raised_exception, tp.binding, caller_locations]
87
+ # # p $foo
88
+ # end
89
+ # @ex_trace.enable
84
90
  end
85
91
 
86
92
  def stop
data/lib/nrepl-lazuli.rb CHANGED
@@ -7,15 +7,18 @@ module NREPL
7
7
  PORT_FILENAME = '.nrepl-port'
8
8
 
9
9
  require_relative 'nrepl-lazuli/server'
10
- @@watches = {}
10
+ @@bindings = {}
11
11
  @@connections = Set.new
12
12
 
13
13
  def self.watch!(binding, id=nil)
14
- (file, row) = caller[0].split(/:/)
14
+ loc = caller_locations[0]
15
+ file = loc.absolute_path
16
+ row = loc.lineno
15
17
  id ||= "#{file}:#{row}"
16
- row = row.to_i
17
18
 
18
- @@watches[id] = {binding: binding}
19
+ @@bindings[file] ||= {}
20
+ @@bindings[file][loc.lineno-1] = {id: id, binding: binding}
21
+
19
22
  @@connections.each do |connection|
20
23
  connection.send_msg(
21
24
  'op' => 'hit_watch',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nrepl-lazuli
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
  - Maurício Szabo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-20 00:00:00.000000000 Z
11
+ date: 2024-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bencode