Module: IRB
- Defined in:
- lib/virb/default.rb,
lib/virb/default.rb
Defined Under Namespace
Classes: Abort, Irb, StdioInputMethod
Class Method Summary collapse
- .conf ⇒ Object
- .CurrentContext ⇒ Object
-
.inspect ⇒ Object
Singleton method.
- .irb_abort(irb, exception = Abort) ⇒ Object
- .irb_at_exit ⇒ Object
- .irb_exit(irb, ret) ⇒ Object
- .original_start(ap_path = nil) ⇒ Object
-
.start(ap_path = nil) ⇒ Object
initialize IRB and start TOP_LEVEL irb.
-
.version ⇒ Object
IRB version method.
Class Method Details
.conf ⇒ Object
73 74 75 |
# File 'lib/virb/default.rb', line 73 def IRB.conf @CONF end |
.CurrentContext ⇒ Object
86 87 88 |
# File 'lib/virb/default.rb', line 86 def IRB.CurrentContext IRB.conf[:MAIN_CONTEXT] end |
.inspect ⇒ Object
Singleton method
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
# File 'lib/virb/default.rb', line 436 def @CONF.inspect IRB.version unless self[:VERSION] array = [] for k, v in sort{|a1, a2| a1[0].id2name <=> a2[0].id2name} case k when :MAIN_CONTEXT, :__TMP__EHV__ array.push format("CONF[:%s]=...myself...", k.id2name) when :PROMPT s = v.collect{ |kk, vv| ss = vv.collect{|kkk, vvv| ":#{kkk.id2name}=>#{vvv.inspect}"} format(":%s=>{%s}", kk.id2name, ss.join(", ")) } array.push format("CONF[:%s]={%s}", k.id2name, s.join(", ")) else array.push format("CONF[:%s]=%s", k.id2name, v.inspect) end end array.join("\n") end |
.irb_abort(irb, exception = Abort) ⇒ Object
153 154 155 156 157 158 159 |
# File 'lib/virb/default.rb', line 153 def IRB.irb_abort(irb, exception = Abort) if defined? Thread irb.context.thread.raise exception, "abort then interrupt!" else raise exception, "abort then interrupt!" end end |
.irb_at_exit ⇒ Object
145 146 147 |
# File 'lib/virb/default.rb', line 145 def IRB.irb_at_exit @CONF[:AT_EXIT].each{|hook| hook.call} end |
.irb_exit(irb, ret) ⇒ Object
149 150 151 |
# File 'lib/virb/default.rb', line 149 def IRB.irb_exit(irb, ret) throw :IRB_EXIT, ret end |
.original_start(ap_path = nil) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/virb/default.rb', line 115 def IRB.original_start(ap_path = nil) $0 = File::basename(ap_path, ".rb") if ap_path IRB.setup(ap_path) if @CONF[:SCRIPT] irb = Irb.new(nil, @CONF[:SCRIPT]) else irb = Irb.new end @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC] @CONF[:MAIN_CONTEXT] = irb.context trap("SIGINT") do irb.signal_handle end begin catch(:IRB_EXIT) do irb.eval_input end ensure irb_at_exit end # print "\n" end |
.start(ap_path = nil) ⇒ Object
initialize IRB and start TOP_LEVEL irb
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/virb/default.rb', line 91 def IRB.start(ap_path = nil) `rm -rf .virb` `mkdir -p .virb` unless File.exist?('.virb/fifo') `mkfifo .virb/fifo` end `touch .virb/session` vimscript = File.join(File.dirname(__FILE__), '..', 'virb.vim') # strip args so IRB doesn't think it's loading a file args = ARGV.dup while ARGV.shift # pass end fork do original_start ap_path end exec("vim -S #{vimscript} #{args.join(' ')} && rm -rf .virb && kill 0") end |
.version ⇒ Object
IRB version method
78 79 80 81 82 83 84 |
# File 'lib/virb/default.rb', line 78 def IRB.version if v = @CONF[:VERSION] then return v end require "irb/version" rv = @RELEASE_VERSION.sub(/\.0/, "") @CONF[:VERSION] = format("irb %s(%s)", rv, @LAST_UPDATE_DATE) end |