Commit graph

764 commits

Author SHA1 Message Date
Masataka Pocke Kuwabara
e8c2b03ee1 [ruby/irb] Fix error on ls object_cant_define_singleton
such as `ls 42`, `ls :sym` and so on

b1d436a853
2021-06-30 20:55:18 +09:00
Takashi Kokubun
35c7e83bb3 [ruby/irb] Optimize show_source command further
https://github.com/ruby/irb/pull/249 actually slowed down how `code` is
concatenated. The original way of creating `code` is faster.

[before]
    user     system      total        real
2.420137   0.005364   2.425501 (  2.426264)

[after]
    user     system      total        real
1.000221   0.007454   1.007675 (  1.008295)

Theoretically, this implementation might skip lines that don't appear in
Ripper tokens, but this assumes such lines don't impact whether the code
passes compilation or not. At least normal blank lines seem to have an
`on_ignored_nl` token anyway though.

27dd2867cd
2021-06-27 10:52:49 +09:00
Masataka Pocke Kuwabara
6eb7c663c6 [ruby/irb] Improve performance of show_source for large class
2b79e9ad21
2021-06-27 10:36:11 +09:00
Keiko Kaneko
de779f4a62 [ruby/irb] Sort ls result ordered by anscestry
fdd5c0a71e
2021-06-22 22:32:42 +09:00
Ulysse Buonomo
5cc11845b2 [ruby/irb] Improve stackprof measure
Allow usage of more detailed args when setting stackprof callback.

Signed-off-by: Ulysse Buonomo <buonomo.ulysse@gmail.com>

c9d101f450
2021-06-21 18:03:49 +09:00
aycabta
c2f30aaade [ruby/irb] Version 1.3.6
75aa8d159b
2021-06-21 17:35:46 +09:00
Mark Delk
b8ffb1c46f [ruby/irb] respect NO_COLOR environment variable
When `NO_COLOR` is set to any non-nil value, output is not colorized.

See https://no-color.org/

401d0916fe
2021-05-24 11:55:58 +09:00
aycabta
eef406acf4 [ruby/irb] IRB should use the latest Reline, 0.2.5
34496e20e8
2021-05-15 19:12:57 +09:00
Masataka Pocke Kuwabara
de96ae9b71 [ruby/irb] Dump ancestors' methods by ls command
73edff287c
2021-05-08 14:00:40 +09:00
ima1zumi
b2c54f5395 [ruby/irb] Need reline >= 0.1.6
irb 1.3.5 need reline >= 0.1.6 because irb use `Reline::IOGate.in_pasting?`.
This method defined after reline 0.1.6.

fix #228.

6b7b8fc324
2021-04-30 20:46:50 +09:00
Nobuyoshi Nakada
8fdc45c894 [ruby/irb] Added colorable keyword option
Currently `IRB::Color.colorize` and `IRB::Color.colorize_code`
refer `$stdin.tty?` internally.
This patch adds `colorable` keyword option which overrides it.

402e3f1907
2021-04-26 21:14:52 +09:00
Ryuta Kamizono
fc24b0736e [ruby/irb] Fix typo ture -> true [ci skip]
783a0569e8
2021-04-26 21:13:42 +09:00
Nobuyoshi Nakada
9e940eae60
[ruby/irb] Moved development dependencies to Gemfile
As expressions in a gemspec file are evaluated at the build time,
but not the run time, the conditional in the gemspec will not work
as intended.

42f364ea23
2021-04-08 21:41:00 +09:00
Nobuyoshi Nakada
3816157e5d [ruby/irb] Ripper::Lexer::Elem#state is defined since Ruby 2.5
And the required ruby version is 2.5 or later.

ac496d4c78
2021-04-08 20:42:14 +09:00
aycabta
bacb646169 [ruby/irb] Check WITH_VTERM env to add vterm gem as dependency
23c8b73cb1
2021-04-04 22:39:16 +09:00
aycabta
281c6f5055 [ruby/irb] Use vterm 0.0.5 or newer on Unix like OSes because suppresses SEGV
b034bd22b0
2021-04-03 20:21:09 +09:00
aycabta
f079318187 [ruby/irb] Use yamatanooroti gem for tests
f053f49c29
2021-04-03 20:21:02 +09:00
aycabta
3ffb04474a [ruby/irb] Version 1.3.5
22e2ddf715
2021-04-03 01:25:58 +09:00
aycabta
ab89c45b90 [ruby/irb] Evaluate each toplevel statement
bc1b1d8bc3
2021-04-03 01:17:08 +09:00
Cody Cutrer
3cab8c087f [ruby/irb] process multi-line pastes as a single entity
this allows pasting leading-dot chained methods correctly:

```ruby
class A
  def a; self; end
  def b; true; end
end

a = A.new

a
 .a
 .b
```

will properly return `true` instead of erroring on the `.a` line:

```
irb(main):001:1*     class A
irb(main):002:1*       def a; self; end
irb(main):003:0>     end
irb(main):004:0*
irb(main):005:0>     a = A.new
irb(main):006:0*
irb(main):007:0>     a
irb(main):008:0>      .a
irb(main):009:0>      .a
=> #<A:0x00007f984211fbe8>
```

45aeb52575
2021-04-03 00:49:29 +09:00
Takashi Kokubun
9e336f73fb [ruby/irb] Add show_source command
108cb04352
2021-04-02 16:40:06 +09:00
Nobuyoshi Nakada
79af8ce6d7 [ruby/irb] Colorize __END__ as keyword
9b84018311
2021-04-02 10:52:53 +09:00
Aleksandar Ivanov
d65d661151 [ruby/irb] Prevent the completion from crashing if rdoc is missing
There are cases where ruby is installed without rdoc and e.g.
lib/irb/cmd/help.rb also handles the LoadError

Here is how to replicate the issue:

```
$ docker run -it alpine:3.13.3 sh

/ # apk add ruby ruby-irb ruby-io-console

/ # irb

irb(main):001:0> Class[TAB][TAB]
```

And you end up with something like:

```
irb(main):001:0> ClassTraceback (most recent call last):
        34: from /usr/bin/irb:23:in `<main>'
        33: from /usr/bin/irb:23:in `load'
        32: from /usr/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        31: from /usr/lib/ruby/2.7.0/irb.rb:400:in `start'
        30: from /usr/lib/ruby/2.7.0/irb.rb:471:in `run'
        29: from /usr/lib/ruby/2.7.0/irb.rb:471:in `catch'
        28: from /usr/lib/ruby/2.7.0/irb.rb:472:in `block in run'
        27: from /usr/lib/ruby/2.7.0/irb.rb:537:in `eval_input'
        26: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:150:in `each_top_level_statement'
        25: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:150:in `catch'
        24: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:151:in `block in each_top_level_statement'
        23: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:151:in `loop'
        22: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:154:in `block (2 levels) in each_top_level_statement'
        21: from /usr/lib/ruby/2.7.0/irb/ruby-lex.rb:182:in `lex'
        20: from /usr/lib/ruby/2.7.0/irb.rb:518:in `block in eval_input'
        19: from /usr/lib/ruby/2.7.0/irb.rb:704:in `signal_status'
        18: from /usr/lib/ruby/2.7.0/irb.rb:519:in `block (2 levels) in eval_input'
        17: from /usr/lib/ruby/2.7.0/irb/input-method.rb:294:in `gets'
        16: from /usr/lib/ruby/2.7.0/forwardable.rb:235:in `readmultiline'
        15: from /usr/lib/ruby/2.7.0/forwardable.rb:235:in `readmultiline'
        14: from /usr/lib/ruby/2.7.0/reline.rb:175:in `readmultiline'
        13: from /usr/lib/ruby/2.7.0/reline.rb:238:in `inner_readline'
        12: from /usr/lib/ruby/2.7.0/reline.rb:238:in `loop'
        11: from /usr/lib/ruby/2.7.0/reline.rb:239:in `block in inner_readline'
        10: from /usr/lib/ruby/2.7.0/reline.rb:270:in `read_io'
         9: from /usr/lib/ruby/2.7.0/reline.rb:270:in `loop'
         8: from /usr/lib/ruby/2.7.0/reline.rb:311:in `block in read_io'
         7: from /usr/lib/ruby/2.7.0/reline.rb:240:in `block (2 levels) in inner_readline'
         6: from /usr/lib/ruby/2.7.0/reline.rb:240:in `each'
         5: from /usr/lib/ruby/2.7.0/reline.rb:241:in `block (3 levels) in inner_readline'
         4: from /usr/lib/ruby/2.7.0/reline/line_editor.rb:820:in `input_key'
         3: from /usr/lib/ruby/2.7.0/reline/line_editor.rb:608:in `complete'
         2: from /usr/lib/ruby/2.7.0/irb/completion.rb:269:in `block in <module:InputCompletor>'
         1: from /usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/usr/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- rdoc (LoadError)
```

a2d299c2ac
2021-03-30 14:27:51 +09:00
aycabta
ad8842c06d [ruby/irb] Cache completion files to require
612ebcb311
2021-03-25 18:54:02 +09:00
aycabta
0927756e58 [ruby/irb] Complete require and require_relative
1c61178b4c
2021-03-24 15:11:41 +09:00
aycabta
0259ee6008 [ruby/irb] Change ripper_lex_without_warning to a class method
d9f8abc17e
2021-03-24 14:39:50 +09:00
Takashi Kokubun
94254117ee [ruby/irb] Have some right padding
instead of filling out an entire line

6ac8f45f5f
2021-03-21 16:01:29 +09:00
Takashi Kokubun
75b38f1894 [ruby/irb] Fix step's argument
cols.size was calling Integer#size, which returns 8.

Fixing a bug of https://github.com/ruby/irb/pull/209

c93ae4be71
2021-03-21 15:50:53 +09:00
Takashi Kokubun
d0b044a842 [ruby/irb] Fix column overflow on ls output
6115754623
2021-03-21 15:19:04 +09:00
Takashi Kokubun
232433f224 [ruby/irb] Add whereami command
bc822e4aac
2021-03-21 13:40:21 +09:00
Takashi Kokubun
5f72962a09 [ruby/irb] Implement ls command
19b6c20604
2021-03-21 12:59:51 +09:00
Takashi Kokubun
278522f053 [ruby/irb] Don't call Ruby 2.4+'s String#pretty_print
89bcf107be
2021-03-20 20:25:32 +09:00
Takashi Kokubun
f9dc5db38e [ruby/irb] Add all lib files automatically
ecc82336b7
2021-03-20 07:36:21 +09:00
aycabta
0428c2e7df [ruby/irb] Define "measure" command without forced override
9587ba13b5
2021-03-19 23:34:34 +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
Jeremy Evans
2cc5827fdc [ruby/irb] Do not continue line if last expression is an endless range
Fixes [Bug #14824]

63414f8465
2021-03-05 22:03:05 +09:00
Jeremy Evans
dbea0be13d [ruby/irb] Update help message for next context-mode of 4
While here, fixing tab/space issues in help message, and sync
rdoc for IRB class to match the help message.

ef8e3901cc
2021-02-27 06:51:12 +09:00
aycabta
fda162c776 [ruby/irb] Version 1.3.4
ab9852ccc5
2021-02-25 22:11:48 +09:00
Nobuyoshi Nakada
b83b27cddb [ruby/irb] Fix inverse separator condition
33f933196f
2021-02-12 00:02:16 +09:00
aycabta
6eb5b3ac27 [ruby/irb] The command "irb_info" should show RUBY_PLATFORM
39d1cd874f
2021-02-11 20:36:43 +09:00
aycabta
b2d2d25b94 [ruby/irb] Suppress colorize on Windows tests
5be9354cf9
2021-02-11 20:31:29 +09:00
aycabta
d77a42fbfd [ruby/irb] Suppress error when File::ALT_SEPARATOR is nil
96accf3b95
2021-02-11 20:27:25 +09:00
aycabta
8aac11484b [ruby/irb] Version 1.3.3
4c87035b7c
2021-02-07 05:28:08 +09:00
aycabta
7b354cf67b [ruby/irb] Enable to reassign a new block with "measure" command
b444573aa2
2021-02-06 21:09:31 +09:00
aycabta
5704b5fe5e [ruby/irb] Allow "measure" command to take block
20f1ca23e9
2021-02-06 20:45:08 +09:00
ima1zumi
b79d443482 [ruby/irb] Add info.rb to gemspec
adbba19adf
2021-02-04 21:12:54 +09:00
Nobuhiro IMAI
b0fb208218 [ruby/irb] follow up the actual line number
7aed8fe3b1
2021-02-03 00:09:32 +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
e80e5a2f89 [ruby/irb] use RubyLex::TerminateLineInput appropriately [Bug #17564]
* using the appropriciate exception instead of `break` so that the session
  can be continue after the `irb_source` and `irb_load` commands
* suppress extra new line due to one more `#prompt` call

bdefaa7cfd
2021-01-27 15:02:05 +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