pryx 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -15
- data/lib/pry-disasm/commands.rb +1 -1
- data/lib/pry-disasm.rb +8 -1
- data/lib/pryx/common_plugins.rb +9 -0
- data/lib/pryx/irb_hack.rb +14 -5
- data/lib/pryx/looksee_hack.rb +3 -3
- data/lib/pryx/pry-stack_explorer_hack.rb +12 -0
- data/lib/pryx/pry_hack.rb +12 -13
- data/lib/pryx/pry_plugins.rb +7 -3
- data/lib/pryx/version.rb +1 -1
- data/lib/pryx.rb +1 -1
- data/lib/pryx_irb.rb +1 -6
- metadata +51 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce341aed30736e74c9555f58904c279e3df2c8e9b34927b5a3ea0a203d56f48a
|
4
|
+
data.tar.gz: b910b99fd34921918bac6baccf2153518f0ca9c46d00245e4af507f80121df1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39b07122fe28eb18ef6b69ce6719fa59a75eb0d5aad2d6407de9684298dd9b80396a3d547294d043e8566043168ee4f14d61c22674d94efb1443f4ec9325e9a8
|
7
|
+
data.tar.gz: 335180f0b216cc9997118bf6e692b5bfb95f8a70d5cc5b1c28049f3955d96dd2696072e516a06fd963e8bb35b4fae4a006879adcf2903b929f193733ee94e791
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Pryx [![Build Status](https://travis-ci.com/zw963/pryx.svg?branch=master)](https://travis-ci.com/zw963/pryx)
|
1
|
+
# Pryx [![Build Status](https://travis-ci.com/zw963/pryx.svg?branch=master)](https://app.travis-ci.com/github/zw963/pryx)[![Gem Version](https://badge.fury.io/rb/pryx.svg)](http://badge.fury.io/rb/pryx)![](https://ruby-gem-downloads-badge.herokuapp.com/pryx?type=total)
|
2
2
|
|
3
3
|
Three Virtues of a Programmer: Laziness, Impatience, and Hubris. -- Larry Wall, the author of Perl Programming language.
|
4
4
|
|
@@ -55,6 +55,18 @@ use http connection.
|
|
55
55
|
Until now, you've only seen the tip of the iceberg, please have a try.
|
56
56
|
|
57
57
|
|
58
|
+
If you prefer to use IRB over Pry, use can add following code instead.
|
59
|
+
|
60
|
+
```sh
|
61
|
+
$: export RUBYOPT+=' -rpryx_irb'
|
62
|
+
$: ruby your_file.rb # add pry! in your_file for start pry session
|
63
|
+
```
|
64
|
+
|
65
|
+
__WARN__: `require 'pryx_irb'` will enable many gems by default in your's ruby code.
|
66
|
+
so, prefer to use `require 'pryx'`, because latter almost not affect your's code,
|
67
|
+
only several methods added into Kernel#, and gems only be require if you run invoke
|
68
|
+
those added methods.
|
69
|
+
|
58
70
|
## useful command which added directly to Kernel#
|
59
71
|
|
60
72
|
### Kernel#pry!
|
@@ -70,22 +82,26 @@ $: RUBYOPT+='-rpryx_irb' ruby your_file.rb # add irb! in your_file for start pry
|
|
70
82
|
|
71
83
|
Following feature both available when start a Pry or IRB session:
|
72
84
|
|
73
|
-
1.
|
74
|
-
2.
|
75
|
-
3. Use
|
85
|
+
1. Add `next/step/up/down` command for debug, use [break](https://github.com/gsamokovarov/break) [pry-stack_explorer](https://github.com/pry/pry-stack_explorer)
|
86
|
+
2. Add `Kernel#ls1`(use ls1 to avoid conflict with pry builtin ls command), see [looksee](https://github.com/oggy/looksee)
|
87
|
+
3. Use `ap` for pretty print. see [awesome-print](https://github.com/awesome-print/awesome_print)
|
88
|
+
4. Use `Clipboard.copy` or `Clipboard.paste` to interactive with system clipboard. see [clipboard](https://github.com/janlelis/clipboard)
|
76
89
|
|
77
|
-
Following
|
90
|
+
Following is pry command available only after start a Pry session:
|
78
91
|
|
79
|
-
1.
|
92
|
+
1. Add `$/?` command for see source, see [pry-doc](https://github.com/pry/pry-doc)
|
80
93
|
2. pry-remote debug support. you still use `pry!` no changes, it will use `pry-remote` automatically
|
81
94
|
if current ruby process was running on backround, then, it will use pry-remote, and listen on 0.0.0.0:9876,
|
82
95
|
Then, you can connect to it from another terminal! see [pry-remote](https://github.com/Mon-Ouie/pry-remote)
|
83
|
-
3.
|
84
|
-
4.
|
85
|
-
5.
|
86
|
-
6.
|
87
|
-
|
88
|
-
|
96
|
+
3. Add `pa` command, see [pry-power_assert](https://github.com/yui-knk/pry-power_assert)
|
97
|
+
4. Add `hier` command for print the class hierarchies, see [pry-hier](https://github.com/phaul/pry-hier)
|
98
|
+
5. Add `pry-aa_ancestors` command for print the class hierarchy, see [pry-aa_ancestors](https://github.com/tbpgr/pry-aa_ancestors)
|
99
|
+
6. Add `up/down/frame/stack` command, see [pry-stack_explorer](https://github.com/pry/pry-stack_explorer)
|
100
|
+
7. Add `yes` or `y` command, see [pry-yes](https://github.com/christofferh/pry-yes)
|
101
|
+
8. Add `pry-disam`, Check following screenshot for a example:
|
102
|
+
|
103
|
+
![pry-disasm](images/disasm.png)
|
104
|
+
|
89
105
|
### Kernel#pry1 Kernel#pry2 (sorry for this bad name, please create a issue you have a better one)
|
90
106
|
|
91
107
|
pry2 do nothing, but it will be interceptd and start a pry session only after pry1 is running.
|
@@ -106,7 +122,10 @@ but above plugins and libraries all correct configured.
|
|
106
122
|
|
107
123
|
we have another Kernel#pry?, which enable `pry-state` automatically, see [pry-state](https://github.com/SudhagarS/pry-state)
|
108
124
|
|
109
|
-
###
|
125
|
+
### Add command from command line, rescue, kill-pry-rescue, pryx, irbx, pry!
|
126
|
+
|
127
|
+
`rescue` and `kill-pry-rescue` come from `pry-rescue` gem, it not load by default, but you can use rescue command from command line directly.
|
128
|
+
see [pry-rescue](https://github.com/ConradIrwin/pry-rescue)
|
110
129
|
|
111
130
|
pryx is same as pry, but, with plugins and libraries correct configured.
|
112
131
|
|
@@ -124,8 +143,17 @@ $: pry! -s 192.168.1.100 -p 9876
|
|
124
143
|
|
125
144
|
## Philosophy
|
126
145
|
|
127
|
-
This gem is design to
|
128
|
-
|
146
|
+
This gem is design to Minimal impact on target ruby code, in fact, after `require 'pryx'` or `RUBYOPT='-rpryx'`
|
147
|
+
(they do same thing), only several instance method be defined on Kernel, and several gems add to $LOAD_PATH,
|
148
|
+
but not load, ready to require it, no more. so, it should be safe to use it, either affect performance nor
|
149
|
+
namespace/variables etc.
|
150
|
+
|
151
|
+
But, you should only use it in development, though, it was tested is run in container(alpine) too.
|
152
|
+
|
153
|
+
## Limit
|
154
|
+
|
155
|
+
1. `break` not work well if you add more than one break point, but still use `next` goto the next break point,
|
156
|
+
See https://github.com/gsamokovarov/break/issues/12
|
129
157
|
|
130
158
|
## Support
|
131
159
|
|
data/lib/pry-disasm/commands.rb
CHANGED
data/lib/pry-disasm.rb
CHANGED
@@ -3,7 +3,14 @@ require 'pry-disasm/commands'
|
|
3
3
|
|
4
4
|
class PryDisasm
|
5
5
|
def self.process(expr)
|
6
|
-
|
6
|
+
case expr
|
7
|
+
when Method, Proc
|
8
|
+
str = RubyVM::InstructionSequence.disasm(expr)
|
9
|
+
when String
|
10
|
+
str = RubyVM::InstructionSequence.compile(expr).disasm
|
11
|
+
else
|
12
|
+
return puts "Error: The command 'disasm' requires Method/Proc/String instance."
|
13
|
+
end
|
7
14
|
|
8
15
|
lines = str.split("\n")
|
9
16
|
lines[0].gsub!(/=+/) { |s| "\033[0;32m#{s}\033[0m" }
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'binding_of_caller'
|
2
|
+
require 'clipboard'
|
3
|
+
|
4
|
+
# ap_hack 可以确保,当使用 irb! 时,looksee ls1 输出显示正确,同时不用关闭 irb :USE_COLORIZE 设置。
|
5
|
+
# See https://github.com/oggy/looksee/issues/57
|
6
|
+
# 但是,ap_hack 必须放到 break_hack 前面,调换顺序,上面的 hack 失效。
|
7
|
+
# WARN: 下面两行代码顺序不要换。
|
8
|
+
require 'pryx/ap_hack'
|
9
|
+
require 'pryx/break_hack'
|
data/lib/pryx/irb_hack.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'binding_of_caller'
|
2
|
-
|
3
1
|
class Binding
|
4
2
|
def _irb(_host=nil)
|
5
3
|
warn '[1m[33mloading irb ...[0m'
|
@@ -26,7 +24,9 @@ module Kernel
|
|
26
24
|
|
27
25
|
ENV['IRB_was_started'] = 'true'
|
28
26
|
|
29
|
-
|
27
|
+
require 'binding_of_caller'
|
28
|
+
|
29
|
+
irb3(2)
|
30
30
|
end
|
31
31
|
|
32
32
|
def reirb!
|
@@ -37,10 +37,19 @@ module Kernel
|
|
37
37
|
ENV['IRB2_should_start'] = 'true'
|
38
38
|
end
|
39
39
|
|
40
|
-
def irb2
|
40
|
+
def irb2
|
41
41
|
if ENV['IRB2_should_start'] == 'true'
|
42
42
|
ENV['IRB2_should_start'] = nil
|
43
|
-
|
43
|
+
|
44
|
+
require 'binding_of_caller'
|
45
|
+
|
46
|
+
irb3(2)
|
44
47
|
end
|
45
48
|
end
|
49
|
+
|
50
|
+
def irb3(caller=1)
|
51
|
+
require 'binding_of_caller'
|
52
|
+
|
53
|
+
binding.of_caller(caller)._irb
|
54
|
+
end
|
46
55
|
end
|
data/lib/pryx/looksee_hack.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
# 被覆写的方法 灰色 30
|
11
11
|
|
12
12
|
module Kernel
|
13
|
-
def
|
13
|
+
def _load_looksee
|
14
14
|
case RbConfig::CONFIG['ruby_version']
|
15
15
|
when '1.9.0'...'2.1.0'
|
16
16
|
require 'old_looksee'
|
@@ -23,12 +23,12 @@ module Kernel
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def ls1(*args)
|
26
|
-
|
26
|
+
_load_looksee unless defined? Looksee
|
27
27
|
Looksee[self, *args, :noprivate]
|
28
28
|
end
|
29
29
|
|
30
30
|
def ls2(*args)
|
31
|
-
|
31
|
+
_load_looksee unless defined? Looksee
|
32
32
|
Looksee[self, *args]
|
33
33
|
end
|
34
34
|
end
|
data/lib/pryx/pry_hack.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# 注意如果开启 pry-stack_explorer, 就不要使用 debugger, 因为进入新的上下文后, pry-stack_explorer 将失效.
|
2
2
|
|
3
|
-
require 'binding_of_caller'
|
4
|
-
|
5
3
|
class Binding
|
6
4
|
def _pry(host=nil, port=nil, options={})
|
7
5
|
if host
|
@@ -10,8 +8,7 @@ class Binding
|
|
10
8
|
require 'pry'
|
11
9
|
end
|
12
10
|
|
13
|
-
require 'pryx/
|
14
|
-
require 'pryx/break_hack'
|
11
|
+
require 'pryx/common_plugins'
|
15
12
|
require 'pryx/pry_plugins'
|
16
13
|
|
17
14
|
if host
|
@@ -55,14 +52,6 @@ module Kernel
|
|
55
52
|
# 这里如果有代码, 将会让 pry! 进入这个方法, 因此保持为空.
|
56
53
|
end
|
57
54
|
|
58
|
-
# 等价于默认的 binding.pry, 会反复被拦截。
|
59
|
-
# 起成 pry3 这个名字,也是为了方便直接使用。
|
60
|
-
def pry3(caller=1, remote: nil, port: 9876)
|
61
|
-
remote = '0.0.0.0' if Pryx::Background.background?
|
62
|
-
|
63
|
-
binding.of_caller(caller)._pry(remote, port)
|
64
|
-
end
|
65
|
-
|
66
55
|
def pry1
|
67
56
|
ENV['Pry2_should_start'] = 'true'
|
68
57
|
end
|
@@ -73,10 +62,20 @@ module Kernel
|
|
73
62
|
def pry2(caller=1, remote: nil, port: 9876)
|
74
63
|
if ENV['Pry2_should_start'] == 'true'
|
75
64
|
ENV['Pry2_should_start'] = nil
|
76
|
-
|
65
|
+
pry3(2, remote: remote, port: port)
|
77
66
|
end
|
78
67
|
end
|
79
68
|
|
69
|
+
# 等价于默认的 binding.pry, 会反复被拦截。
|
70
|
+
# 起成 pry3 这个名字,也是为了方便直接使用。
|
71
|
+
def pry3(caller=1, remote: nil, port: 9876)
|
72
|
+
remote = '0.0.0.0' if Pryx::Background.background?
|
73
|
+
|
74
|
+
require 'binding_of_caller'
|
75
|
+
|
76
|
+
binding.of_caller(caller)._pry(remote, port)
|
77
|
+
end
|
78
|
+
|
80
79
|
def notify_send(msg)
|
81
80
|
system("notify-send \"#{msg}\"") if system 'which notify-send &>/dev/null'
|
82
81
|
|
data/lib/pryx/pry_plugins.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# power_assert is ruby 3 builtin gem
|
1
2
|
require 'pry-power_assert'
|
2
3
|
|
3
4
|
require 'pry-doc'
|
@@ -7,12 +8,15 @@ Pry.commands.alias_command 'y', 'yes'
|
|
7
8
|
|
8
9
|
require 'pry-hier'
|
9
10
|
|
11
|
+
require 'pry-disasm'
|
12
|
+
|
10
13
|
require 'pry-aa_ancestors'
|
11
14
|
Pry::Commands.alias_command 'aa', 'aa_ancestors'
|
12
15
|
|
13
|
-
#
|
14
|
-
#
|
15
|
-
require 'pry-stack_explorer'
|
16
|
+
# stack 显示 stack 的列表,
|
17
|
+
# frame 显示当前所在 stack, frame N 也可以根据数字跳转到 N
|
18
|
+
require 'pry-stack_explorer'
|
19
|
+
require 'pryx/pry-stack_explorer_hack'
|
16
20
|
|
17
21
|
Pry::Commands.block_command 'cc', 'Continue, but stop in pry! breakpoint' do
|
18
22
|
Pry.instance_variable_set(:@initial_session, true)
|
data/lib/pryx/version.rb
CHANGED
data/lib/pryx.rb
CHANGED
@@ -9,7 +9,7 @@ require 'pryx/irb_hack'
|
|
9
9
|
|
10
10
|
# Add the non-bundler managermented gems back
|
11
11
|
# this step is necessory when install pryx in docker-compose
|
12
|
-
ENV['RUBYLIB'] = $LOAD_PATH.grep(/gems/).join(':')
|
12
|
+
ENV['RUBYLIB'] = "#{ENV['RUBYLIB']}:#{$LOAD_PATH.grep(/gems/).join(':')}"
|
13
13
|
|
14
14
|
# set export RUBYOPT+=" -rpryx" to work with pryx.
|
15
15
|
module Pryx
|
data/lib/pryx_irb.rb
CHANGED
@@ -5,10 +5,5 @@
|
|
5
5
|
# we need set `export RUBYOPT+=" -rpryx_irb"` instead of `-rpryx` to make
|
6
6
|
# irb work with break and ap gem.
|
7
7
|
|
8
|
-
|
9
|
-
# 但是,ap_hack 不可以放到 break_hack 后面,否则会失效。
|
10
|
-
# WARN: 下面两行代码顺序不要换。
|
11
|
-
require 'pryx/ap_hack'
|
12
|
-
require 'pryx/break_hack'
|
13
|
-
|
8
|
+
require 'pryx/common_plugins'
|
14
9
|
require 'pryx'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pryx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Billy.Zheng(zw963)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: clipboard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: pry
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,16 +126,16 @@ dependencies:
|
|
112
126
|
name: pry-aa_ancestors
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- - "
|
129
|
+
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
131
|
+
version: 0.0.1
|
118
132
|
type: :runtime
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- - "
|
136
|
+
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
138
|
+
version: 0.0.1
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: pry-stack_explorer
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,7 +151,21 @@ dependencies:
|
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0.6'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
154
|
+
name: pry-rescue
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '1.5'
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.5'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: minitest
|
141
169
|
requirement: !ruby/object:Gem::Requirement
|
142
170
|
requirements:
|
143
171
|
- - ">="
|
@@ -150,6 +178,20 @@ dependencies:
|
|
150
178
|
- - ">="
|
151
179
|
- !ruby/object:Gem::Version
|
152
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: m
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '1.6'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '1.6'
|
153
195
|
- !ruby/object:Gem::Dependency
|
154
196
|
name: ritual
|
155
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -197,9 +239,11 @@ files:
|
|
197
239
|
- lib/pryx/ap_hack.rb
|
198
240
|
- lib/pryx/background.rb
|
199
241
|
- lib/pryx/break_hack.rb
|
242
|
+
- lib/pryx/common_plugins.rb
|
200
243
|
- lib/pryx/drip.wav
|
201
244
|
- lib/pryx/irb_hack.rb
|
202
245
|
- lib/pryx/looksee_hack.rb
|
246
|
+
- lib/pryx/pry-stack_explorer_hack.rb
|
203
247
|
- lib/pryx/pry_hack.rb
|
204
248
|
- lib/pryx/pry_plugins.rb
|
205
249
|
- lib/pryx/trap_backtrace.rb
|