Commit graph

81 commits

Author SHA1 Message Date
Stan Lo
57ca5960ad [ruby/irb] Restructure workspace management
(https://github.com/ruby/irb/pull/888)

* Remove dead irb_level method

* Restructure workspace management

Currently, workspace is an attribute of IRB::Context in most use cases.
But when some workspace commands are used, like `pushws` or `popws`, a
workspace will be created and used along side with the original workspace
attribute.

This complexity is not necessary and will prevent us from expanding
multi-workspace support in the future.

So this commit introduces a @workspace_stack ivar to IRB::Context so IRB
can have a more natural way to manage workspaces.

* Fix pushws without args

* Always display workspace stack after related commands are used

61560b99b3
2024-03-01 15:51:29 +00:00
tomoya ishida
ea2fb7460e [ruby/irb] Remove useless loaded file check
(https://github.com/ruby/irb/pull/885)

f6d489658e
2024-02-23 13:11:20 +00:00
Stan Lo
4831bb5bab [ruby/irb] Turn on frozen literal in files
(https://github.com/ruby/irb/pull/881)

83d90550c2
2024-02-23 10:53:53 +00:00
Stan Lo
37dde6e2f8 [ruby/irb] Unroll extension method generation
(https://github.com/ruby/irb/pull/882)

* Unroll extension method generation

Given we only have 2 remaining extension setter methods, both of which
only take 1 argument and don't have any alias, the current method generation
logic is overly complicated.

This commit simplifies the method generation logic by simply defining
the methods directly in the `IRB::Context` class.

* Fix use_loader extension

67eba5401b
2024-02-23 10:02:19 +00:00
Stan Lo
f5801e2bf4 [ruby/irb] Standardize command related names
(https://github.com/ruby/irb/pull/873)

* Replace ExtendCommand with Command and standardize command related names

1. Rename lib/irb/extend-command.rb to lib/irb/command.rb
2. Rename lib/irb/cmd/*.rb to lib/irb/command/*.rb
3. Rename test/irb/test_cmd.rb to test/irb/test_command.rb
4. Rename ExtendCommand to Command

* Alias ExtendCommand to Command and deprecate it

* Rename Command::Nop to Command::Base

* Not deprecate old constants just yet

* Add lib/irb/cmd/nop.rb back

462c1284af
2024-02-16 16:47:36 +00:00
Stan Lo
ec26786b1a [ruby/irb] Refactor eval_path and SourceFinder::Source
(https://github.com/ruby/irb/pull/870)

* Assign `@eval_path` through `irb_path=` method

This simplifies the original caching logic for the `eval_path` method
and makes it easier to understand.

* Refactor SourceFinder::Source

c63e4c4035
2024-02-13 13:33:36 +00:00
Stan Lo
5f4245e74b [ruby/irb] Polish tracer integration and tests
(https://github.com/ruby/irb/pull/864)

* Remove useless ivar

* Simplify tracer test setup

* Treat tracer like a normal development dependency

* Only require ext/tracer when value is truthy

* Make tracer integration skip IRB traces

a97a4129a7
2024-02-07 14:59:10 +00:00
Nuno Silva
300dee1fe8 [ruby/irb] Fix usage of tracer gem and add tests
(https://github.com/ruby/irb/pull/857)

The new tests are skipped when ruby below 3.1, as it was a default gem on it, and in a version we do not support.

This also move definition of `use_tracer` to module Context instead of monkey patch.

08834fbd5f
2024-02-06 16:46:50 +00: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
45ff2f4a89 [ruby/irb] Refactor ExtendCommand::Nop
(https://github.com/ruby/irb/pull/598)

* Rename conf to irb_context

* Drop Nop#irb method because it's only used by irb/ext/loader.rb

We don't need to expose this method to all command classes, especially
when it's just an alias of `irb_context.irb`.
2023-06-05 19:12:16 +00:00
Yusuf Daniju
ec211ad54d [ruby/irb] fix typo in tracer (https://github.com/ruby/irb/pull/565)
2f567f3d3e
2023-04-23 18:41:40 +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+

3f714b616c
2023-04-05 21:40:40 +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.

---------

7de0234325

Co-authored-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
2023-04-02 14:11:12 +00:00
Stan Lo
cbac0fa4cb [ruby/irb] Remove unused context argument from Worksapce#evaluate
(https://github.com/ruby/irb/pull/488)

The context argument was introduced in this change:

6806669d17 (diff-296327851fb7a2c307c2d0693b769f58c01aaf315972f290500d10081ee200a9)

perhaps for potential usages. But after that it's never used.
2023-02-18 11:34:28 +00:00
Hiroshi SHIBATA
7e283c585e [ruby/irb] Formatting to header styles
cef125850d
2023-01-11 22:29:10 +00:00
Hiroshi SHIBATA
c7bb8d67b7 [ruby/irb] Removed Release Version and Revisions for old VCS software
07fae94862
2023-01-11 22:29:09 +00:00
Nobuyoshi Nakada
d532d27507 [ruby/irb] Use class methods of File over Kernel.open
e0ec5e1bd8
2022-11-30 10:18:57 +00:00
st0012
4f348e482c [ruby/irb] Rename leftover Reidline references
0ed8b103ed
2022-11-15 10:08:28 +00:00
st0012
b97e909ef4 [ruby/irb] Remove unnecessary Thread presence check
They were introduced around 20 years ago, when Thread is not yet
stabilized. So we don't need them anymore.

4c75e03b2b
2022-10-03 07:00:53 +09:00
Nobuyoshi Nakada
f863bc505c [ruby/irb] Fix the error when LC_MESSAGES config value is nil
6bbde84369
2022-09-14 11:14:08 +09:00
Jeremy Evans
9299db49f5 [ruby/irb] Fix history file saving with concurrent irb sessions when history file doesn't exist
If history file didn't exist when irb was started, @loaded_history_mtime
would be nil.  However, if the history file didn't exist before, but it
exists when saving history, that means the history file was modified,
and we should handle it the same way as we handle the other case where
the history file was modified.

Fixes #388

8d277aafcb
2022-09-14 10:15:45 +09:00
Jeremy Evans
14e1739ff3 [ruby/irb] Make save-history extension safe for concurrent use
This makes the save-history extension check for modifications to
the history file before saving it.  If the history file was modified
after the history was loaded and before it was saved, append only
the new history lines to the history file.

This can result in more lines in the history file than SAVE_HISTORY
allows.  However, that will be fixed the next time irb is run and
the history is saved.

Fixes [Bug #13654]

041ef53845
2021-03-06 00:18:32 +09:00
Nobuyoshi Nakada
b83b27cddb [ruby/irb] Fix inverse separator condition
33f933196f
2021-02-12 00:02:16 +09:00
aycabta
d77a42fbfd [ruby/irb] Suppress error when File::ALT_SEPARATOR is nil
96accf3b95
2021-02-11 20:27:25 +09:00
Nobuyoshi Nakada
f6387ae073 Fix absolute path predicate on Windows
A path starts with '/' is not an absolute path on Windows, because
of drive letter or UNC.
2021-01-29 10:26:18 +09:00
Nobuhiro IMAI
5b05b85d85 [ruby/irb] add IRB::FileInputMethod.open to ensure closing associated File
* tweak some methods not to raise exception after `#close`
* use it in `IRB::IrbLoader#{source_file,load_file}

ec2947acbd
2021-01-27 15:01:57 +09:00
aycabta
8882927036 [ruby/irb] Discard newlines at end of file
0b2773d91d
2020-08-28 11:05:18 +09:00
Nobuyoshi Nakada
7fa86de15b [ruby/irb] Workaround a bug of ruby-mode.el
6dfd59400d
2020-08-18 14:38:01 +09:00
Nobuyoshi Nakada
82d4da7816 [ruby/irb] Yet another unnecessary readline
933841af11
2020-08-18 14:38:01 +09:00
aycabta
126e1fc296 [ruby/irb] Make history infinite if set SAVE_HISTORY to negative
824473e880
2020-08-18 14:38:01 +09:00
aycabta
ef498a016b [ruby/irb] Suppress crash when bignum is set to SAVE_HISTORY
5044eb2730
2020-08-18 14:38:01 +09:00
Nobuyoshi Nakada
bc646e6715
[DOC] get rid of parsing as TIDYLINK unintentionally 2020-04-07 13:59:38 +09:00
aycabta
8c3efa4940 Use Reline.encoding_system_needs if exists 2020-01-14 15:40:38 +09:00
aycabta
51ea1abb5f Remove e2mmap dependency 2019-11-25 05:38:09 +09:00
aycabta
1aeb201d28 Remove debug code... 2019-11-24 23:29:09 +09:00
aycabta
745ab16818 Disable tracer ext of IRB when tracer doesn't found 2019-11-24 22:42:08 +09:00
zverok
4fe06f4667 IRB: Document command evaluation history. 2019-10-26 10:24:20 -07:00
aycabta
48fdc37ad5 IRB's multiline history is enable only when Reidline mode 2019-08-22 05:09:08 +09:00
Jeremy Evans
a06301b103 Ignore history file without saving if permissions cannot be changed
Fixes [Ruby Bug 13907]
2019-07-27 16:56:04 +09:00
aycabta
0af897ab59 Simplify history saving code 2019-07-15 10:20:23 +09:00
aycabta
17ccda5413 Use #to_a for Readline::HISTORY directly 2019-07-15 08:33:07 +09:00
aycabta
266f6cd8a1 Remove debug print 2019-07-15 07:54:47 +09:00
aycabta
4b7a04a5b8 Support multiline irb_history
A history line ends with "\" to escape newline if it's a continuous
line.
2019-07-15 07:51:57 +09:00
Masataka Pocke Kuwabara
9806da50f4 Suppress warnings 2019-07-15 00:13:01 +09:00
Sutou Kouhei
29c16b30ce Add support for history with Reline backend 2019-05-27 06:32:52 +09:00
marcandre
e859e668d2 lib/*: Prefer require_relative over require.
[#15206] [Fix GH-1976]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-02 17:52:33 +00:00
kazu
6064132c42 Remove unnecessary require 'thread'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-08 07:00:01 +00: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
hsbt
589169cb78 * lib/irb/ext/save-history.rb: Fix NoMethodError when method is not defined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-15 11:27:38 +00:00