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
228
229
230
231
232
233
234
235
|
# File 'lib/chitin/commands/builtins.rb', line 228
def method_missing(name, *args, &block)
if meth = lookup(name, *args, &block)
return meth
end
super
end
|
Instance Method Details
#lookup(name, *args, &block) ⇒ Object
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
# File 'lib/chitin/commands/builtins.rb', line 243
def lookup(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
nil
end
|
#path_for_exec(name) ⇒ Object
214
215
216
217
218
219
220
221
222
223
224
225
226
|
# File 'lib/chitin/commands/builtins.rb', line 214
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, h
237
238
239
|
# File 'lib/chitin/commands/builtins.rb', line 237
def raw_exec(path, *args)
Executable.new path, *args
end
|