diff options
author | tomoya ishida <[email protected]> | 2024-04-11 01:52:47 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-04-10 16:52:53 +0000 |
commit | 6a505d1b59cf326a8e004fc06e02f30222b17f3f (patch) | |
tree | 8ed520d1aee744158f154f4dd7733b6eb4d017e0 /lib/irb/statement.rb | |
parent | 9f6deaa6888a423720b4b127b5314f0ad26cc2e6 (diff) |
[ruby/irb] Command implementation not by method
(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 <[email protected]>
---------
https://github.com/ruby/irb/commit/8fb776e379
Co-authored-by: Stan Lo <[email protected]>
Diffstat (limited to 'lib/irb/statement.rb')
-rw-r--r-- | lib/irb/statement.rb | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/lib/irb/statement.rb b/lib/irb/statement.rb index 1e026d112f..a3391c12a3 100644 --- a/lib/irb/statement.rb +++ b/lib/irb/statement.rb @@ -16,10 +16,6 @@ module IRB raise NotImplementedError end - def evaluable_code - raise NotImplementedError - end - class EmptyInput < Statement def is_assignment? false @@ -37,10 +33,6 @@ module IRB def code "" end - - def evaluable_code - code - end end class Expression < Statement @@ -60,18 +52,15 @@ module IRB def is_assignment? @is_assignment end - - def evaluable_code - @code - end end class Command < Statement - def initialize(code, command, arg, command_class) - @code = code - @command = command - @arg = arg + attr_reader :command_class, :arg + + def initialize(original_code, command_class, arg) + @code = original_code @command_class = command_class + @arg = arg end def is_assignment? @@ -86,17 +75,6 @@ module IRB require_relative 'command/debug' IRB::Command::DebugCommand > @command_class end - - def evaluable_code - # Hook command-specific transformation to return valid Ruby code - if @command_class.respond_to?(:transform_args) - arg = @command_class.transform_args(@arg) - else - arg = @arg - end - - [@command, arg].compact.join(' ') - end end end end |