Class: Ronin::Core::CLI::RubyShell
- Inherits:
-
Object
- Object
- Ronin::Core::CLI::RubyShell
- Includes:
- CommandKit::Colors, Banner
- Defined in:
- lib/ronin/core/cli/ruby_shell.rb
Overview
Starts a customized Interactive Ruby console.
Constant Summary
Constants included from Banner
Instance Attribute Summary collapse
-
#context ⇒ Object?
readonly
The optional context to spawn the console inside of.
-
#name ⇒ String
readonly
The console name.
Class Method Summary collapse
-
.start(**kwargs) ⇒ Object
Starts a customized [irb] console.
Instance Method Summary collapse
-
#configure ⇒ Object
Configures IRB.
-
#initialize(name: 'ronin', context: nil, **kwargs) ⇒ RubyShell
constructor
Initializes the console.
-
#start ⇒ Object
Starts a customized [irb] console.
Methods included from Banner
Constructor Details
#initialize(name: 'ronin', context: nil, **kwargs) ⇒ RubyShell
Initializes the console.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 59 def initialize(name: 'ronin', context: nil, **kwargs) super(**kwargs) @name = name @context = case context when Module Object.new.tap do |obj| obj.singleton_class.include(context) obj.singleton_class.define_singleton_method(:const_missing,&context.method(:const_missing)) obj.define_singleton_method(:inspect) do "#<#{context}>" end end else context end end |
Instance Attribute Details
#context ⇒ Object? (readonly)
The optional context to spawn the console inside of.
45 46 47 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 45 def context @context end |
#name ⇒ String (readonly)
The console name.
40 41 42 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 40 def name @name end |
Class Method Details
.start(**kwargs) ⇒ Object
Starts a customized irb console.
90 91 92 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 90 def self.start(**kwargs) new(**kwargs).start end |
Instance Method Details
#configure ⇒ Object
Configures IRB.
97 98 99 100 101 102 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 97 def configure IRB.setup(nil, argv: []) IRB.conf[:IRB_NAME] = @name set_prompt end |
#start ⇒ Object
Starts a customized irb console.
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 108 def start if STDOUT.tty? configure workspace = if @context then IRB::WorkSpace.new(@context) else IRB::WorkSpace.new end irb = IRB::Irb.new(workspace) irb.run end |