Class: Shell
Overview
Instance Attribute Summary
Attributes inherited from ArcadiaExt
#arcadia
Instance Method Summary
collapse
Methods inherited from ArcadiaExt
#conf, #conf_array, #exec, #float_frame, #frame, #initialize
Constructor Details
This class inherits a constructor from ArcadiaExt
Instance Method Details
#is_windows? ⇒ Boolean
96
97
98
99
|
# File 'ext/ae-shell/ae-shell.rb', line 96
def is_windows?
!(RUBY_PLATFORM =~ /(win|w)32$/).nil?
end
|
#on_before_build(_event) ⇒ Object
#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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'ext/ae-shell/ae-shell.rb', line 47
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 if _event.persistent
_cmd_ = "|"+@arcadia['conf']['shell.ruby']+" "+_filename+" 2>&1"
open(_cmd_,"r"){|f|
_readed = f.read
Arcadia.console(self,'msg'=>_readed, 'level'=>'debug')
_event.add_result(self, 'output'=>_readed)
}
rescue Exception => e
Arcadia.console(self,'msg'=>e, 'level'=>'debug')
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
45
|
# File 'ext/ae-shell/ae-shell.rb', line 20
def on_system_exec(_event)
begin
_cmd_ = "#{_event.command}"
if is_windows?
io = IO.popen(_cmd_)
else
Process.fork{
open(_cmd_,"r"){|f|
Arcadia.console(self,'msg'=>f.read, 'level'=>'debug')
}
}
end
rescue Exception => e
Arcadia.console(self,'msg'=>e, 'level'=>'debug')
end
end
|
#on_system_exec_bo(_event) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'ext/ae-shell/ae-shell.rb', line 67
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.console(self,'msg'=>'begin', 'level'=>'debug')
@io = IO.popen(_cmd,'r+')
@io.puts(command)
result = ''
while line = @io.gets
result << line
end
Arcadia.console(self,'msg'=>result, 'level'=>'debug')
}
else
Process.fork{
open(_cmd_,"r"){|f|
Arcadia.console(self,'msg'=>f.read, 'level'=>'debug')
}
}
end
end
|
#run(_filename = nil) ⇒ Object
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'ext/ae-shell/ae-shell.rb', line 120
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"
@cmd = open(_cmd_,"r"){|f|
Arcadia.console(self, 'msg'=>f.read ,'level'=>'debug')
}
end
rescue Exception => e
Arcadia.console(self, 'msg'=>e ,'level'=>'debug')
end
end
end
|
#run_current ⇒ Object
106
107
108
109
|
# File 'ext/ae-shell/ae-shell.rb', line 106
def run_current
current_editor = $arcadia['editor'].raised
run(current_editor.file) if current_editor
end
|
#run_last ⇒ Object
102
103
104
|
# File 'ext/ae-shell/ae-shell.rb', line 102
def run_last
run($arcadia['pers']['run.file.last'])
end
|
#stop ⇒ Object
111
112
113
114
115
116
117
118
|
# File 'ext/ae-shell/ae-shell.rb', line 111
def stop
@run_threads.each{|t|
if t.alive?
t.kill
end
}
debug_quit if @adw
end
|