Class: Ronin::Core::CLI::RubyShell
- Inherits:
-
Object
- Object
- Ronin::Core::CLI::RubyShell
- Includes:
- CommandKit::Colors
- Defined in:
- lib/ronin/core/cli/ruby_shell.rb
Overview
Starts a customized Interactive Ruby console.
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.
Constructor Details
#initialize(name: 'ronin', context: nil, **kwargs) ⇒ RubyShell
Initializes the console.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 57 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.
43 44 45 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 43 def context @context end |
#name ⇒ String (readonly)
The console name.
38 39 40 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 38 def name @name end |
Class Method Details
.start(**kwargs) ⇒ Object
Starts a customized irb console.
88 89 90 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 88 def self.start(**kwargs) new(**kwargs).start end |
Instance Method Details
#configure ⇒ Object
Configures IRB.
95 96 97 98 99 100 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 95 def configure IRB.setup(nil, argv: []) IRB.conf[:IRB_NAME] = @name set_prompt end |
#start ⇒ Object
Starts a customized irb console.
106 107 108 109 110 111 112 113 114 115 |
# File 'lib/ronin/core/cli/ruby_shell.rb', line 106 def start configure workspace = if @context then IRB::WorkSpace.new(@context) else IRB::WorkSpace.new end irb = IRB::Irb.new(workspace) irb.run end |