Class: RVC::RubyEvaluator
- Inherits:
-
Object
- Object
- RVC::RubyEvaluator
show all
- Includes:
- Util
- Defined in:
- lib/rvc/ruby_evaluator.rb
Constant Summary
Constants included
from Util
Util::PROGRESS_BAR_LEFT, Util::PROGRESS_BAR_MIDDLE, Util::PROGRESS_BAR_RIGHT, Util::UserError
Instance Method Summary
collapse
Methods included from Util
#collect_children, #display_inventory, #err, #http_clone, #http_download, #http_upload, #interactive?, #menu, #metric, #one_progress, #progress, #retrieve_fields, #search_path, #single_connection, #status_color, #system_fg, #tasks, #tcsetpgrp, #terminal_columns
Constructor Details
Returns a new instance of RubyEvaluator.
28
29
30
31
|
# File 'lib/rvc/ruby_evaluator.rb', line 28
def initialize shell
@binding = toplevel
@shell = shell
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *a) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/rvc/ruby_evaluator.rb', line 65
def method_missing sym, *a
if a.empty?
if @shell.cmds.namespaces.member? sym
@shell.cmds.namespaces[sym]
elsif sym.to_s =~ /_?([\w\d]+)(!?)/ && objs = @shell.fs.marks[$1]
if $2 == '!'
objs
else
objs.first
end
else
super
end
else
super
end
end
|
Instance Method Details
#conn ⇒ Object
57
58
59
|
# File 'lib/rvc/ruby_evaluator.rb', line 57
def conn
@shell.fs.lookup("~@").first
end
|
#dc ⇒ Object
53
54
55
|
# File 'lib/rvc/ruby_evaluator.rb', line 53
def dc
@shell.fs.lookup("~").first
end
|
#do_eval(input, file) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/rvc/ruby_evaluator.rb', line 37
def do_eval input, file
begin
eval input, @binding, file
rescue Exception => e
bt = e.backtrace
bt = bt.reverse.drop_while { |x| !(x =~ /toplevel/) }.reverse
bt[-1].gsub! ':in `toplevel\'', '' if bt[-1]
e.set_backtrace bt
raise
end
end
|
#rvc_exec(command) ⇒ Object
61
62
63
|
# File 'lib/rvc/ruby_evaluator.rb', line 61
def rvc_exec command
@shell.eval_command command
end
|
#this ⇒ Object
49
50
51
|
# File 'lib/rvc/ruby_evaluator.rb', line 49
def this
@shell.fs.cur
end
|
#toplevel ⇒ Object
33
34
35
|
# File 'lib/rvc/ruby_evaluator.rb', line 33
def toplevel
binding
end
|