Module: Chitin::Builtins::ExecutableBinaries
Constant Summary
collapse
- COMMANDS =
Executable files Do them lazily because otherwise we could have a SHITTONNE of methods lying around in the objectspace
{}
- PRIORITY_METHODS =
[]
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
# File 'lib/chitin/commands/builtins.rb', line 165
def method_missing(name, *args, &block)
if PRIORITY_METHODS.include? name
return StringMethod.new(name, *args, &block)
end
if path_for_exec(name)
return Executable.new(path_for_exec(name), *args)
end
if "".public_methods(false).include? name
return StringMethod.new(name, *args, &block)
end
super
end
|
Instance Method Details
#path_for_exec(name) ⇒ Object
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# File 'lib/chitin/commands/builtins.rb', line 151
def path_for_exec(name)
return COMMANDS[name] if COMMANDS[name]
ENV['PATH'].split(':').each do |p|
if File.exist? File.join(p, name.to_s)
COMMANDS[name] = File.join(p, name.to_s)
return COMMANDS[name]
end
end
false
end
|
#raw_exec(path, *args) ⇒ Object
Also known as:
here
182
183
184
|
# File 'lib/chitin/commands/builtins.rb', line 182
def raw_exec(path, *args)
Executable.new path, *args
end
|