Module: Kernel
- Defined in:
- lib/pryx/looksee_hack.rb,
lib/pryx/irb_hack.rb,
lib/pryx/pry_hack.rb
Overview
ls1 支持的参数有:
-
String 或 Regexp,包含字符串或匹配正则过滤.
-
:nopublic :noprotected, :noprivate, :noundefined, :nooverridden 显示指定类型方法.
颜色方案模块 白色 37 公开方法 绿色 32 保护方法 黄色 33 私有方法 红色 31 取消定义的方法 蓝色 34 被覆写的方法 灰色 30
Instance Method Summary collapse
- #_load_looksee ⇒ Object
- #irb! ⇒ Object
- #irb1 ⇒ Object
- #irb2 ⇒ Object
- #irb3(caller = 1) ⇒ Object
- #ls1(*args) ⇒ Object
- #ls2(*args) ⇒ Object
- #notify_send(msg) ⇒ Object
-
#pry!(remote: nil, port: 9876) ⇒ Object
运行 pry! 会被拦截, 且只会被拦截一次.
- #pry1 ⇒ Object
-
#pry2(remote: nil, port: 9876) ⇒ Object
1.
-
#pry3(caller = 1, remote: nil, port: 9876) ⇒ Object
等价于默认的 binding.pry, 会反复被拦截。 起成 pry3 这个名字,也是为了方便直接使用。.
-
#pry?(remote: nil, port: 9876) ⇒ Boolean
和 pry! 的差别就是,pry? 使用 pry-state 插件输出当前 context 的很多变量内容。 注意:不需要总是开启 pry-state,因为有时候会输出太多内容,造成刷屏。.
- #reirb! ⇒ Object
-
#repry! ⇒ Object
在 pry! 之前如果输入这个,会让下次执行的 pry! 被拦截一次, 而不管之前是否有执行过 pry!.
Instance Method Details
#_load_looksee ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/pryx/looksee_hack.rb', line 13 def _load_looksee case RbConfig::CONFIG['ruby_version'] when '1.9.0'...'2.1.0' require 'old_looksee' when '2.1.0'...'3.2.0' require 'looksee' end Looksee.rename :ls_looksee Looksee.editor = '.emacsclient +%l %f' # e.g. [].ls1.edit :to_set end |
#irb! ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/pryx/irb_hack.rb', line 22 def irb! return unless ENV['IRB_was_started'].nil? ENV['IRB_was_started'] = 'true' require 'binding_of_caller' irb3(2) end |
#irb1 ⇒ Object
36 37 38 |
# File 'lib/pryx/irb_hack.rb', line 36 def irb1 ENV['IRB2_should_start'] = 'true' end |
#irb2 ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/pryx/irb_hack.rb', line 40 def irb2 if ENV['IRB2_should_start'] == 'true' ENV['IRB2_should_start'] = nil require 'binding_of_caller' irb3(2) end end |
#irb3(caller = 1) ⇒ Object
50 51 52 53 54 |
# File 'lib/pryx/irb_hack.rb', line 50 def irb3(caller=1) require 'binding_of_caller' binding.of_caller(caller)._irb end |
#ls1(*args) ⇒ Object
25 26 27 28 |
# File 'lib/pryx/looksee_hack.rb', line 25 def ls1(*args) _load_looksee unless defined? Looksee Looksee[self, *args, :noprivate] end |
#ls2(*args) ⇒ Object
30 31 32 33 |
# File 'lib/pryx/looksee_hack.rb', line 30 def ls2(*args) _load_looksee unless defined? Looksee Looksee[self, *args] end |
#notify_send(msg) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/pryx/pry_hack.rb', line 79 def notify_send(msg) system("notify-send \"#{msg}\"") if system 'which notify-send &>/dev/null' system('aplay "#{__dir__}/drip.wav" &>/dev/null') if system 'which aplay &>/dev/null' warn "[1m[33m#{msg}[0m" end |
#pry!(remote: nil, port: 9876) ⇒ Object
运行 pry! 会被拦截, 且只会被拦截一次.
27 28 29 30 31 32 33 34 35 |
# File 'lib/pryx/pry_hack.rb', line 27 def pry!(remote: nil, port: 9876) return unless ENV['Pry_was_started'].nil? ENV['Pry_was_started'] = 'true' pry3(2, remote: remote, port: port) # 这里如果有代码, 将会让 pry! 进入这个方法, 因此保持为空. end |
#pry1 ⇒ Object
55 56 57 |
# File 'lib/pryx/pry_hack.rb', line 55 def pry1 ENV['Pry2_should_start'] = 'true' end |
#pry2(remote: nil, port: 9876) ⇒ Object
-
单独运行 pry2, 永远不会被拦截,
-
如果之前运行过 pry1, 此时 pry2 将被拦截, 且只会被拦截一次.
62 63 64 65 66 67 |
# File 'lib/pryx/pry_hack.rb', line 62 def pry2(remote: nil, port: 9876) if ENV['Pry2_should_start'] == 'true' ENV['Pry2_should_start'] = nil pry3(2, remote: remote, port: port) end end |
#pry3(caller = 1, remote: nil, port: 9876) ⇒ Object
等价于默认的 binding.pry, 会反复被拦截。起成 pry3 这个名字,也是为了方便直接使用。
71 72 73 74 75 76 77 |
# File 'lib/pryx/pry_hack.rb', line 71 def pry3(caller=1, remote: nil, port: 9876) remote = '0.0.0.0' if Pryx::Background.background? require 'binding_of_caller' binding.of_caller(caller)._pry(remote, port) end |
#pry?(remote: nil, port: 9876) ⇒ Boolean
和 pry! 的差别就是,pry? 使用 pry-state 插件输出当前 context 的很多变量内容。注意:不需要总是开启 pry-state,因为有时候会输出太多内容,造成刷屏。
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pryx/pry_hack.rb', line 44 def pry?(remote: nil, port: 9876) return unless ENV['Pry_was_started'].nil? require 'pry-state' ENV['Pry_was_started'] = 'true' pry3(2, remote: remote, port: port) # 这里如果有代码, 将会让 pry! 进入这个方法, 因此保持为空. end |
#reirb! ⇒ Object
32 33 34 |
# File 'lib/pryx/irb_hack.rb', line 32 def reirb! ENV['IRB_was_started'] = nil end |
#repry! ⇒ Object
在 pry! 之前如果输入这个,会让下次执行的 pry! 被拦截一次, 而不管之前是否有执行过 pry!
38 39 40 |
# File 'lib/pryx/pry_hack.rb', line 38 def repry! ENV['Pry_was_started'] = nil end |