Sha256: ad54a183e0f4fdf09ac2e57d876f86158111fc159c887112c62401c9e8e589eb

Contents?: true

Size: 997 Bytes

Versions: 42

Compression:

Stored size: 997 Bytes

Contents

module Rex
module Ui
module Text

###
#
# This class wraps the creation of an IRB shell.
#
###
class IrbShell

	@@IrbInitialized = false

	def initialize(binding)
		@binding_ctx = binding
	end

	#
	# Runs the IRB shell until completion.  The binding parameter initializes
	# IRB to the appropriate binding context.
	#
	def run
		# Initialize IRB by setting up its internal configuration hash and
		# stuff.
		if (@@IrbInitialized == false)
			load('irb.rb')

			IRB.setup(nil)
			IRB.conf[:PROMPT_MODE]  = :SIMPLE

			@@IrbInitialized = true
		end

		# Create a new IRB instance
		irb = IRB::Irb.new(IRB::WorkSpace.new(@binding_ctx))

		# Set the primary irb context so that exit and other intrinsic
		# commands will work.
		IRB.conf[:MAIN_CONTEXT] = irb.context

		# Trap interrupt
		old_sigint = trap("SIGINT") do
			irb.signal_handle
		end

		# Keep processing input until the cows come home...
		catch(:IRB_EXIT) do
			irb.eval_input
		end

		trap("SIGINT", old_sigint)
	end

end
end
end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/ui/text/irb_shell.rb
librex-0.0.63 lib/rex/ui/text/irb_shell.rb
librex-0.0.54 lib/rex/ui/text/irb_shell.rb
librex-0.0.53 lib/rex/ui/text/irb_shell.rb
librex-0.0.52 lib/rex/ui/text/irb_shell.rb
librex-0.0.51 lib/rex/ui/text/irb_shell.rb
librex-0.0.50 lib/rex/ui/text/irb_shell.rb
librex-0.0.49 lib/rex/ui/text/irb_shell.rb
librex-0.0.48 lib/rex/ui/text/irb_shell.rb
librex-0.0.47 lib/rex/ui/text/irb_shell.rb
librex-0.0.46 lib/rex/ui/text/irb_shell.rb
librex-0.0.44 lib/rex/ui/text/irb_shell.rb
librex-0.0.43 lib/rex/ui/text/irb_shell.rb
librex-0.0.42 lib/rex/ui/text/irb_shell.rb
librex-0.0.41 lib/rex/ui/text/irb_shell.rb
librex-0.0.40 lib/rex/ui/text/irb_shell.rb
librex-0.0.39 lib/rex/ui/text/irb_shell.rb
librex-0.0.38 lib/rex/ui/text/irb_shell.rb
librex-0.0.37 lib/rex/ui/text/irb_shell.rb
librex-0.0.36 lib/rex/ui/text/irb_shell.rb