B
Bryan Richardson
Hello all,
I'm attempting to convert a command-line driven application into a
console application using Irb. However, I'm having some trouble right
out of the gate. Here's what I have so far:
module App
class Framework
def use(plugin)
path = "plugins/#{plugin}"
tree = plugin.split('/')
tree.collect! { |x| x.capitalize }
@plugin = Object.const_get("App::#{tree.join('::')}").new
end
def show_options
@plugin.show_options
end
def run
@plugin.run
end
end
end
binding = App::Framework.new
load 'irb.rb'
IRB.setup(nil)
IRB.conf[
ROMPT][:APP] = IRB.conf[
ROMPT][:SIMPLE]
IRB.conf[
ROMPT][:APP][
ROMPT_I] = 'app > '
IRB.conf[
ROMPT_MODE] = :APP
irb = IRB::Irb.new(IRB::WorkSpace.new(binding))
IRB.conf[:MAIN_CONTEXT] = irb.context
trap('SIGINT') do
irb.signal_handle
end
catch
IRB_EXIT) do
irb.eval_input
end
Essentially, I'm setting the App::Framework class to be my Irb context.
When I run this program and try to load a plugin named 'test' using the
'use' method, I get the following:
antfarm > use test
ArgumentError: wrong number of arguments
from (irb):1:in `test'
from (irb):1
from :0
antfarm >
From this, it looks like 'test' might be a keyword in Irb, because when
I use a different plugin name I get the following:
antfarm > use hello
NameError: undefined local variable or method `hello' for
#<Antfarm::Framework:0xb7c4c16c>
from (irb):1
from :0
antfarm >
From this, it looks like 'use' might be a keyword as well. I'm having
trouble finding good documentation on Irb Contexts, so if there are any
Irb experts out there please help!!!
I'm attempting to convert a command-line driven application into a
console application using Irb. However, I'm having some trouble right
out of the gate. Here's what I have so far:
module App
class Framework
def use(plugin)
path = "plugins/#{plugin}"
tree = plugin.split('/')
tree.collect! { |x| x.capitalize }
@plugin = Object.const_get("App::#{tree.join('::')}").new
end
def show_options
@plugin.show_options
end
def run
@plugin.run
end
end
end
binding = App::Framework.new
load 'irb.rb'
IRB.setup(nil)
IRB.conf[
IRB.conf[
IRB.conf[
irb = IRB::Irb.new(IRB::WorkSpace.new(binding))
IRB.conf[:MAIN_CONTEXT] = irb.context
trap('SIGINT') do
irb.signal_handle
end
catch
irb.eval_input
end
Essentially, I'm setting the App::Framework class to be my Irb context.
When I run this program and try to load a plugin named 'test' using the
'use' method, I get the following:
antfarm > use test
ArgumentError: wrong number of arguments
from (irb):1:in `test'
from (irb):1
from :0
antfarm >
From this, it looks like 'test' might be a keyword in Irb, because when
I use a different plugin name I get the following:
antfarm > use hello
NameError: undefined local variable or method `hello' for
#<Antfarm::Framework:0xb7c4c16c>
from (irb):1
from :0
antfarm >
From this, it looks like 'use' might be a keyword as well. I'm having
trouble finding good documentation on Irb Contexts, so if there are any
Irb experts out there please help!!!