lib/ronin/ui/console.rb in ronin-0.1.4 vs lib/ronin/ui/console.rb in ronin-0.2.0
- old
+ new
@@ -25,103 +25,107 @@
require 'irb'
require 'irb/completion'
module Ronin
- module Console
- #
- # Returns the default Console prompt style
- #
- def Console.prompt
- @@ronin_console_prompt ||= :SIMPLE
- end
+ module UI
+ module Console
+ #
+ # Returns the default Console prompt style
+ #
+ def Console.prompt
+ @@ronin_console_prompt ||= :SIMPLE
+ end
- #
- # Sets the default Console prompt style to the specified _style_.
- #
- def Console.prompt=(style)
- @@ronin_console_prompt = style
- end
+ #
+ # Sets the default Console prompt style to the specified _style_.
+ #
+ def Console.prompt=(style)
+ @@ronin_console_prompt = style
+ end
- #
- # Returns the default Console indent setting.
- #
- def Console.indent
- @@ronin_console_indent ||= true
- end
+ #
+ # Returns the default Console indent setting.
+ #
+ def Console.indent
+ @@ronin_console_indent ||= true
+ end
- #
- # Sets the default Console indent setting.
- #
- def Console.indent=(value)
- @@ronin_console_indent = value
- end
+ #
+ # Sets the default Console indent setting.
+ #
+ def Console.indent=(value)
+ @@ronin_console_indent = value
+ end
- #
- # Returns the Array of files to require when the Console starts.
- #
- def Console.auto_load
- @@ronin_console_auto_load ||= []
- end
+ #
+ # Returns the Array of files to require when the Console starts.
+ #
+ def Console.auto_load
+ @@ronin_console_auto_load ||= []
+ end
- #
- # Calls the specified _block_ from within the Console after it is
- # started.
- #
- def Console.setup(&block)
- Console.setup_blocks << block if block
- end
+ #
+ # Calls the specified _block_ from within the Console after it is
+ # started.
+ #
+ def Console.setup(&block)
+ Console.setup_blocks << block if block
+ end
- #
- # Starts a Console with the given _script_. If a _block_ is given, it
- # will be called from within the Console.
- #
- def Console.start(script=nil,&block)
- IRB.setup(script)
+ #
+ # Starts a Console with the given _script_. If a _block_ is given, it
+ # will be called from within the Console.
+ #
+ def Console.start(script=nil,&block)
+ IRB.setup(script)
- IRB.conf[:IRB_NAME] = 'ronin'
- IRB.conf[:PROMPT_MODE] = Console.prompt
- IRB.conf[:AUTO_INDENT] = Console.indent
- IRB.conf[:LOAD_MODULES] = Console.auto_load
+ IRB.conf[:IRB_NAME] = 'ronin'
+ IRB.conf[:PROMPT_MODE] = Console.prompt
+ IRB.conf[:AUTO_INDENT] = Console.indent
- irb = IRB::Irb.new(nil,script)
+ irb = IRB::Irb.new(nil,script)
- # configure the irb workspace
- irb.context.main.instance_eval do
- require 'ronin'
- require 'pp'
+ # configure the irb workspace
+ irb.context.main.instance_eval do
+ require 'ronin/environment'
- include Ronin
- end
+ Ronin::UI::Console.auto_load.each do |path|
+ require path
+ end
- Console.setup_blocks.each do |setup_block|
- irb.context.main.instance_eval(&setup_block)
- end
+ include Ronin
+ end
- # Load console configuration block is given
- irb.context.main.instance_eval(&block) if block
+ Console.setup_blocks.each do |setup_block|
+ irb.context.main.instance_eval(&setup_block)
+ end
- IRB.conf[:MAIN_CONTEXT] = irb.context
+ # Load console configuration block is given
+ irb.context.main.instance_eval(&block) if block
- trap('SIGINT') do
- irb.signal_handle
- end
+ IRB.conf[:MAIN_CONTEXT] = irb.context
- catch(:IRB_EXIT) do
- irb.eval_input
- end
+ trap('SIGINT') do
+ irb.signal_handle
+ end
- print "\n"
- return nil
- end
+ catch(:IRB_EXIT) do
+ irb.eval_input
+ end
- protected
+ putc "\n"
+ return nil
+ end
- #
- # Returns the Array of setup_blocks to run within the Console after it
- # is started.
- #
- def Console.setup_blocks
- @@console_setup_blocks ||= []
+ protected
+
+ #
+ # Returns the Array of setup_blocks to run within the Console after it
+ # is started.
+ #
+ def Console.setup_blocks
+ @@console_setup_blocks ||= []
+ end
end
end
end