mirror of
https://github.com/ruby/ruby.git
synced 2025-08-24 13:34:17 +02:00

(https://github.com/ruby/irb/pull/824)
* Command is not a method
* Fix command test
* Implement non-method command name completion
* Add test for ExtendCommandBundle.def_extend_command
* Add helper method install test
* Remove spaces in command input parse
* Remove command arg unquote in help command
* Simplify Statement and handle execution in IRB::Irb
* Tweak require, const name
* Always install CommandBundle module to main object
* Remove considering local variable in command or expression check
* Remove unused method, tweak
* Remove outdated comment for help command arg
Co-authored-by: Stan Lo <stan001212@gmail.com>
---------
8fb776e379
Co-authored-by: Stan Lo <stan001212@gmail.com>
36 lines
1.1 KiB
Ruby
36 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
#
|
|
# push-ws.rb -
|
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
|
#
|
|
|
|
module IRB # :nodoc:
|
|
class Context
|
|
# Creates a new workspace with the given object or binding, and appends it
|
|
# onto the current #workspaces stack.
|
|
#
|
|
# See IRB::Context#change_workspace and IRB::WorkSpace.new for more
|
|
# information.
|
|
def push_workspace(*_main)
|
|
if _main.empty?
|
|
if @workspace_stack.size > 1
|
|
# swap the top two workspaces
|
|
previous_workspace, current_workspace = @workspace_stack.pop(2)
|
|
@workspace_stack.push current_workspace, previous_workspace
|
|
end
|
|
else
|
|
new_workspace = WorkSpace.new(workspace.binding, _main[0])
|
|
@workspace_stack.push new_workspace
|
|
new_workspace.load_helper_methods_to_main
|
|
end
|
|
end
|
|
|
|
# Removes the last element from the current #workspaces stack and returns
|
|
# it, or +nil+ if the current workspace stack is empty.
|
|
#
|
|
# Also, see #push_workspace.
|
|
def pop_workspace
|
|
@workspace_stack.pop if @workspace_stack.size > 1
|
|
end
|
|
end
|
|
end
|