Граф коммитов

56 Коммитов

Автор SHA1 Сообщение Дата
Gary Tou 4ee1f0fb5d [ruby/irb] Implement `history` command
(https://github.com/ruby/irb/pull/761)

* Implement `history` command

Lists IRB input history with indices. Also aliased as `hist`.

* Add tests for `history` command

* Address feedback: `puts` with multiple arguments instead of `join`ing

* Address feedback: Handle nil from splitting an empty input string

* Refactor line truncation

* Add `-g` grep option to `history` command

* Add `history` command to README

* Remove unused `*args` parameter

* Allow spaces to be included in grep

* Allow `/` to be included in grep regex

* Handle `input` being an empty string

* Exclude "#{index}: " from matching the grep regex

* Add new line after joining

https://github.com/ruby/irb/commit/3f9eacbfa9
2023-12-02 04:32:04 +00:00
tomoya ishida cf21c72cdb [ruby/irb] Fix test runner exit bug
(https://github.com/ruby/irb/pull/728)

* Remove useless test setup and teardown that sets MAIN_CONTEXT to nil

* Avoid adding command methods to main object in test

https://github.com/ruby/irb/commit/f204829a08
2023-10-12 13:55:47 +00:00
Takashi Kokubun 5140e6a4c3 Fix calling exit if irb_context is nil
Trying to avoid a flaky failure like:
https://github.com/ruby/ruby/actions/runs/6486918029/job/17616113816
2023-10-11 16:22:20 -07:00
Stan Lo f6af5a1128 [ruby/irb] Refactor eval history
(https://github.com/ruby/irb/pull/623)

* Rename `ext/history.rb` to `ext/eval_history.rb`

To confusion with `lib/irb/history.rb`

* Add eval_history tests

* Rename eval_history's History to EvalHistory to avoid confusion
2023-07-04 15:17:41 +00:00
Stan Lo af9eeb19d8 [ruby/irb] Stop treating history-saving logic as extension
(https://github.com/ruby/irb/pull/613)

Since `IRB.conf[:SAVE_HISTORY]` is assigned with 1000 by default, history-saving
is a feature enabled by default. So it should not be treated as an extension,
which adds unnecessary complexity to the code.
2023-07-03 13:48:23 +00:00
Stan Lo e1ccb2838b [ruby/irb] Use `Kernel.warn` to print command alias warning
(https://github.com/ruby/irb/pull/601)

This aligns with other warnings in irb and properly channel the message
to stderr.
2023-06-10 15:01:46 +00:00
Stan Lo b695f58d52 [ruby/irb] Print deprecation warning for `help` command
(https://github.com/ruby/irb/pull/567)

* Give show_doc its own command class

* Print deprecation warning for `help` command
2023-05-18 03:28:31 +00:00
Stan Lo e7f77e1e89 [ruby/irb] Simplify command method definition
(https://github.com/ruby/irb/pull/559)

* Remove unnecessary command argument generation code

Now that all the supported Ruby versions handle splat args and splat kwargs,
we don't need that args generation code anymore.

* Remove unused command definition code

If we look at `@EXTEND_COMMANDS`, all commands are defined in a file, which
means the `if load_file` branch is always executed. Therefore we can drop
the else branch of that condition.

* Avoid defining unnecessary command methods

There's no need to define another command method just to call `Command.execute`.
2023-04-08 10:11:50 +00:00
Stan Lo 2f8e5c80e6 [ruby/irb] Drop Ruby 2.6 support
(https://github.com/ruby/irb/pull/555)

* Remove all Ruby 2.6 support

* Drop Ruby 2.6 specific testing conditions

* Only run Ruby 2.7+ on CI

* Bump Ruby requirement to 2.7+

https://github.com/ruby/irb/commit/3f714b616c
2023-04-05 21:40:40 +00:00
Stan Lo cd94bcdc46 [ruby/irb] Don't check RUBY_ENGINE when deciding whether to accept kargs
Ruby implementations like JRuby and TruffleRuby already indicate their
compatibility target with RUBY_VERSION. We don't need to exclude
them from accepting keyword arguments as long as they target 2.7+.

https://github.com/ruby/irb/commit/bf20faa4e6

Co-authored-by: Kevin Menard <kevin@nirvdrum.com>
2023-04-02 15:34:28 +00:00
Stan Lo f25791884c [ruby/irb] Remove dead code (https://github.com/ruby/irb/pull/554)
* Remove unused ATTR_TTY and ATTR_PLAIN constants

They were added in d7d26b51bf

But the references were removed in 1c76845cca

Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>

* Remove unused MethodExtender module

It was added in 6cc5d718d7
but it's not used anywhere.

Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>

* Remove unused IRB.irb_at_exit

It's not used after aaf4eb4e98

Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>

* Remove unused InputCompletor.ignored_modules

It was added in 88311ce3c8
but the reference was removed in 78c74d2425

* Remove unused TracerLoadError constant

This constant was added in cb50fa3738
but never referenced.

---------

https://github.com/ruby/irb/commit/7de0234325

Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
2023-04-02 14:11:12 +00:00
Stan Lo 207f8d0027 [ruby/irb] Avoid calling private methods on the main object
(https://github.com/ruby/irb/pull/498)

When the main object is frozen, `IRB` wraps a `SimpleDelegator` around it.
But because `SimpleDelegator` doesn't delegate private methods, methods like
`require_relative` or `const_get` would cause error, which are needed for
lazily loading commands.

This commit works around this limitation by avoiding those private method calls
when setting up command execution.
2023-01-12 11:49:16 +00:00
Hiroshi SHIBATA 7e283c585e [ruby/irb] Formatting to header styles
https://github.com/ruby/irb/commit/cef125850d
2023-01-11 22:29:10 +00:00
Hiroshi SHIBATA c7bb8d67b7 [ruby/irb] Removed Release Version and Revisions for old VCS software
https://github.com/ruby/irb/commit/07fae94862
2023-01-11 22:29:09 +00:00
Stan Lo c9076d546a [ruby/irb] Add show_doc as an alias to the help command
(https://github.com/ruby/irb/pull/475)

In the long-term, we want to align with `Pry`, `byebug` and `debug` to
use the `help` command to list all commands, which is what `show_cmds`
currently does. And `show_doc` will be the command to look up Ruby APIs.

By aliasing `show_doc` to the current `help` now, users will have time
to get use to it.
2022-12-08 21:46:55 +00:00
Stan Lo 3956bb859c [ruby/irb] Add "show_cmds" command to list all commands'
descriptions
(https://github.com/ruby/irb/pull/463)

https://github.com/ruby/irb/commit/7e857655ac
2022-12-08 19:10:23 +00:00
Takashi Kokubun c9fbc779a6 [ruby/irb] Add commands to start and use the debugger
(https://github.com/ruby/irb/pull/449)

* Seamlessly integrate a few debug commands

* Improve the break command support

* Utilize skip_src option if available

* Add step and delete commands

* Write end-to-end tests for each debugger command

* Add documentation

* Add backtrace, info, catch commands

https://github.com/ruby/irb/commit/976100c1c2
2022-11-21 08:46:27 +00:00
Stan Lo 180ed611b2 [ruby/irb] Add edit command (https://github.com/ruby/irb/pull/453)
* Add edit command

* Make find_source a public singleton method

* Add document for the edit command

* Make find_end private

* Remove duplicated private

https://github.com/ruby/irb/commit/4321674aa7
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2022-11-20 04:47:54 +00:00
Takashi Kokubun 5958c305e5 [ruby/irb] Document a full list of commands
(https://github.com/ruby/irb/pull/451)

* Document a full list of commands

* Document debug as well

* Make it less duplicated
2022-11-19 22:14:44 +00:00
Stan Lo 00872d120b [ruby/irb] Add debug command (https://github.com/ruby/irb/pull/446)
https://github.com/ruby/irb/commit/30faa13fa3
2022-11-18 09:11:23 +00:00
Takashi Kokubun 9001e53e68 [ruby/irb] Support non-string input in show_source
(https://github.com/ruby/irb/pull/430)

* Support non-string input in show_source

* Test show_source as a method
2022-11-07 17:29:28 +00:00
Kaíque Kandy Koga d880322243 [ruby/irb] Update remark of self.install_extend_commands.
Create line

https://github.com/ruby/irb/commit/64d6a461d5
2022-10-05 19:15:28 +09:00
manga_osyo b6b2e489f1 [ruby/irb] Changed to call Kernel.print
If you call `binding.irb` on a class defined `#print`, it will crash, so call `Kernel.print`.

Fix [Bug #18389] `binding.irb` can fail in some classes that implement `context` and `print` methods.

https://github.com/ruby/irb/commit/d54b271984
2022-01-27 01:28:52 +09:00
st0012 e53962b9e1 [ruby/irb] Use require_relative to load extensions/commands
https://github.com/ruby/irb/commit/d5060f7668
2022-01-17 21:09:36 +09:00
Takashi Kokubun 9e336f73fb [ruby/irb] Add show_source command
https://github.com/ruby/irb/commit/108cb04352
2021-04-02 16:40:06 +09:00
Takashi Kokubun 232433f224 [ruby/irb] Add whereami command
https://github.com/ruby/irb/commit/bc822e4aac
2021-03-21 13:40:21 +09:00
Takashi Kokubun 5f72962a09 [ruby/irb] Implement ls command
https://github.com/ruby/irb/commit/19b6c20604
2021-03-21 12:59:51 +09:00
aycabta 0428c2e7df [ruby/irb] Define "measure" command without forced override
https://github.com/ruby/irb/commit/9587ba13b5
2021-03-19 23:34:34 +09:00
Nobuyoshi Nakada 4b6e3f7b82
irb: Define extension command on the given object 2020-12-20 19:35:59 +09:00
Nobuyoshi Nakada feea436feb
irb: Define extension command only on the given object
Not to interfer in class variables.
2020-12-20 18:26:38 +09:00
aycabta 9f08e3c703 [ruby/irb] Add measure command
You can use "measure" command to check performance in IRB like below:

  irb(main):001:0> 3
  => 3
  irb(main):002:0> measure
  TIME is added.
  => nil
  irb(main):003:0> 3
  processing time: 0.000058s
  => 3
  irb(main):004:0> measure :off
  => nil
  irb(main):005:0> 3
  => 3

You can set "measure :on" by "IRB.conf[:MEASURE] = true" in .irbrc, and, also,
set custom performance check method:

  IRB.conf[:MEASURE_PROC][:CUSTOM] = proc { |context, code, line_no, &block|
    time = Time.now
    result = block.()
    now = Time.now
    puts 'custom processing time: %fs' % (Time.now - time) if IRB.conf[:MEASURE]
    result
  }

https://github.com/ruby/irb/commit/3899eaf2e2
2020-12-20 16:23:59 +09:00
Nobuyoshi Nakada 3198e7abd7
Separate `send` into `public_send` and `__send__` 2020-10-27 16:12:45 +09:00
aycabta 7e5253d15e [ruby/irb] Suppress "method redefined" warning
https://github.com/ruby/irb/commit/5f0aee56fa
2020-04-29 19:13:14 +09:00
aycabta 98a346d065 [ruby/irb] Add irb_info command
https://github.com/ruby/irb/commit/a6fe58e916
2020-04-29 19:13:14 +09:00
Nobuyoshi Nakada e68999c82c
Fixed misspellings
Fixed misspellings reported at [Bug #16437], for default gems.
2019-12-20 12:19:45 +09:00
Nobuyoshi Nakada a506b7f35a Adjusted indents and supplied last commas
Fixed unmatched indent of the closing bracket for
`:irb_current_working_workspace`, and adjusted following elements.
2019-08-28 16:08:14 +09:00
hsbt 6a08beef51 Removed math mode from irb.
mathn is deprecated from Ruby 2.2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-20 09:11:36 +00:00
naruse 3e92b635fb Add frozen_string_literal: false for all files
When you change this to true, you may need to add more tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16 05:07:31 +00:00
hsbt 76515504d5 * lib/irb.rb: removed commented-out code.
* lib/irb/**/*.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-09 02:02:58 +00:00
hsbt 8e5af8b628 * lib/cmath.rb: fixed indent.
* lib/drb/ssl.rb: ditto.
* lib/irb/**/*.rb: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-09 01:36:49 +00:00
zzak 7e9eb32669 * lib/irb.rb, lib/irb/*: Documentation for IRB
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-21 05:45:50 +00:00
zzak 8983315238 * lib/irb*: merge doc from doc/irb/ird.rd and improve overall
documentation of IRB
* doc/irb/irb.rd: remove stale documentation


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-13 05:22:30 +00:00
nobu b271ca8c62 * lib/irb/extend-command.rb (def_extend_command): fixed argument
number for negative arity.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-05 01:18:28 +00:00
keiju c7fa0c727c * bin/irb, lib/irb.rb lib/irb/*: irb-0.9.6, extend inspect-mode
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23985 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-07 11:36:20 +00:00
nobu 287a34ae0d * {ext,lib,test}/**/*.rb: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-06 03:56:38 +00:00
mame cba52ec37c * lib/irb/extend-command.rb (def_extend_command): check number of
arguments.  [ruby-dev:35074]

* lib/irb/ext/multi-irb.rb (search): check if a corresponding job is
  found.  [ruby-dev:35074]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 13:41:11 +00:00
matz e6c1752137 * lib/rdoc.rb: massive spelling correction patch from Evan Farrar
<evanfarrar at gmail.com> in [ruby-doc:1382] applied.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-04 09:37:38 +00:00
akr 6cdef2dc7e * $Date$ keyword removed to avoid inclusion of locale dependent
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 15:49:38 +00:00
matz 7e5324e6c1 * lib/irb/extend-command.rb (IRB::ExtendCommandBundle): pacify
RDoc.  a patch from Eric Hodel <drbrain at segment7.net>.
  [ruby-core:08522]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-08-08 15:17:06 +00:00
keiju 622b522047 * bin/irb lib/irb.rb lib/irb/...: IRB 0.9.5.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-04-13 15:27:09 +00:00