pry-moves 1.0.11 → 1.0.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 +4 -4
- data/Gemfile.lock +2 -8
- data/README.md +9 -1
- data/lib/commands/profile.rb +34 -0
- data/lib/commands/trace_command.rb +3 -0
- data/lib/pry-moves/add_suffix.rb +2 -0
- data/lib/pry-moves/code_reloader.rb +6 -2
- data/lib/pry-moves/commands.rb +7 -3
- data/lib/pry-moves/error_with_data.rb +6 -5
- data/lib/pry-moves/formatter.rb +2 -5
- data/lib/pry-moves/pry_ext.rb +2 -2
- data/lib/pry-moves/pry_wrapper.rb +2 -1
- data/lib/pry-moves/version.rb +1 -1
- data/lib/pry-moves.rb +30 -5
- data/lib/requires.rb +1 -0
- data/lib/sugar/debug_sugar.rb +1 -1
- data/pry-moves.gemspec +1 -1
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54b617db559dc0394f447095883171d67be49bbddd46bffb6d65206efd6a7d4b
|
4
|
+
data.tar.gz: aff84108e38f6be7e651ac0363f83046af91b287856773a8e5944b1d45e218f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97c48fd3a44a337062e934de38faa1bce273f29ef81d6e7d3a957f38318deb1c512bc816ba1d12ab0b2c24893fd3c61453b4cf7b0f718b0bd198ff1e304f55bb
|
7
|
+
data.tar.gz: 2de12cf6e43a8f6e488acec5db74b8745b2b7ef27c6c3b526e6835ea5b89c2f013a1f180202056c401ac147878038d103ea62d81b0fbb3b4a0d3c85486c9db46
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pry-moves (1.0.
|
4
|
+
pry-moves (1.0.12)
|
5
5
|
awesome_print (>= 1.8.0)
|
6
6
|
binding_of_caller (~> 0.7)
|
7
7
|
colorize (~> 0.8)
|
8
8
|
diffy (~> 3.4.0)
|
9
9
|
pry (>= 0.10.4, < 0.13)
|
10
|
-
pry-coolline (~> 0.2.5)
|
11
10
|
|
12
11
|
GEM
|
13
12
|
remote: https://rubygems.org/
|
@@ -17,17 +16,13 @@ GEM
|
|
17
16
|
debug_inspector (>= 0.0.1)
|
18
17
|
coderay (1.1.2)
|
19
18
|
colorize (0.8.1)
|
20
|
-
|
21
|
-
unicode_utils (~> 1.4)
|
22
|
-
debug_inspector (1.1.0)
|
19
|
+
debug_inspector (1.2.0)
|
23
20
|
diff-lcs (1.3)
|
24
21
|
diffy (3.4.2)
|
25
22
|
method_source (0.9.0)
|
26
23
|
pry (0.11.3)
|
27
24
|
coderay (~> 1.1.0)
|
28
25
|
method_source (~> 0.9.0)
|
29
|
-
pry-coolline (0.2.5)
|
30
|
-
coolline (~> 0.5)
|
31
26
|
pry-remote (0.1.8)
|
32
27
|
pry (~> 0.9)
|
33
28
|
slop (~> 3.0)
|
@@ -45,7 +40,6 @@ GEM
|
|
45
40
|
rspec-support (~> 3.8.0)
|
46
41
|
rspec-support (3.8.0)
|
47
42
|
slop (3.6.0)
|
48
|
-
unicode_utils (1.4.0)
|
49
43
|
|
50
44
|
PLATFORMS
|
51
45
|
ruby
|
data/README.md
CHANGED
@@ -38,13 +38,21 @@ Documentation for latest version. For [v0.1.12 see documentation here](https://g
|
|
38
38
|
* `.method` or `123` or `:hash_key` - Continue traversing of last object in history. E.g. `orders` will list array, then `3` will enter `orders[3]`, then `.price` will enter `orders[3].price`
|
39
39
|
* `watch variable` - display variable's value on each step
|
40
40
|
* `diff expression` - display difference between saved expression (on first run) and expression 2
|
41
|
+
* `profile [timeout]` - profile time-consuming code and infinite loops/recursion
|
41
42
|
* `off` - Turn off debugging (don't stop on breakpoints)
|
42
43
|
* `@` - restart and reload scripts (in app/ & spec/ by default), reload rake tasks. Configurable.
|
43
44
|
* `#` - exit with code 3, can be wrapped in bash script to fully reload ruby scripts
|
44
45
|
* `!` - exit
|
45
46
|
|
46
47
|
Variable & methods names takes precedence over commands.
|
47
|
-
So if you have variable named `step`, to execute command `step` type `cmd step` or command's alias, e.g. `s`
|
48
|
+
So if you have variable named `step`, to execute command `step` type `cmd step` or command's alias, e.g. `s`
|
49
|
+
|
50
|
+
Custom commands:
|
51
|
+
```ruby
|
52
|
+
PryMoves.custom_command "say" do |args, output|
|
53
|
+
output.puts "Pry says: #{args}"
|
54
|
+
end
|
55
|
+
```
|
48
56
|
|
49
57
|
## Examples
|
50
58
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class PryMoves::Profile < PryMoves::TraceCommand
|
2
|
+
|
3
|
+
def init(binding_)
|
4
|
+
@start_line = binding_.eval('__LINE__')
|
5
|
+
@profiling_start_at = Time.now
|
6
|
+
@timeout = (@command[:param]&.to_i || 3).seconds
|
7
|
+
end
|
8
|
+
|
9
|
+
def trace(event, file, line, method, binding_)
|
10
|
+
return unless file.start_with? PryMoves.project_root
|
11
|
+
|
12
|
+
if Time.now - @profiling_start_at > @timeout
|
13
|
+
PryMoves.messages << "Profiling timeout: #{@timeout} seconds"
|
14
|
+
return true
|
15
|
+
end
|
16
|
+
|
17
|
+
stop = false
|
18
|
+
place = "#{method} @ #{file}:#{line}"
|
19
|
+
if @last_place != place
|
20
|
+
if @last_start_at
|
21
|
+
took = Time.now - @last_start_at
|
22
|
+
if took > 0.1
|
23
|
+
PryMoves.messages << "#{@last_place} took #{took} seconds"
|
24
|
+
stop = true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
@last_place = place
|
28
|
+
@last_start_at = Time.now
|
29
|
+
end
|
30
|
+
|
31
|
+
stop
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -81,6 +81,9 @@ class TraceCommand
|
|
81
81
|
elsif event == "return" and traced_method?(file, line, method, binding_)
|
82
82
|
@call_depth -= 1
|
83
83
|
end
|
84
|
+
rescue => err
|
85
|
+
puts err.backtrace.reverse
|
86
|
+
puts "PryMoves Tracing error: #{err}".red
|
84
87
|
end
|
85
88
|
|
86
89
|
def traced_method?(file, line, method, binding_)
|
data/lib/pry-moves/add_suffix.rb
CHANGED
@@ -44,8 +44,12 @@ class CodeReloader
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def rails_path_exceptions
|
47
|
-
Rails
|
48
|
-
|
47
|
+
if defined?(Rails)
|
48
|
+
Rails.autoloaders.main.ignore.map do
|
49
|
+
_1.to_s.gsub /^#{Rails.root.to_s}\//, ""
|
50
|
+
end
|
51
|
+
else
|
52
|
+
[]
|
49
53
|
end
|
50
54
|
rescue
|
51
55
|
[]
|
data/lib/pry-moves/commands.rb
CHANGED
@@ -42,7 +42,7 @@ module PryMoves
|
|
42
42
|
alias_command 'g', 'goto'
|
43
43
|
|
44
44
|
block_command 'continue', 'Continue program execution and end the Pry session' do
|
45
|
-
|
45
|
+
_check_file_context
|
46
46
|
run 'exit-all'
|
47
47
|
end
|
48
48
|
alias_command 'c', 'continue'
|
@@ -66,6 +66,10 @@ module PryMoves
|
|
66
66
|
breakout_navigation :debug, cmd
|
67
67
|
end
|
68
68
|
|
69
|
+
block_command 'profile', '' do |param|
|
70
|
+
breakout_navigation :profile, param
|
71
|
+
end
|
72
|
+
|
69
73
|
block_command 'off', '' do
|
70
74
|
PryMoves.switch if PryMoves.stop_on_breakpoints?
|
71
75
|
run 'continue'
|
@@ -103,7 +107,7 @@ module PryMoves
|
|
103
107
|
def breakout_navigation(action, param)
|
104
108
|
return if PryMoves::Vars.var_precedence action, target
|
105
109
|
|
106
|
-
|
110
|
+
_check_file_context
|
107
111
|
_pry_.binding_stack.clear # Clear the binding stack.
|
108
112
|
throw :breakout_nav, { # Break out of the REPL loop and
|
109
113
|
action: action, # signal the tracer.
|
@@ -113,7 +117,7 @@ module PryMoves
|
|
113
117
|
end
|
114
118
|
|
115
119
|
# Ensures that a command is executed in a local file context.
|
116
|
-
def
|
120
|
+
def _check_file_context
|
117
121
|
unless PryMoves.check_file_context(target)
|
118
122
|
raise Pry::CommandError, 'Cannot find local context. Did you use `binding.pry`?'
|
119
123
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
class PryMoves::ErrorWithData < StandardError
|
2
2
|
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :data
|
4
|
+
alias metadata data
|
4
5
|
|
5
|
-
def initialize(msg,
|
6
|
+
def initialize(msg, data)
|
6
7
|
super msg
|
7
|
-
@
|
8
|
+
@data = data
|
8
9
|
end
|
9
|
-
|
10
|
-
end
|
10
|
+
|
11
|
+
end
|
data/lib/pry-moves/formatter.rb
CHANGED
@@ -57,12 +57,9 @@ class PryMoves::Formatter
|
|
57
57
|
str.length > 50 ? "#{str.first 50}..." : str
|
58
58
|
end
|
59
59
|
|
60
|
-
def path_trash
|
61
|
-
@path_trash ||= defined?(Rails) ? Rails.root.to_s : Dir.pwd
|
62
|
-
end
|
63
|
-
|
64
60
|
def shorten_path(path)
|
65
|
-
|
61
|
+
project_root = PryMoves.project_root
|
62
|
+
path = path.gsub( /^#{project_root}\//, '')
|
66
63
|
PryMoves::Backtrace.trim_path ?
|
67
64
|
File.basename(path, ".*") : path
|
68
65
|
end
|
data/lib/pry-moves/pry_ext.rb
CHANGED
@@ -112,7 +112,7 @@ Pry::Command::Whereami.class_eval do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def location
|
115
|
-
|
115
|
+
@file
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -141,4 +141,4 @@ Pry::Output.class_eval do
|
|
141
141
|
pry_moves_origin_for_puts *args
|
142
142
|
end
|
143
143
|
|
144
|
-
end if defined? Pry::Output
|
144
|
+
end if defined? Pry::Output
|
data/lib/pry-moves/version.rb
CHANGED
data/lib/pry-moves.rb
CHANGED
@@ -93,7 +93,7 @@ module PryMoves
|
|
93
93
|
return if at and self.debug_called_times != at
|
94
94
|
return if from and self.debug_called_times < from
|
95
95
|
if message
|
96
|
-
PryMoves.messages << (message
|
96
|
+
PryMoves.messages << format_debug_object(message)
|
97
97
|
end
|
98
98
|
binding.pry options
|
99
99
|
PryMoves.re_execution
|
@@ -127,9 +127,16 @@ module PryMoves
|
|
127
127
|
|
128
128
|
MAX_MESSAGE_CHARS = 520
|
129
129
|
def format_debug_object obj
|
130
|
-
|
131
|
-
|
132
|
-
|
130
|
+
result = case obj
|
131
|
+
when String
|
132
|
+
obj
|
133
|
+
when Hash
|
134
|
+
result = obj.map {"#{_1}:#{_2}"}.join " "
|
135
|
+
result if result.length < 100
|
136
|
+
end
|
137
|
+
result ||= obj.ai rescue "#{obj.class} #{obj}"
|
138
|
+
result.length > MAX_MESSAGE_CHARS ?
|
139
|
+
result[0 .. MAX_MESSAGE_CHARS] + "... (cut)" : result
|
133
140
|
end
|
134
141
|
|
135
142
|
def debug_error(message, debug_object=nil)
|
@@ -159,6 +166,18 @@ module PryMoves
|
|
159
166
|
Pry.commands.block_command command, "", &block
|
160
167
|
end
|
161
168
|
|
169
|
+
def custom_command command, &block
|
170
|
+
cls = Pry::Commands.create_command command, "", :shellwords => false do; end
|
171
|
+
cls.define_method(:process_block) do |args, output|
|
172
|
+
block.call args, output
|
173
|
+
end
|
174
|
+
cls.class_eval do
|
175
|
+
def process
|
176
|
+
process_block args, output
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
162
181
|
def locked?
|
163
182
|
semaphore.locked?
|
164
183
|
end
|
@@ -185,6 +204,8 @@ module PryMoves
|
|
185
204
|
|
186
205
|
def trigger(event, context)
|
187
206
|
triggers[event].each {|t| t.call context}
|
207
|
+
rescue => err
|
208
|
+
puts "PryMoves :#{event} Trigger error: #{err}".red
|
188
209
|
end
|
189
210
|
|
190
211
|
def triggers
|
@@ -193,12 +214,16 @@ module PryMoves
|
|
193
214
|
end
|
194
215
|
end
|
195
216
|
|
196
|
-
TRIGGERS = [:each_new_run, :restart]
|
217
|
+
TRIGGERS = [:each_new_run, :restart, :after_debug]
|
197
218
|
def on(trigger, &block)
|
198
219
|
error "Invalid trigger, possible triggers: #{TRIGGERS}", trigger unless TRIGGERS.include? trigger
|
199
220
|
triggers[trigger] << block
|
200
221
|
end
|
201
222
|
|
223
|
+
def project_root
|
224
|
+
@project_root ||= defined?(Rails) ? Rails.root.to_s : Dir.pwd
|
225
|
+
end
|
226
|
+
|
202
227
|
# Reference to currently running pry-remote server. Used by the tracer.
|
203
228
|
attr_accessor :current_remote_server
|
204
229
|
end
|
data/lib/requires.rb
CHANGED
data/lib/sugar/debug_sugar.rb
CHANGED
@@ -26,7 +26,7 @@ def shit!(err = 'Oh, shit!', debug_object = nil)
|
|
26
26
|
message = "💩 #{err.is_a?(String) ? err : err.message}"
|
27
27
|
raise err unless PryMoves.stop_on_breakpoints?
|
28
28
|
lines = [message.red]
|
29
|
-
lines.prepend debug_object
|
29
|
+
lines.prepend PryMoves.format_debug_object(debug_object) if debug_object
|
30
30
|
PryMoves.debug_error lines.join("\n")
|
31
31
|
nil
|
32
32
|
end
|
data/pry-moves.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
# Dependencies
|
21
21
|
gem.required_ruby_version = '>= 1.8.7', '< 3'
|
22
22
|
gem.add_runtime_dependency 'pry', '>= 0.10.4', '< 0.13'
|
23
|
-
gem.add_runtime_dependency 'pry-coolline', '~> 0.2.5'
|
23
|
+
# gem.add_runtime_dependency 'pry-coolline', '~> 0.2.5'
|
24
24
|
gem.add_runtime_dependency 'binding_of_caller', '~> 0.7'
|
25
25
|
gem.add_runtime_dependency 'colorize', '~> 0.8'
|
26
26
|
gem.add_runtime_dependency 'awesome_print', '>= 1.8.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-moves
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- garmoshka-mo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -30,20 +30,6 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '0.13'
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: pry-coolline
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: 0.2.5
|
40
|
-
type: :runtime
|
41
|
-
prerelease: false
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - "~>"
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.2.5
|
47
33
|
- !ruby/object:Gem::Dependency
|
48
34
|
name: binding_of_caller
|
49
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +122,7 @@ files:
|
|
136
122
|
- lib/commands/iterate.rb
|
137
123
|
- lib/commands/next.rb
|
138
124
|
- lib/commands/next_breakpoint.rb
|
125
|
+
- lib/commands/profile.rb
|
139
126
|
- lib/commands/step.rb
|
140
127
|
- lib/commands/trace_command.rb
|
141
128
|
- lib/commands/trace_helpers.rb
|