irb 1.7.1 → 1.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +1 -1
- data/Gemfile +10 -1
- data/README.md +265 -20
- data/Rakefile +13 -10
- data/doc/irb/irb.rd.ja +1 -3
- data/irb.gemspec +2 -1
- data/lib/irb/cmd/nop.rb +3 -52
- data/lib/irb/color.rb +4 -2
- data/lib/irb/command/backtrace.rb +17 -0
- data/lib/irb/command/base.rb +62 -0
- data/lib/irb/command/break.rb +17 -0
- data/lib/irb/command/catch.rb +17 -0
- data/lib/irb/command/chws.rb +40 -0
- data/lib/irb/command/context.rb +16 -0
- data/lib/irb/{cmd → command}/continue.rb +3 -3
- data/lib/irb/command/debug.rb +71 -0
- data/lib/irb/{cmd → command}/delete.rb +3 -3
- data/lib/irb/command/disable_irb.rb +19 -0
- data/lib/irb/command/edit.rb +63 -0
- data/lib/irb/command/exit.rb +18 -0
- data/lib/irb/{cmd → command}/finish.rb +3 -3
- data/lib/irb/command/force_exit.rb +18 -0
- data/lib/irb/command/help.rb +83 -0
- data/lib/irb/command/history.rb +45 -0
- data/lib/irb/command/info.rb +17 -0
- data/lib/irb/command/internal_helpers.rb +27 -0
- data/lib/irb/{cmd → command}/irb_info.rb +7 -7
- data/lib/irb/{cmd → command}/load.rb +23 -8
- data/lib/irb/{cmd → command}/ls.rb +42 -19
- data/lib/irb/{cmd → command}/measure.rb +18 -17
- data/lib/irb/{cmd → command}/next.rb +3 -3
- data/lib/irb/command/pushws.rb +65 -0
- data/lib/irb/command/show_doc.rb +51 -0
- data/lib/irb/command/show_source.rb +74 -0
- data/lib/irb/{cmd → command}/step.rb +3 -3
- data/lib/irb/command/subirb.rb +123 -0
- data/lib/irb/{cmd → command}/whereami.rb +3 -5
- data/lib/irb/command.rb +23 -0
- data/lib/irb/completion.rb +133 -102
- data/lib/irb/context.rb +182 -66
- data/lib/irb/debug/ui.rb +103 -0
- data/lib/irb/{cmd/debug.rb → debug.rb} +53 -59
- data/lib/irb/default_commands.rb +265 -0
- data/lib/irb/easter-egg.rb +16 -6
- data/lib/irb/ext/change-ws.rb +6 -8
- data/lib/irb/ext/{history.rb → eval_history.rb} +7 -7
- data/lib/irb/ext/loader.rb +4 -4
- data/lib/irb/ext/multi-irb.rb +5 -5
- data/lib/irb/ext/tracer.rb +12 -51
- data/lib/irb/ext/use-loader.rb +6 -8
- data/lib/irb/ext/workspaces.rb +10 -34
- data/lib/irb/frame.rb +1 -1
- data/lib/irb/help.rb +3 -3
- data/lib/irb/helper_method/base.rb +16 -0
- data/lib/irb/helper_method/conf.rb +11 -0
- data/lib/irb/helper_method.rb +29 -0
- data/lib/irb/{ext/save-history.rb → history.rb} +20 -58
- data/lib/irb/init.rb +154 -58
- data/lib/irb/input-method.rb +238 -203
- data/lib/irb/inspector.rb +3 -3
- data/lib/irb/lc/error.rb +1 -11
- data/lib/irb/lc/help-message +4 -0
- data/lib/irb/lc/ja/error.rb +1 -11
- data/lib/irb/lc/ja/help-message +13 -0
- data/lib/irb/locale.rb +2 -2
- data/lib/irb/nesting_parser.rb +13 -3
- data/lib/irb/notifier.rb +1 -1
- data/lib/irb/output-method.rb +2 -8
- data/lib/irb/pager.rb +91 -0
- data/lib/irb/ruby-lex.rb +391 -471
- data/lib/irb/ruby_logo.aa +43 -0
- data/lib/irb/source_finder.rb +139 -0
- data/lib/irb/statement.rb +80 -0
- data/lib/irb/version.rb +3 -3
- data/lib/irb/workspace.rb +24 -4
- data/lib/irb/ws-for-case-2.rb +1 -1
- data/lib/irb/xmp.rb +3 -3
- data/lib/irb.rb +1232 -604
- data/man/irb.1 +7 -0
- metadata +60 -32
- data/lib/irb/cmd/backtrace.rb +0 -21
- data/lib/irb/cmd/break.rb +0 -21
- data/lib/irb/cmd/catch.rb +0 -21
- data/lib/irb/cmd/chws.rb +0 -36
- data/lib/irb/cmd/edit.rb +0 -61
- data/lib/irb/cmd/help.rb +0 -23
- data/lib/irb/cmd/info.rb +0 -21
- data/lib/irb/cmd/pushws.rb +0 -45
- data/lib/irb/cmd/show_cmds.rb +0 -39
- data/lib/irb/cmd/show_doc.rb +0 -48
- data/lib/irb/cmd/show_source.rb +0 -113
- data/lib/irb/cmd/subirb.rb +0 -66
- data/lib/irb/extend-command.rb +0 -356
- data/lib/irb/src_encoding.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 243737997cdd6abe7e129eb7e7945dca379f1af38ed4254dfe094f2a611918cc
|
4
|
+
data.tar.gz: 5a1cbbdf5ab88a61278afe32a5497f38efa1342e123734ae3ede6135aae9b91f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b4e5d658e1eba4a0503ffd3776c3baffabb0782eb43a993aac593b6dc4383e9e209ca3c1f077c78225f612a1ac7607f951bc11a2ff8fd78a93e12029fbf1954
|
7
|
+
data.tar.gz: c9e978f318f22d322934b77b8c431830e67a9cb7cf365923041f77123ee5e7d39ffa814a4e7bdd9af759f4671d0b24bd2ae68a9d20beb54b4a0e4248e32ee85f
|
data/.document
CHANGED
data/Gemfile
CHANGED
@@ -15,4 +15,13 @@ gem "stackprof" if is_unix && !is_truffleruby
|
|
15
15
|
gem "reline", github: "ruby/reline" if ENV["WITH_LATEST_RELINE"] == "true"
|
16
16
|
gem "rake"
|
17
17
|
gem "test-unit"
|
18
|
-
gem "
|
18
|
+
gem "test-unit-ruby-core"
|
19
|
+
|
20
|
+
gem "rubocop"
|
21
|
+
|
22
|
+
gem "tracer" if !is_truffleruby
|
23
|
+
gem "debug", github: "ruby/debug", platforms: [:mri, :mswin]
|
24
|
+
|
25
|
+
if RUBY_VERSION >= "3.0.0" && !is_truffleruby
|
26
|
+
gem "repl_type_completor"
|
27
|
+
end
|
data/README.md
CHANGED
@@ -1,15 +1,36 @@
|
|
1
1
|
# IRB
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/irb.svg)](https://badge.fury.io/rb/irb)
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/irb.svg)](https://badge.fury.io/rb/irb)
|
4
4
|
[![build](https://github.com/ruby/irb/actions/workflows/test.yml/badge.svg)](https://github.com/ruby/irb/actions/workflows/test.yml)
|
5
5
|
|
6
6
|
IRB stands for "interactive Ruby" and is a tool to interactively execute Ruby expressions read from the standard input.
|
7
7
|
|
8
8
|
The `irb` command from your shell will start the interpreter.
|
9
9
|
|
10
|
+
- [Installation](#installation)
|
11
|
+
- [Usage](#usage)
|
12
|
+
- [The `irb` Executable](#the-irb-executable)
|
13
|
+
- [The `binding.irb` Breakpoint](#the-bindingirb-breakpoint)
|
14
|
+
- [Commands](#commands)
|
15
|
+
- [Debugging with IRB](#debugging-with-irb)
|
16
|
+
- [More about `debug.gem`](#more-about-debuggem)
|
17
|
+
- [Advantages Over `debug.gem`'s Console](#advantages-over-debuggems-console)
|
18
|
+
- [Type Based Completion](#type-based-completion)
|
19
|
+
- [How to Enable IRB::TypeCompletor](#how-to-enable-irbtypecompletor)
|
20
|
+
- [Advantage over Default IRB::RegexpCompletor](#advantage-over-default-irbregexpcompletor)
|
21
|
+
- [Difference between Steep's Completion](#difference-between-steeps-completion)
|
22
|
+
- [Configuration](#configuration)
|
23
|
+
- [Environment Variables](#environment-variables)
|
24
|
+
- [Documentation](#documentation)
|
25
|
+
- [Extending IRB](#extending-irb)
|
26
|
+
- [Development](#development)
|
27
|
+
- [Contributing](#contributing)
|
28
|
+
- [Releasing](#releasing)
|
29
|
+
- [License](#license)
|
30
|
+
|
10
31
|
## Installation
|
11
32
|
|
12
|
-
>
|
33
|
+
> [!Note]
|
13
34
|
>
|
14
35
|
> IRB is a default gem of Ruby so you shouldn't need to install it separately.
|
15
36
|
>
|
@@ -35,6 +56,10 @@ $ gem install irb
|
|
35
56
|
|
36
57
|
## Usage
|
37
58
|
|
59
|
+
> [!Note]
|
60
|
+
>
|
61
|
+
> We're working hard to match Pry's variety of powerful features in IRB, and you can track our progress or find contribution ideas in [this document](https://github.com/ruby/irb/blob/master/COMPARED_WITH_PRY.md).
|
62
|
+
|
38
63
|
### The `irb` Executable
|
39
64
|
|
40
65
|
You can start a fresh IRB session by typing `irb` in your terminal.
|
@@ -43,15 +68,15 @@ In the session, you can evaluate Ruby expressions or even prototype a small Ruby
|
|
43
68
|
|
44
69
|
```shell
|
45
70
|
$ irb
|
46
|
-
irb(main):001
|
71
|
+
irb(main):001> 1 + 2
|
47
72
|
=> 3
|
48
|
-
irb(main):002
|
49
|
-
irb(main):003
|
50
|
-
irb(main):004
|
51
|
-
irb(main):005
|
52
|
-
irb(main):006
|
73
|
+
irb(main):002* class Foo
|
74
|
+
irb(main):003* def foo
|
75
|
+
irb(main):004* puts 1
|
76
|
+
irb(main):005* end
|
77
|
+
irb(main):006> end
|
53
78
|
=> :foo
|
54
|
-
irb(main):007
|
79
|
+
irb(main):007> Foo.new.foo
|
55
80
|
1
|
56
81
|
=> nil
|
57
82
|
```
|
@@ -82,25 +107,33 @@ Hello World
|
|
82
107
|
|
83
108
|
## Commands
|
84
109
|
|
85
|
-
The following commands are available on IRB. You can get the same output from the `
|
110
|
+
The following commands are available on IRB. You can get the same output from the `help` command.
|
86
111
|
|
112
|
+
```txt
|
113
|
+
Help
|
114
|
+
help List all available commands. Use `help <command>` to get information about a specific command.
|
87
115
|
|
88
|
-
```
|
89
116
|
IRB
|
117
|
+
exit Exit the current irb session.
|
118
|
+
exit! Exit the current process.
|
119
|
+
irb_load Load a Ruby file.
|
120
|
+
irb_require Require a Ruby file.
|
121
|
+
source Loads a given file in the current session.
|
122
|
+
irb_info Show information about IRB.
|
123
|
+
history Shows the input history. `-g [query]` or `-G [query]` allows you to filter the output.
|
124
|
+
|
125
|
+
Workspace
|
90
126
|
cwws Show the current workspace.
|
91
127
|
chws Change the current workspace to an object.
|
92
128
|
workspaces Show workspaces.
|
93
129
|
pushws Push an object to the workspace stack.
|
94
130
|
popws Pop a workspace from the workspace stack.
|
95
|
-
|
96
|
-
|
97
|
-
source Loads a given file in the current session.
|
131
|
+
|
132
|
+
Multi-irb (DEPRECATED)
|
98
133
|
irb Start a child IRB.
|
99
134
|
jobs List of current sessions.
|
100
135
|
fg Switches to the session of the given number.
|
101
136
|
kill Kills the session with the given number.
|
102
|
-
irb_info Show information about IRB.
|
103
|
-
show_cmds List all available commands and their description.
|
104
137
|
|
105
138
|
Debugging
|
106
139
|
debug Start the debugger of debug.gem.
|
@@ -115,14 +148,194 @@ Debugging
|
|
115
148
|
info Start the debugger of debug.gem and run its `info` command.
|
116
149
|
|
117
150
|
Misc
|
118
|
-
edit Open a file
|
151
|
+
edit Open a file or source location.
|
119
152
|
measure `measure` enables the mode to measure processing time. `measure :off` disables it.
|
120
153
|
|
121
154
|
Context
|
122
155
|
show_doc Enter the mode to look up RI documents.
|
123
|
-
ls Show methods, constants, and variables.
|
156
|
+
ls Show methods, constants, and variables.
|
124
157
|
show_source Show the source code of a given method or constant.
|
125
158
|
whereami Show the source code around binding.irb again.
|
159
|
+
|
160
|
+
Aliases
|
161
|
+
$ Alias for `show_source`
|
162
|
+
@ Alias for `whereami`
|
163
|
+
```
|
164
|
+
|
165
|
+
## Debugging with IRB
|
166
|
+
|
167
|
+
Starting from version 1.8.0, IRB boasts a powerful integration with `debug.gem`, providing a debugging experience akin to `pry-byebug`.
|
168
|
+
|
169
|
+
After hitting a `binding.irb` breakpoint, you can activate the debugger with the `debug` command. Alternatively, if the `debug` method happens to already be defined in the current scope, you can call `irb_debug`.
|
170
|
+
|
171
|
+
```shell
|
172
|
+
From: test.rb @ line 3 :
|
173
|
+
|
174
|
+
1:
|
175
|
+
2: def greet(word)
|
176
|
+
=> 3: binding.irb
|
177
|
+
4: puts "Hello #{word}"
|
178
|
+
5: end
|
179
|
+
6:
|
180
|
+
7: greet("World")
|
181
|
+
|
182
|
+
irb(main):001> debug
|
183
|
+
irb:rdbg(main):002>
|
184
|
+
```
|
185
|
+
|
186
|
+
Once activated, the prompt's header changes from `irb` to `irb:rdbg`, enabling you to use any of `debug.gem`'s [commands](https://github.com/ruby/debug#debug-command-on-the-debug-console):
|
187
|
+
|
188
|
+
```shell
|
189
|
+
irb:rdbg(main):002> info # use info command to see available variables
|
190
|
+
%self = main
|
191
|
+
_ = nil
|
192
|
+
word = "World"
|
193
|
+
irb:rdbg(main):003> next # use next command to move to the next line
|
194
|
+
[1, 7] in test.rb
|
195
|
+
1|
|
196
|
+
2| def greet(word)
|
197
|
+
3| binding.irb
|
198
|
+
=> 4| puts "Hello #{word}"
|
199
|
+
5| end
|
200
|
+
6|
|
201
|
+
7| greet("World")
|
202
|
+
=>#0 Object#greet(word="World") at test.rb:4
|
203
|
+
#1 <main> at test.rb:7
|
204
|
+
irb:rdbg(main):004>
|
205
|
+
```
|
206
|
+
|
207
|
+
Simultaneously, you maintain access to IRB's commands, such as `show_source`:
|
208
|
+
|
209
|
+
```shell
|
210
|
+
irb:rdbg(main):004> show_source greet
|
211
|
+
|
212
|
+
From: test.rb:2
|
213
|
+
|
214
|
+
def greet(word)
|
215
|
+
binding.irb
|
216
|
+
puts "Hello #{word}"
|
217
|
+
end
|
218
|
+
```
|
219
|
+
|
220
|
+
### More about `debug.gem`
|
221
|
+
|
222
|
+
`debug.gem` offers many advanced debugging features that simple REPLs can't provide, including:
|
223
|
+
|
224
|
+
- Step-debugging
|
225
|
+
- Frame navigation
|
226
|
+
- Setting breakpoints with commands
|
227
|
+
- Thread control
|
228
|
+
- ...and many more
|
229
|
+
|
230
|
+
To learn about these features, please refer to `debug.gem`'s [commands list](https://github.com/ruby/debug#debug-command-on-the-debug-console).
|
231
|
+
|
232
|
+
In the `irb:rdbg` session, the `help` command will also display all commands from `debug.gem`.
|
233
|
+
|
234
|
+
### Advantages Over `debug.gem`'s Console
|
235
|
+
|
236
|
+
This integration offers several benefits over `debug.gem`'s native console:
|
237
|
+
|
238
|
+
1. Access to handy IRB commands like `show_source` or `show_doc`.
|
239
|
+
2. Support for multi-line input.
|
240
|
+
3. Symbol shortcuts such as `@` (`whereami`) and `$` (`show_source`).
|
241
|
+
4. Autocompletion.
|
242
|
+
5. Customizable prompt.
|
243
|
+
|
244
|
+
However, there are also some limitations to be aware of:
|
245
|
+
|
246
|
+
1. `binding.irb` doesn't support `pre` and `do` arguments like [`binding.break`](https://github.com/ruby/debug#bindingbreak-method).
|
247
|
+
2. As IRB [doesn't currently support remote-connection](https://github.com/ruby/irb/issues/672), it can't be used with `debug.gem`'s remote debugging feature.
|
248
|
+
3. Access to the previous return value via the underscore `_` is not supported.
|
249
|
+
|
250
|
+
## Type Based Completion
|
251
|
+
|
252
|
+
IRB's default completion `IRB::RegexpCompletor` uses Regexp. IRB has another experimental completion `IRB::TypeCompletor` that uses type analysis.
|
253
|
+
|
254
|
+
### How to Enable IRB::TypeCompletor
|
255
|
+
|
256
|
+
Install [ruby/repl_type_completor](https://github.com/ruby/repl_type_completor/) with:
|
257
|
+
```
|
258
|
+
$ gem install repl_type_completor
|
259
|
+
```
|
260
|
+
Or add these lines to your project's Gemfile.
|
261
|
+
```ruby
|
262
|
+
gem 'irb'
|
263
|
+
gem 'repl_type_completor', group: [:development, :test]
|
264
|
+
```
|
265
|
+
|
266
|
+
Now you can use type based completion by:
|
267
|
+
|
268
|
+
Running IRB with the `--type-completor` option
|
269
|
+
```
|
270
|
+
$ irb --type-completor
|
271
|
+
```
|
272
|
+
|
273
|
+
Or writing this line to IRB's rc-file (e.g. `~/.irbrc`)
|
274
|
+
```ruby
|
275
|
+
IRB.conf[:COMPLETOR] = :type # default is :regexp
|
276
|
+
```
|
277
|
+
|
278
|
+
Or setting the environment variable `IRB_COMPLETOR`
|
279
|
+
```ruby
|
280
|
+
ENV['IRB_COMPLETOR'] = 'type'
|
281
|
+
IRB.start
|
282
|
+
```
|
283
|
+
|
284
|
+
To check if it's enabled, type `irb_info` into IRB and see the `Completion` section.
|
285
|
+
```
|
286
|
+
irb(main):001> irb_info
|
287
|
+
...
|
288
|
+
# Enabled
|
289
|
+
Completion: Autocomplete, ReplTypeCompletor: 0.1.0, Prism: 0.18.0, RBS: 3.3.0
|
290
|
+
# Not enabled
|
291
|
+
Completion: Autocomplete, RegexpCompletor
|
292
|
+
...
|
293
|
+
```
|
294
|
+
If you have `sig/` directory or `rbs_collection.lock.yaml` in current directory, IRB will load it.
|
295
|
+
|
296
|
+
### Advantage over Default IRB::RegexpCompletor
|
297
|
+
|
298
|
+
IRB::TypeCompletor can autocomplete chained methods, block parameters and more if type information is available.
|
299
|
+
These are some examples IRB::RegexpCompletor cannot complete.
|
300
|
+
|
301
|
+
```ruby
|
302
|
+
irb(main):001> 'Ruby'.upcase.chars.s # Array methods (sample, select, shift, size)
|
303
|
+
```
|
304
|
+
|
305
|
+
```ruby
|
306
|
+
irb(main):001> 10.times.map(&:to_s).each do |s|
|
307
|
+
irb(main):002> s.up # String methods (upcase, upcase!, upto)
|
308
|
+
```
|
309
|
+
|
310
|
+
```ruby
|
311
|
+
irb(main):001> class User < ApplicationRecord
|
312
|
+
irb(main):002> def foo
|
313
|
+
irb(main):003> sa # save, save!
|
314
|
+
```
|
315
|
+
|
316
|
+
As a trade-off, completion calculation takes more time than IRB::RegexpCompletor.
|
317
|
+
|
318
|
+
### Difference between Steep's Completion
|
319
|
+
|
320
|
+
Compared with Steep, IRB::TypeCompletor has some difference and limitations.
|
321
|
+
```ruby
|
322
|
+
[0, 'a'].sample.
|
323
|
+
# Steep completes intersection of Integer methods and String methods
|
324
|
+
# IRB::TypeCompletor completes both Integer and String methods
|
325
|
+
```
|
326
|
+
|
327
|
+
Some features like type narrowing is not implemented.
|
328
|
+
```ruby
|
329
|
+
def f(arg = [0, 'a'].sample)
|
330
|
+
if arg.is_a?(String)
|
331
|
+
arg. # Completes both Integer and String methods
|
332
|
+
```
|
333
|
+
|
334
|
+
Unlike other static type checker, IRB::TypeCompletor uses runtime information to provide better completion.
|
335
|
+
```ruby
|
336
|
+
irb(main):001> a = [1]
|
337
|
+
=> [1]
|
338
|
+
irb(main):002> a.first. # Completes Integer methods
|
126
339
|
```
|
127
340
|
|
128
341
|
## Configuration
|
@@ -131,12 +344,20 @@ Context
|
|
131
344
|
|
132
345
|
- `NO_COLOR`: Assigning a value to it disables IRB's colorization.
|
133
346
|
- `IRB_USE_AUTOCOMPLETE`: Setting it to `false` disables IRB's autocompletion.
|
134
|
-
- `
|
347
|
+
- `IRB_COMPLETOR`: Configures IRB's auto-completion behavior, allowing settings for either `regexp` or `type`.
|
348
|
+
- `VISUAL`: Its value would be used to open files by the `edit` command.
|
349
|
+
- `EDITOR`: Its value would be used to open files by the `edit` command if `VISUAL` is unset.
|
135
350
|
- `IRBRC`: The file specified would be evaluated as IRB's rc-file.
|
136
351
|
|
137
352
|
## Documentation
|
138
353
|
|
139
|
-
https://
|
354
|
+
https://ruby.github.io/irb/
|
355
|
+
|
356
|
+
## Extending IRB
|
357
|
+
|
358
|
+
IRB `v1.13.0` and later versions allows users/libraries to extend its functionality through official APIs.
|
359
|
+
|
360
|
+
For more information, please visit [EXTEND_IRB.md](./EXTEND_IRB.md).
|
140
361
|
|
141
362
|
## Development
|
142
363
|
|
@@ -148,6 +369,30 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
148
369
|
|
149
370
|
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/irb.
|
150
371
|
|
372
|
+
### Set up the environment
|
373
|
+
|
374
|
+
1. Fork the project to your GithHub account
|
375
|
+
2. Clone the fork with `git clone git@github.com:[your_username]/irb.git`
|
376
|
+
3. Run `bundle install`
|
377
|
+
4. Run `bundle exec rake` to make sure tests pass locally
|
378
|
+
|
379
|
+
### Run integration tests
|
380
|
+
|
381
|
+
If your changes affect component rendering, such as the autocompletion's dialog/dropdown, you may need to run IRB's integration tests, known as `yamatanooroti`.
|
382
|
+
|
383
|
+
Before running these tests, ensure that you have `libvterm` installed. If you're using Homebrew, you can install it by running:
|
384
|
+
|
385
|
+
```bash
|
386
|
+
brew install libvterm
|
387
|
+
```
|
388
|
+
|
389
|
+
After installing `libvterm`, you can run the integration tests using the following commands:
|
390
|
+
|
391
|
+
```bash
|
392
|
+
WITH_VTERM=1 bundle install
|
393
|
+
WITH_VTERM=1 bundle exec rake test test_yamatanooroti
|
394
|
+
```
|
395
|
+
|
151
396
|
## Releasing
|
152
397
|
|
153
398
|
```
|
data/Rakefile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
require "rake/testtask"
|
3
|
+
require "rdoc/task"
|
3
4
|
|
4
5
|
Rake::TestTask.new(:test) do |t|
|
5
6
|
t.libs << "test" << "test/lib"
|
6
7
|
t.libs << "lib"
|
7
8
|
t.ruby_opts << "-rhelper"
|
8
|
-
t.test_files = FileList["test/irb
|
9
|
+
t.test_files = FileList["test/irb/**/test_*.rb"]
|
9
10
|
end
|
10
11
|
|
11
12
|
# To make sure they have been correctly setup for Ruby CI.
|
@@ -13,11 +14,11 @@ desc "Run each irb test file in isolation."
|
|
13
14
|
task :test_in_isolation do
|
14
15
|
failed = false
|
15
16
|
|
16
|
-
FileList["test/irb
|
17
|
+
FileList["test/irb/**/test_*.rb"].each do |test_file|
|
17
18
|
ENV["TEST"] = test_file
|
18
19
|
begin
|
19
20
|
Rake::Task["test"].execute
|
20
|
-
rescue
|
21
|
+
rescue
|
21
22
|
failed = true
|
22
23
|
msg = "Test '#{test_file}' failed when being executed in isolation. Please make sure 'rake test TEST=#{test_file}' passes."
|
23
24
|
separation_line = '=' * msg.length
|
@@ -41,11 +42,13 @@ Rake::TestTask.new(:test_yamatanooroti) do |t|
|
|
41
42
|
t.pattern = 'test/irb/yamatanooroti/test_*.rb'
|
42
43
|
end
|
43
44
|
|
44
|
-
task :sync_tool do
|
45
|
-
require 'fileutils'
|
46
|
-
FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
|
47
|
-
FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
|
48
|
-
FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
|
49
|
-
end
|
50
|
-
|
51
45
|
task :default => :test
|
46
|
+
|
47
|
+
RDoc::Task.new do |rdoc|
|
48
|
+
rdoc.title = "IRB"
|
49
|
+
rdoc.rdoc_files.include("*.md", "lib/**/*.rb")
|
50
|
+
rdoc.rdoc_files.exclude("lib/irb/xmp.rb")
|
51
|
+
rdoc.rdoc_dir = "docs"
|
52
|
+
rdoc.main = "README.md"
|
53
|
+
rdoc.options.push("--copy-files", "LICENSE.txt")
|
54
|
+
end
|
data/doc/irb/irb.rd.ja
CHANGED
@@ -125,7 +125,6 @@ irb起動時に``~/.irbrc''を読み込みます. もし存在しない場合は
|
|
125
125
|
|
126
126
|
IRB.conf[:PROMPT][:MY_PROMPT] = { # プロンプトモードの名前
|
127
127
|
:PROMPT_I => nil, # 通常のプロンプト
|
128
|
-
:PROMPT_N => nil, # 継続行のプロンプト
|
129
128
|
:PROMPT_S => nil, # 文字列などの継続行のプロンプト
|
130
129
|
:PROMPT_C => nil, # 式が継続している時のプロンプト
|
131
130
|
:RETURN => " ==>%s\n" # リターン時のプロンプト
|
@@ -140,7 +139,7 @@ OKです.
|
|
140
139
|
|
141
140
|
IRB.conf[:PROMPT_MODE] = :MY_PROMPT
|
142
141
|
|
143
|
-
PROMPT_I,
|
142
|
+
PROMPT_I, PROMPT_S, PROMPT_Cは, フォーマットを指定します.
|
144
143
|
|
145
144
|
%N 起動しているコマンド名が出力される.
|
146
145
|
%m mainオブジェクト(self)がto_sで出力される.
|
@@ -155,7 +154,6 @@ PROMPT_I, PROMPT_N, PROMPT_S, PROMPT_Cは, フォーマットを指定します.
|
|
155
154
|
|
156
155
|
IRB.conf[:PROMPT][:DEFAULT] = {
|
157
156
|
:PROMPT_I => "%N(%m):%03n:%i> ",
|
158
|
-
:PROMPT_N => "%N(%m):%03n:%i> ",
|
159
157
|
:PROMPT_S => "%N(%m):%03n:%i%l ",
|
160
158
|
:PROMPT_C => "%N(%m):%03n:%i* ",
|
161
159
|
:RETURN => "=> %s\n"
|
data/irb.gemspec
CHANGED
data/lib/irb/cmd/nop.rb
CHANGED
@@ -1,53 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
2
|
-
#
|
3
|
-
# nop.rb -
|
4
|
-
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
5
|
-
#
|
1
|
+
# frozen_string_literal: true
|
6
2
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
module ExtendCommand
|
11
|
-
class CommandArgumentError < StandardError; end
|
12
|
-
|
13
|
-
class Nop
|
14
|
-
class << self
|
15
|
-
def category(category = nil)
|
16
|
-
@category = category if category
|
17
|
-
@category
|
18
|
-
end
|
19
|
-
|
20
|
-
def description(description = nil)
|
21
|
-
@description = description if description
|
22
|
-
@description
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def string_literal?(args)
|
28
|
-
sexp = Ripper.sexp(args)
|
29
|
-
sexp && sexp.size == 2 && sexp.last&.first&.first == :string_literal
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.execute(irb_context, *opts, **kwargs, &block)
|
34
|
-
command = new(irb_context)
|
35
|
-
command.execute(*opts, **kwargs, &block)
|
36
|
-
rescue CommandArgumentError => e
|
37
|
-
puts e.message
|
38
|
-
end
|
39
|
-
|
40
|
-
def initialize(irb_context)
|
41
|
-
@irb_context = irb_context
|
42
|
-
end
|
43
|
-
|
44
|
-
attr_reader :irb_context
|
45
|
-
|
46
|
-
def execute(*opts)
|
47
|
-
#nop
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# :startdoc:
|
53
|
-
end
|
3
|
+
# This file is just a placeholder for backward-compatibility.
|
4
|
+
# Please require 'irb' and inherit your command from `IRB::Command::Base` instead.
|
data/lib/irb/color.rb
CHANGED
@@ -9,12 +9,14 @@ module IRB # :nodoc:
|
|
9
9
|
BOLD = 1
|
10
10
|
UNDERLINE = 4
|
11
11
|
REVERSE = 7
|
12
|
+
BLACK = 30
|
12
13
|
RED = 31
|
13
14
|
GREEN = 32
|
14
15
|
YELLOW = 33
|
15
16
|
BLUE = 34
|
16
17
|
MAGENTA = 35
|
17
18
|
CYAN = 36
|
19
|
+
WHITE = 37
|
18
20
|
|
19
21
|
TOKEN_KEYWORDS = {
|
20
22
|
on_kw: ['nil', 'self', 'true', 'false', '__FILE__', '__LINE__', '__ENCODING__'],
|
@@ -77,12 +79,12 @@ module IRB # :nodoc:
|
|
77
79
|
|
78
80
|
class << self
|
79
81
|
def colorable?
|
80
|
-
supported = $stdout.tty? && (/mswin|mingw
|
82
|
+
supported = $stdout.tty? && (/mswin|mingw/.match?(RUBY_PLATFORM) || (ENV.key?('TERM') && ENV['TERM'] != 'dumb'))
|
81
83
|
|
82
84
|
# because ruby/debug also uses irb's color module selectively,
|
83
85
|
# irb won't be activated in that case.
|
84
86
|
if IRB.respond_to?(:conf)
|
85
|
-
supported && IRB.conf.fetch(:USE_COLORIZE, true)
|
87
|
+
supported && !!IRB.conf.fetch(:USE_COLORIZE, true)
|
86
88
|
else
|
87
89
|
supported
|
88
90
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "debug"
|
4
|
+
|
5
|
+
module IRB
|
6
|
+
# :stopdoc:
|
7
|
+
|
8
|
+
module Command
|
9
|
+
class Backtrace < DebugCommand
|
10
|
+
def execute(arg)
|
11
|
+
execute_debug_command(pre_cmds: "backtrace #{arg}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# :startdoc:
|
17
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# nop.rb -
|
4
|
+
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
5
|
+
#
|
6
|
+
|
7
|
+
module IRB
|
8
|
+
# :stopdoc:
|
9
|
+
|
10
|
+
module Command
|
11
|
+
class CommandArgumentError < StandardError; end
|
12
|
+
|
13
|
+
def self.extract_ruby_args(*args, **kwargs)
|
14
|
+
throw :EXTRACT_RUBY_ARGS, [args, kwargs]
|
15
|
+
end
|
16
|
+
|
17
|
+
class Base
|
18
|
+
class << self
|
19
|
+
def category(category = nil)
|
20
|
+
@category = category if category
|
21
|
+
@category || "No category"
|
22
|
+
end
|
23
|
+
|
24
|
+
def description(description = nil)
|
25
|
+
@description = description if description
|
26
|
+
@description || "No description provided."
|
27
|
+
end
|
28
|
+
|
29
|
+
def help_message(help_message = nil)
|
30
|
+
@help_message = help_message if help_message
|
31
|
+
@help_message
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def highlight(text)
|
37
|
+
Color.colorize(text, [:BOLD, :BLUE])
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.execute(irb_context, arg)
|
42
|
+
new(irb_context).execute(arg)
|
43
|
+
rescue CommandArgumentError => e
|
44
|
+
puts e.message
|
45
|
+
end
|
46
|
+
|
47
|
+
def initialize(irb_context)
|
48
|
+
@irb_context = irb_context
|
49
|
+
end
|
50
|
+
|
51
|
+
attr_reader :irb_context
|
52
|
+
|
53
|
+
def execute(arg)
|
54
|
+
#nop
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
Nop = Base
|
59
|
+
end
|
60
|
+
|
61
|
+
# :startdoc:
|
62
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "debug"
|
4
|
+
|
5
|
+
module IRB
|
6
|
+
# :stopdoc:
|
7
|
+
|
8
|
+
module Command
|
9
|
+
class Break < DebugCommand
|
10
|
+
def execute(arg)
|
11
|
+
execute_debug_command(pre_cmds: "break #{arg}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# :startdoc:
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "debug"
|
4
|
+
|
5
|
+
module IRB
|
6
|
+
# :stopdoc:
|
7
|
+
|
8
|
+
module Command
|
9
|
+
class Catch < DebugCommand
|
10
|
+
def execute(arg)
|
11
|
+
execute_debug_command(pre_cmds: "catch #{arg}")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# :startdoc:
|
17
|
+
end
|