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!(host: nil, port: 9876, state: false) ⇒ Object
运行 pry! 会被拦截, 且只会被拦截一次.
- #pry1 ⇒ Object
-
#pry2(host: nil, port: 9876) ⇒ Object
1.
-
#pry3(caller = 1, host: nil, port: 9876) ⇒ Object
等价于默认的 binding.pry, 会反复被拦截。 起成 pry3 这个名字,也是为了方便直接使用。.
- #reirb! ⇒ Object
-
#repry! ⇒ Object
在 pry! 之前如果输入这个,会让下次执行的 pry! 被拦截一次, 而不管之前是否有执行过 pry!.
Instance Method Details
#_load_looksee ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/pryx/looksee_hack.rb', line 13 def _load_looksee require 'looksee' Looksee.rename :ls_looksee Looksee.editor = '.emacsclient +%l %f' # e.g. [].ls1.edit :to_set end |
#irb! ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/pryx/irb_hack.rb', line 12 def irb! return unless ENV['IRB_was_started'].nil? ENV['IRB_was_started'] = 'true' irb3(2) end |
#irb1 ⇒ Object
24 25 26 |
# File 'lib/pryx/irb_hack.rb', line 24 def irb1 ENV['IRB2_should_start'] = 'true' end |
#irb2 ⇒ Object
28 29 30 31 32 33 |
# File 'lib/pryx/irb_hack.rb', line 28 def irb2 if ENV['IRB2_should_start'] == 'true' ENV['IRB2_should_start'] = nil irb3(2) end end |
#irb3(caller = 1) ⇒ Object
35 36 37 38 39 |
# File 'lib/pryx/irb_hack.rb', line 35 def irb3(caller=1) require 'binding_of_caller' binding.of_caller(caller)._irb end |
#ls1(*args) ⇒ Object
21 22 23 24 |
# File 'lib/pryx/looksee_hack.rb', line 21 def ls1(*args) _load_looksee unless defined? Looksee Looksee[self, *args, :noprivate] end |
#ls2(*args) ⇒ Object
26 27 28 29 |
# File 'lib/pryx/looksee_hack.rb', line 26 def ls2(*args) _load_looksee unless defined? Looksee Looksee[self, *args] end |
#notify_send(msg) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/pryx/pry_hack.rb', line 73 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!(host: nil, port: 9876, state: false) ⇒ Object
运行 pry! 会被拦截, 且只会被拦截一次.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pryx/pry_hack.rb', line 29 def pry!(host: nil, port: 9876, state: false) # You can use environment variables SHOW_GLOBAL_VARIABLES, # HIDE_INSTANCE_VARIABLES and HIDE_LOCAL_VARIABLES # to customise the kind of variables shown. require_relative '../pry-state' if state return unless ENV['Pry_was_started'].nil? ENV['Pry_was_started'] = 'true' pry3(2, host: host, port: port) # 这里如果有代码, 将会让 pry! 进入这个方法, 因此保持为空. end |
#pry1 ⇒ Object
49 50 51 |
# File 'lib/pryx/pry_hack.rb', line 49 def pry1 ENV['Pry2_should_start'] = 'true' end |
#pry2(host: nil, port: 9876) ⇒ Object
-
单独运行 pry2, 永远不会被拦截,
-
如果之前运行过 pry1, 此时 pry2 将被拦截, 且只会被拦截一次.
56 57 58 59 60 61 |
# File 'lib/pryx/pry_hack.rb', line 56 def pry2(host: nil, port: 9876) if ENV['Pry2_should_start'] == 'true' ENV['Pry2_should_start'] = nil pry3(2, host: host, port: port) end end |
#pry3(caller = 1, host: nil, port: 9876) ⇒ Object
等价于默认的 binding.pry, 会反复被拦截。起成 pry3 这个名字,也是为了方便直接使用。
65 66 67 68 69 70 71 |
# File 'lib/pryx/pry_hack.rb', line 65 def pry3(caller=1, host: nil, port: 9876) host = '0.0.0.0' if Pryx::Background.background? require 'binding_of_caller' binding.of_caller(caller)._pry(host: host, port: port) end |
#reirb! ⇒ Object
20 21 22 |
# File 'lib/pryx/irb_hack.rb', line 20 def reirb! ENV['IRB_was_started'] = nil end |
#repry! ⇒ Object
在 pry! 之前如果输入这个,会让下次执行的 pry! 被拦截一次, 而不管之前是否有执行过 pry!
45 46 47 |
# File 'lib/pryx/pry_hack.rb', line 45 def repry! ENV['Pry_was_started'] = nil end |