Commit graph

764 commits

Author SHA1 Message Date
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
Takashi Kokubun
d6b2b5bd47 [ruby/irb] Add missing require
This is useful if you want to use IRB::ColorPrinter as a library like:

```
begin
  require 'irb/color_printer'
  IRB::ColorPrinter.pp(obj)
rescue LoadError
  pp(obj)
end
```

f8461691c7
2021-01-07 22:35:12 -08:00
aycabta
559f844bf4 irb: Drop lines from backtrace for tests in Ruby repository 2021-01-08 13:25:18 +09:00
Nobuhiro IMAI
ed3264d37a [ruby/irb] refactoring an error handling in IRB::Inspector
* moved rescue clause to `#inspect_value` to catch all failures in inspectors
* test with all (currently five kind of) inspect modes
  - tweaked the input due to only `Marshal` can inspect(dump) a `BasicObject`

9d112fab8e
2021-01-08 13:25:18 +09:00
Nobuhiro IMAI
f594775230 [ruby/irb] do not escape a predicate method for doc namespace
* Fixes #88

d431a30af4
2021-01-08 13:25:18 +09:00
Nobuyoshi Nakada
903af74bbd [ruby/irb] Ensure to restore $VERBOSE
cef474a76a
2021-01-05 18:07:18 +09:00
aycabta
0123bc9d38 [ruby/irb] Use error tokens if there are no correct tokens in the same place
For example, the broken code "%www" will result in only one error token.

9fa39a7cf3
2021-01-05 18:06:43 +09:00
aycabta
5a1866caff [ruby/irb] Use Ripper::Lexer#scan to take broken tokens
ref. https://github.com/ruby/reline/pull/242

54f90cb6c9
2021-01-05 18:06:34 +09:00
aycabta
505e01fe12 [ruby/irb] Heredoc may contain multiple newlines in a single token
Use the start token as the indentation criteria so that it works properly in
heredoc.

ref. https://github.com/ruby/reline/pull/242

9704808dfd
2021-01-05 18:06:26 +09:00
aycabta
5012512398 [ruby/irb] Handle indentations related to keyword "do" correctly
This fixes ruby/irb#158.

964643400b
2021-01-05 18:06:10 +09:00
aycabta
cce72a2411 [ruby/irb] Newline in oneliner def doesn't reset indent
This closes ruby/irb#132.

43456dcf5e
2021-01-05 18:04:45 +09:00
aycabta
515d6b47ad [ruby/irb] Stringify when a non-object is passed to PP#text
If a nested object is passed to #pp, it may be sometimes passed to the #text
method as an object without being stringified.

This is fixed on the Ruby main repository;
433a3be86a
but it was a bug of Ripper so still needs this workaround for using irb
as a gem on Ruby 3.0.0 or earlier.

Co-authored-by: k0kubun <takashikkbn@gmail.com>

8d13df22ee
2021-01-04 20:14:31 -08:00
Takashi Kokubun
6d07785127 [ruby/irb] Remove unnecessary ignore_error in dispatch_seq
Just forgotten in a5804c3560

e42e548793
2020-12-28 23:29:29 -08:00
Takashi Kokubun
f30a3a0629
[ruby/irb] Do not colorize partially-correct inspect
This is to prevent a yellow-mixed output for ActiveSupport::TimeWithZone.

Follows up https://github.com/ruby/irb/pull/159 and https://github.com/ruby/ruby/pull/3967.

a5804c3560
2020-12-28 23:29:08 -08:00
Nobuhiro IMAI
9b7ceb6765
irb: add more syntax errors colorizing support (#3967) 2020-12-28 23:07:20 -08:00
Takashi Kokubun
f9e80af28a [ruby/irb] Add color_printer.rb to gemspec
b4df0fd8b2
2020-12-28 23:01:01 -08:00
Takashi Kokubun
c715fb46c2 [ruby/irb] Enhance colored inspect output
dffcdb5269
2020-12-28 23:01:00 -08:00
aycabta
32616229e3 [ruby/irb] Version 1.3.0
ec83280e66
2020-12-25 01:29:18 +09:00
aycabta
167dc37632 [ruby/irb] Try not to register the exact same measuring method twice
cc66b5573e
2020-12-24 23:26:22 +09:00
aycabta
28e9344fa4 [ruby/irb] Change StdioInputMethod#eof? to non-blocking
This fixes --inf-ruby-mode.

0e4a818955
2020-12-23 22:08:30 +09:00
aycabta
31bd172185 [ruby/irb] Suppress "shadowing outer" warning
8b83fbef69
2020-12-23 21:26:25 +09:00
aycabta
841d22ea47 [ruby/reline] [ruby/irb] Handle multiple newlines in a token correctly
Co-authored-by: manga_osyo <manga.osyo@gmail.com>
Co-authored-by: ima1zumi <mariimaizumi5@gmail.com>

c59a9be82f

a7922da16b
2020-12-23 06:06:07 +09:00
Takeru Naito
be5faa2519 [ruby/irb] Make it possible to use measure even if it is installed as gem
Include the file that implements this command in the irb gem.

Co-Authored-By: scivola <scivola@users.noreply.github.com>

d8dfea5b57
2020-12-23 06:06:07 +09:00
aycabta
0b14abe8e7 [ruby/irb] Suppress "shadowing outer" warning
27b149c599
2020-12-22 23:45:43 +09:00
aycabta
fbcdcbff0d [ruby/irb] Version 1.2.9
9668e5fe6b
2020-12-22 23:45:43 +09:00
aycabta
4131cd05be [ruby/irb] Support arg for measure command
b43f35d8f3
2020-12-22 23:45:43 +09:00
aycabta
47b26795d0 [ruby/irb] Change variables handling for compatibility
26fd1a75cf
2020-12-22 23:45:43 +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
24fcbc92b4 [ruby/irb] Version 1.2.8
bcd96834c7
2020-12-20 16:23:59 +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
  }

3899eaf2e2
2020-12-20 16:23:59 +09:00
aycabta
8b6aaeaddf [ruby/irb] Handle rest of tokens correctly if no newline at last
f3c8edad2a
2020-12-20 16:23:58 +09:00
aycabta
dc61affd67 [ruby/reline] [ruby/irb] Call ripper only once when generating dynamic prompt
babb122a48

e6dbcb3b42
2020-12-19 02:12:11 +09:00
Marc-Andre Lafortune
980f994b3b [ruby/irb] Change context-mode's default to new mode 4.
This new mode uses a copy of the TOPLEVEL_BINDING. This is compatible with refinements (contrary to mode 3), while keeping nested IRB sessions separate

25c731cb2f
2020-12-17 20:24:08 +09:00
Jeremy Evans
753222d72c [ruby/irb] Enable deprecation warnings when using -W or -w
Requested in Ruby Bug 17377

698f6eb34a
2020-12-17 20:23:49 +09:00
Nobuyoshi Nakada
b5effe07bd [ruby/irb] Fixed a typo in a comment [ci skip]
ce373417f3
2020-12-17 20:22:55 +09:00
Nobuhiro IMAI
cbf6a7f906 [ruby/irb] workaround for lack of tokens from Ripper.lex
* Fixes #38

905fb8e52e
2020-12-17 20:22:29 +09:00
Benoit Daloze
afb8aba4af [ruby/irb] Add a fallback for check_code_block that does not depend on implementation-private APIs
* Fixes https://github.com/ruby/irb/issues/133

5eb3ef3293
2020-11-22 21:00:11 +09:00
Nobuhiro IMAI
5218f17737 [ruby/irb] support more body argument for oneliner method definition
2ff1295533
2020-11-22 21:00:11 +09:00
NARUSE, Yui
3407b7d8a6 Revert "Prefer #send over #__send__ when it is clear there is no possible conflict"
This reverts commit 4dba0c1a8e.

Matz's comment is "send is not deprecated. __send__ is safer".
But "Prefer #send over #__send__" is not reasonable.
2020-11-05 20:54:34 +09:00
Benoit Daloze
4dba0c1a8e Prefer #send over #__send__ when it is clear there is no possible conflict
* Reverts part of 3198e7abd7.
* If the rule is #send should be deprecated, that should be ruled by matz,
  there is no such rule currently and gems seem to prefer #send
  overwhelmingly.
2020-11-05 11:23:27 +01:00
Nobuyoshi Nakada
3198e7abd7
Separate send into public_send and __send__ 2020-10-27 16:12:45 +09:00