Commit graph

855 commits

Author SHA1 Message Date
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
aycabta
743c44ee21 [ruby/irb] Indent correctly with method calling with receiver
e7c68e74a0
2021-01-24 14:35:34 +09:00
aycabta
fc54af8aa1 [ruby/irb] Indent correctly with keyword "for" and "in"
47c83ea724
2021-01-24 14:35:26 +09:00
aycabta
fb33ec0119 [ruby/irb] Delete a doodle-level memo comment...
fc3e1d9e0c
2021-01-22 08:15:31 +09:00
Takashi Kokubun
1f87725cae [ruby/irb] Rescue Errno::EINVAL on IRB pp
20210119T070008Z.log.html.gz
is caused by:

/export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/reline/ansi.rb:157:in `winsize': Invalid argument - <STDIN> (Errno::EINVAL)
        from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/reline/ansi.rb:157:in `get_screen_size'
        from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/reline.rb:168:in `get_screen_size'
        from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/forwardable.rb:238:in `get_screen_size'
        from /export/home/chkbuild/chkbuild-gcc/tmp/build/20210119T150010Z/ruby/lib/irb/color_printer.rb:7:in `pp'
        from -e:1:in `<main>'

1719514598
2021-01-19 08:57:50 -08:00
Takashi Kokubun
82386f21b9 [ruby/irb] Use a real screen size for pp by default
9b9300dec2
2021-01-18 22:52:44 -08:00
aycabta
9f7876ab0f [ruby/irb] Version 1.3.2
a7699026cc
2021-01-18 02:13:07 +09:00
Nobuhiro IMAI
3f0b4665df [ruby/irb] handle __ENCODING__ as a keyword as well
a6a33d908f
2021-01-18 02:12:43 +09:00
aycabta
9fa478e38a [ruby/irb] Version 1.3.1
c230d08911
2021-01-13 01:12:54 +09:00
Takashi Kokubun
98bd7e87a0 [ruby/irb] Make IRB::ColorPrinter.pp compatible with PP.pp
The incompatible interface is not helpful, again if you want to use it
as a standalone library, falling it back to PP.

Original PP.pp also ends with `out << "\n"`.

4c74c7d84c
2021-01-07 22:43:40 -08:00