Class: Shell
- Inherits:
-
ArcadiaExt
- Object
- ArcadiaExt
- Shell
- Defined in:
- ext/ae-shell/ae-shell.rb
Overview
require “base/a-utils”
Instance Method Summary collapse
- #is_windows? ⇒ Boolean
- #on_before_build(_event) ⇒ Object
- #on_build(_event) ⇒ Object
- #on_run_ruby_file(_event) ⇒ Object
- #on_system_exec(_event) ⇒ Object
- #on_system_exec_bo(_event) ⇒ Object
- #run(_filename = nil) ⇒ Object
- #run_current ⇒ Object
- #run_last ⇒ Object
- #stop ⇒ Object
Instance Method Details
#is_windows? ⇒ Boolean
89 90 91 92 |
# File 'ext/ae-shell/ae-shell.rb', line 89 def is_windows? !(RUBY_PLATFORM =~ /(win|w)32$/).nil? #RUBY_PLATFORM.include?('win') end |
#on_before_build(_event) ⇒ Object
11 12 13 14 |
# File 'ext/ae-shell/ae-shell.rb', line 11 def on_before_build(_event) Arcadia.add_listener(self, SystemExecEvent) Arcadia.add_listener(self, RunRubyFileEvent) end |
#on_build(_event) ⇒ Object
16 17 18 |
# File 'ext/ae-shell/ae-shell.rb', line 16 def on_build(_event) @run_threads = Array.new end |
#on_run_ruby_file(_event) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'ext/ae-shell/ae-shell.rb', line 46 def on_run_ruby_file(_event) _filename = _event.file _filename = @arcadia['pers']['run.file.last'] if _filename == "*LAST" if _filename && File.exists?(_filename) begin @arcadia['pers']['run.file.last']=_filename _cmd_ = "|"+@arcadia['conf']['shell.ruby']+" "+_filename+" 2>&1" open(_cmd_,"r"){|f| _readed = f.read Arcadia.new_debug_msg(self, _readed) _event.add_result(self, 'output'=>_readed) } rescue Exception => e Arcadia.new_debug_msg(self, e) end end end |
#on_system_exec(_event) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'ext/ae-shell/ae-shell.rb', line 20 def on_system_exec(_event) begin # _cmd_ = "|ruby #{File.dirname(__FILE__)}/sh.rb #{_event.command} 2>&1" # p _cmd_ # Thread.new do # open(_cmd_,"r"){|f| # Arcadia.new_debug_msg(self, f.read) # } # end _cmd_ = "#{_event.command}" if is_windows? io = IO.popen(_cmd_) else Process.fork{ open(_cmd_,"r"){|f| Arcadia.new_debug_msg(self, f.read) #Arcadia.new_debug_msg(self, f.read) } } end rescue Exception => e Arcadia.new_debug_msg(self, e) end end |
#on_system_exec_bo(_event) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'ext/ae-shell/ae-shell.rb', line 64 def on_system_exec_bo(_event) command = "#{_event.command} 2>&1" (RUBY_PLATFORM.include?('mswin32'))?_cmd="cmd":_cmd='sh' if is_windows? Thread.new{ Arcadia.new_debug_msg(self, 'inizio') @io = IO.popen(_cmd,'r+') @io.puts(command) result = '' while line = @io.gets result << line end Arcadia.new_debug_msg(self, result) } else Process.fork{ open(_cmd_,"r"){|f| Arcadia.new_debug_msg(self, f.read) } } end end |
#run(_filename = nil) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'ext/ae-shell/ae-shell.rb', line 113 def run(_filename=nil) if _filename begin @arcadia['pers']['run.file.last']=_filename @run_threads << Thread.new do _cmd_ = "|"+$arcadia['conf']['shell.ruby']+" "+_filename+" 2>&1" # Arcadia.new_debug_msg(self, _cmd_) @cmd = open(_cmd_,"r"){|f| Arcadia.new_debug_msg(self, f.read) } end rescue Exception => e Arcadia.new_debug_msg(self, e) end end end |
#run_current ⇒ Object
99 100 101 102 |
# File 'ext/ae-shell/ae-shell.rb', line 99 def run_current current_editor = $arcadia['editor'].raised run(current_editor.file) if current_editor end |
#run_last ⇒ Object
95 96 97 |
# File 'ext/ae-shell/ae-shell.rb', line 95 def run_last run($arcadia['pers']['run.file.last']) end |
#stop ⇒ Object
104 105 106 107 108 109 110 111 |
# File 'ext/ae-shell/ae-shell.rb', line 104 def stop @run_threads.each{|t| if t.alive? t.kill end } debug_quit if @adw end |