Commit graph

14659 commits

Author SHA1 Message Date
Mari Imaizumi
639449fe8d [ruby/reline] Implement changing editing mode
(https://github.com/ruby/reline/pull/681)

501b9a6c5f
2024-04-16 11:58:49 +00:00
Mari Imaizumi
0a4e3f23e6 [ruby/reline] Remove not implemented method
(https://github.com/ruby/reline/pull/680)

84762fc588
2024-04-15 13:31:38 +00:00
tomoya ishida
43f4da3ebf [ruby/reline] Fix vi_to_column which was broken
(https://github.com/ruby/reline/pull/679)

9e93ad52e7
2024-04-15 13:15:58 +00:00
Nobuyoshi Nakada
fc363944b4 [ruby/optparse] bump up to 0.5.0
f5018a8b1c
2024-04-15 05:06:46 +00:00
Koichi Sasada
9180e33ca3 show warning for unused block
With verbopse mode (-w), the interpreter shows a warning if
a block is passed to a method which does not use the given block.

Warning on:

* the invoked method is written in C
* the invoked method is not `initialize`
* not invoked with `super`
* the first time on the call-site with the invoked method
  (`obj.foo{}` will be warned once if `foo` is same method)

[Feature #15554]

`Primitive.attr! :use_block` is introduced to declare that primitive
functions (written in C) will use passed block.

For minitest, test needs some tweak, so use
ea9caafc07
for `test-bundled-gems`.
2024-04-15 12:08:07 +09:00
Mari Imaizumi
339128b190 [ruby/reline] Refactored Default Key Bindings
(https://github.com/ruby/reline/pull/678)

* Reduce duplicate method

* Configured default key mapping with Readline when the method exists

* Remove undefined methods

155f7047bb
2024-04-14 17:33:51 +00:00
tomoya ishida
1648c4436e [ruby/reline] Refactor waiting_proc and waiting_operator_proc
(https://github.com/ruby/reline/pull/649)

* Fix waiting_proc precedence

* Fix waiting_operator bugs

* Add waiting_proc and vi_waiting_operator test

* Fix vi waiting operator arg number

vi_arg and vi_waiting_operator_arg should be multiplied

* Implement `yy` copies whole line in vi_command mode

* Simplify incremental search cancel test

* Add complex vi test with waiting_proc and vi_waiting_operator, split test input

777dffae1c
2024-04-14 14:28:15 +00:00
Stan Lo
04ba96e619 [ruby/irb] Allow defining custom commands in IRB
(https://github.com/ruby/irb/pull/886)

This is a feature that has been requested for a long time. It is now
possible to define custom commands in IRB.

Example usage:

```ruby
require "irb/command"

class HelloCommand < IRB::Command::Base
  description "Prints hello world"
  category "My commands"
  help_message "It doesn't do more than printing hello world."

  def execute
    puts "Hello world"
  end
end

IRB::Command.register(:hello, HelloCommand)
```

888643467c
2024-04-14 11:01:43 +00:00
Michael J. Giarlo
76b10f2ee1 [ruby/reline] Support menu-complete-backward command for upward
navigation
(https://github.com/ruby/reline/pull/677)

Fixes https://github.com/ruby/reline/pull/675

This commit extracts the upward navigation condition in `LineEditor#input_key` to a new private method, and adds a new alias. This change allows Reline to support upward navigation in when a user has configured `inputrc` to map Shift-Tab to `menu-complete-backward`, a common setting in Bash (>= 4.x).

Instead of special-casing upward navigation in `LineEditor#input_key`, we now allow it to be processed by the branch that calls `process_key`. The extracted method no longer includes the editing mode check since this check is already made by `#wrap_method_call` by the time `#completion_journey_up` (or `#menu_complete_backward`) is called. Since upward navigation is happening in a method other than `#input_key` now, the `completion_occurs` variable that used to be local to `#input_key` is changed to an instance variable so that the new method can change its value. (I see many examples of mutating such instance variables in `LineEditor`, so I assumed this would be an uncontroversial change consistent with the coding practices already in place.)

Test coverage of this change has been added to the emacs and vi `KeyActor` tests.

Many thanks to @ima1zumi for their very helpful comments on #675 which encouraged me to contribute this work!

2ccdb374a4
2024-04-14 09:13:20 +00:00
Stan Lo
0924ff2d39 [ruby/prism] Fix parser translation's heredoc whitespace calculation
Given this example:

```rb
<<~HEREDOC
  #{x}
HEREDOC
```

Both the parser gem and Prism's translation layer would generate the following AST:

```
s(:dstr,
  s(:begin,
    s(:int, 1)),
  s(:str, " a\n"))
```

However, the parser gem inserts a empty string node into this node's location, like:

```
<Parser::Source::Map::Heredoc:0x0000000104ce73b8
 @expression=#<Parser::Source::Range (string) 0...10>,
 @heredoc_body=#<Parser::Source::Range (string) 11...20>,
 @heredoc_end=#<Parser::Source::Range (string) 20...27>,
 @node=s(:dstr,
  s(:str, ""),
  s(:begin,
    s(:int, 1)),
  s(:str, " a\n"))>
```

This is required to calculate the correct whitespace for the heredoc body.

We need to adjust the translation layer to account for this.

With this fix, we also won't need to ignore the tilde heredoc fixture anymore.

e7372e3ba5
2024-04-12 13:55:35 +00:00
David Marshall
a64a42ae38 [rubygems/rubygems] bundle add --glob continued- quote glob value invocation in specs, add banner text for CLI recommending single quotes
6d2cf955f9
2024-04-12 13:31:43 +00:00
David Marshall
c4b5f3f142 [rubygems/rubygems] bundler CLI option for add gem --glob=
Bundler online documentation says that if the gem is located within a subdirectory of a git repository,
you can use the `:glob` option to specify the location of its .gemspec

`gem 'cf-copilot', git: 'https://github.com/cloudfoundry/copilot', glob: 'sdk/ruby/*.gemspec'`

This change allows for equivalent functionality from the bundler CLI

`bundle add cf-copilot --git=https://github.com/cloudfoundry/copilot --glob=sdk/ruby/*.gemspec`

91052e5868
2024-04-12 13:31:43 +00:00
Stan Lo
f1d9e895b9 [ruby/irb] Pass statements to Context#evaluate
(https://github.com/ruby/irb/pull/920)

This has a few benefits:

- We can keep hiding the evaluation logic inside the Context level, which
  has always been the convention until #824 was merged recently.
- Although not an official API, gems like `debug` and `mission_control-jobs`
  patch `Context#evaluate` to wrap their own logic around it. This implicit
  contract was broken after #824, and this change restores it.

In addition to the refactor, I also converted some context-level evaluation
tests into integration tests, which are more robust and easier to maintain.

b32aee4068
2024-04-12 12:01:03 +00:00
Cody Cutrer
c5e661b1d7 [rubygems/rubygems] Fix installing plugins via relative paths
This affected both CLI and Gemfile installs

a0d101a8df
2024-04-11 19:35:28 +00:00
Kevin Newton
cd516ebd20 [ruby/prism] Add Location#chop
5dd57f4b84
2024-04-11 18:53:30 +00:00
Stan Lo
38e3819be6 [ruby/irb] Add a workaround to make IRB work with debug's tests
(https://github.com/ruby/irb/pull/919)

eb442c4dda
2024-04-10 23:16:32 +00:00
Stan Lo
d75dc39880 [ruby/irb] Centralize rstrip calls
(https://github.com/ruby/irb/pull/918)

97898b6251
2024-04-10 17:33:44 +00:00
tomoya ishida
6a505d1b59 [ruby/irb] Command implementation not by method
(https://github.com/ruby/irb/pull/824)

* Command is not a method

* Fix command test

* Implement non-method command name completion

* Add test for ExtendCommandBundle.def_extend_command

* Add helper method install test

* Remove spaces in command input parse

* Remove command arg unquote in help command

* Simplify Statement and handle execution in IRB::Irb

* Tweak require, const name

* Always install CommandBundle module to main object

* Remove considering local variable in command or expression check

* Remove unused method, tweak

* Remove outdated comment for help command arg

Co-authored-by: Stan Lo <stan001212@gmail.com>

---------

8fb776e379

Co-authored-by: Stan Lo <stan001212@gmail.com>
2024-04-10 16:52:53 +00:00
Taketo Takashima
f9f25d0ed0 [ruby/ipaddr] Added IPAddr#wildcard_mask
2093cebc1d
2024-04-10 10:30:53 +00:00
Mari Imaizumi
6846b98576 [ruby/reline] Bump version to 0.5.1
(https://github.com/ruby/reline/pull/672)

d348df90d2
2024-04-09 13:47:23 +00:00
Nobuyoshi Nakada
8217fbf4bd [ruby/tmpdir] Display the offending parent path in the exception
7751b12e97
2024-04-08 11:05:40 +00:00
Masataka Pocke Kuwabara
76914d474d Fix error when default gem is loaded from -r option
This patch fixes an error when a default gem that will be migrated to
a bundled gem is loaded from `-r` option.

Problem
===

`bundle exec ruby -rostruct -e ''` unexpectedly raises the following error:

```console
$ ruby -v
ruby 3.4.0dev (2024-04-08T02:39:00Z master 6f7e8e278f) [arm64-darwin21]
$ bundle init && bundle install
$ bundle exec ruby -rostruct -e ''
/Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/bundled_gems.rb:111:in 'Gem::BUNDLED_GEMS.warning?': undefined method 'find' for nil (NoMethodError)

      caller = caller_locations(3, 3).find {|c| c&.absolute_path}
                                     ^^^^^
        from /Users/kuwabara.masataka/.rbenv/versions/trunk/lib/ruby/3.4.0+0/bundled_gems.rb:75:in 'block (2 levels) in Kernel#replace_require'
```

Solution
===

This patch uses a safe navigation operator to fix this problem. By this
change, the command will show the warning message correctly.

```console
$ bundle exec ruby -rostruct -e ''
warning: ostruct was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.5.0. Add ostruct to your Gemfile or gemspec.
```
2024-04-08 15:48:26 +09:00
Mari Imaizumi
c2d02a6ac2 [ruby/reline] Continue processing even if terminfo database couldn't
be found
(https://github.com/ruby/reline/pull/673)

Fix https://github.com/ruby/reline/issues/447 https://github.com/ruby/reline/issues/543

This problem occurs when Fiddle can be loaded, curses can be loaded, and TERM is not registered in Terminfo.
It should also occur at hardcopy terminals and when Terminfo information is low, but no such reports have been received.

Reline should not abort the process because of missing Terminfo.
Reline proceeds with `Reline::Terminfo.enabled? == false` when fiddle or curses cannot be loaded.
And does the same when Terminfo is present but TERM is not.
ebab2875f1/lib/reline/terminfo.rb (L156-L160)

You can check the operation with `TERM=foo bundle exec bin/console`.

4ce247ce2b
2024-04-06 09:24:53 +00:00
Kevin Newton
f2ac26d914 [ruby/prism] Bump to v0.25.0
4da514456f
2024-04-05 21:44:06 +00:00
Joshua Broughton
f87e60f1f4 [ruby/irb] Filter backtrace before format in handle_exception
(https://github.com/ruby/irb/pull/916)

handle_exception now applies the filter_backtrace to exception
backtraces prior to formatting the lines with Exception#full_message

This fixes a bug in upstream projects, notably Rails, where the
backtrace filtering logic expects the lines to be formatted as
Exception#backtrace.

805ee008f9

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
2024-04-05 16:25:52 +00:00
tomoya ishida
4e48d2724e
[ruby/reline] Thread safe readline
(https://github.com/ruby/reline/pull/669)

Block until other Reline.readline or Reline.readmultiline finish

ebab2875f1
2024-04-05 09:34:28 +09:00
tomoya ishida
4cbe4e49c7
[ruby/reline] Always call finalize and deprep
(https://github.com/ruby/reline/pull/668)

91b030caa4
2024-04-05 09:34:28 +09:00
Kevin Newton
f45c9dbe87 [ruby/prism] Fix up some comments in the parser compiler
e2147cddd8
2024-04-04 15:29:10 -04:00
tomoya ishida
8088c88d01
[ruby/reline] Handle INT signal correctly, remove handle_cleared
because clear(C-l) is not a signal
(https://github.com/ruby/reline/pull/646)

3debb0ae2f
2024-04-04 17:18:47 +09:00
tomoya ishida
80e31663f3
[ruby/reline] Fix audoindent including "\v", escape "\v" for
rendering
(https://github.com/ruby/reline/pull/648)

9c51c577ca
2024-04-04 17:18:47 +09:00
Hiroshi SHIBATA
0930231361 [rubygems/rubygems] Allow to use String keys some of configuration
ee0bef2786
2024-04-04 11:30:02 +09:00
Hiroshi SHIBATA
0be7133b7f [rubygems/rubygems] Re-order configuraiton keys
b2a88983db
2024-04-04 11:30:01 +09:00
Hiroshi SHIBATA
25e28559c1 Ignore warnings on the bundled gems repo 2024-04-03 18:07:31 +09:00
Hiroshi SHIBATA
e651395210 Warn pstore for Ruby 3.5 2024-04-02 18:34:10 +09:00
Yuta Saito
8b55aaa85c [Feature #20345] Add --target-rbconfig option to mkmf
Introduce a new mkmf option `--target-rbconfig` to specify the RbConfig
file for the deployment target platform. This option is useful for
cross-compiling Ruby extensions without faking the global top-level
`RbConfig` constant.
2024-04-02 14:24:54 +09:00
Hiroshi SHIBATA
4db7c8a24a Warn ostruct for Ruby 3.5 2024-04-02 11:22:14 +09:00
tomoya ishida
a531cac335 [ruby/reline] Refactor completion
(https://github.com/ruby/reline/pull/647)

* Refactor completion: split autocompletion and tabcompletion logic and state

* Move completion candidate listup logic from dialog proc to LineEditor

c3c09ac9c2
2024-04-01 18:12:27 +00:00
tomoya ishida
508bddc865 [ruby/reline] Align completion menu items
(https://github.com/ruby/reline/pull/613)

a622704f62
2024-04-01 16:25:26 +00:00
David Rodriguez
e2a1d0b53d [rubygems/rubygems] Improve error message when strict resolution filters out everything
1ea44b3749
2024-04-01 15:03:28 +00:00
David Rodriguez
f80bb3837c [rubygems/rubygems] Keep unfiltered versions separately
7b5cc51a96
2024-04-01 15:03:27 +00:00
David Rodriguez
bfdbdf7aae [rubygems/rubygems] No need to check for root package every time
6ca192649f
2024-04-01 15:03:27 +00:00
David Rodriguez
b6ac37c91a [rubygems/rubygems] No need for any version prioritization when building errors
We just need to filter versions belonging to the range, but don't need
anything else.

8355a225d7
2024-04-01 15:03:26 +00:00
David Rodriguez
caaafbc35e [rubygems/rubygems] Make it look more like BasicPackageSource
bb5727934c
2024-04-01 15:03:26 +00:00
David Rodriguez
d69ef1cc52 [rubygems/rubygems] Let GemVersionPromoter sort in preferred order directly
So that we don't need to reverse the Array.

aeea5e2e00
2024-04-01 15:03:25 +00:00
David Rodriguez
2b82b7d192 [rubygems/rubygems] Update docs
ac24a68486
2024-04-01 15:03:25 +00:00
David Rodriguez
0a1e36964d [rubygems/rubygems] Remove unnecessary filtering
We do that when first caching versions, and then it's no longer
necessary.

ede15847db
2024-04-01 15:03:25 +00:00
David Rodriguez
acbd91e47f [rubygems/rubygems] No need to sort twice when filling versions
13294528c4
2024-04-01 15:03:24 +00:00
David Rodriguez
d342937e01 [rubygems/rubygems] Rename method for clarity
And also so that it matches the method used by main PubGrub sample
resolver class.

0e612361b8
2024-04-01 15:03:24 +00:00
David Rodriguez
3ca0683529 [rubygems/rubygems] Fix typo
0ddf25e5aa
2024-04-01 15:03:23 +00:00
Ellen Marie Dash
174b671699 [rubygems/rubygems] [commands/rebuild] Remove unused DATE_FORMAT constant.
3c4e3fadc9
2024-03-31 02:37:13 +00:00