irb 1.7.1 → 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/irb.gemspec +1 -1
- data/lib/irb/cmd/show_cmds.rb +1 -1
- data/lib/irb/context.rb +28 -0
- data/lib/irb/ext/{history.rb → eval_history.rb} +4 -4
- data/lib/irb/extend-command.rb +1 -3
- data/lib/irb/{ext/save-history.rb → history.rb} +0 -51
- data/lib/irb/input-method.rb +6 -15
- data/lib/irb/version.rb +2 -2
- data/lib/irb.rb +1 -1
- metadata +6 -7
- 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: 9400febd023df0efde88c58ff524d4261ffe727404faf5cc719036e8691b7804
|
4
|
+
data.tar.gz: c46f543dc01f54f1ef6eaa37c2fdad212e06ffeecec0775e65f47423b68f8f7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecca8c833a94435b5d4b2abfea2669b9e6d688976d6010cff13f8440651c3379616b202e2be101bf78ac706ca108abe2b98871984e02f8a3f295522b6e820c0e
|
7
|
+
data.tar.gz: 7877a1a4857f5b9163745057d8a9fdf6440f40272b71699fc481c889520c40cf77f07e3f48488fec7d8ef086d89cf0463900bc8257ba72447bf3164595081f55
|
data/irb.gemspec
CHANGED
data/lib/irb/cmd/show_cmds.rb
CHANGED
@@ -14,7 +14,7 @@ module IRB
|
|
14
14
|
def execute(*args)
|
15
15
|
commands_info = IRB::ExtendCommandBundle.all_commands_info
|
16
16
|
commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] }
|
17
|
-
longest_cmd_name_length = commands_info.map { |c| c[:display_name]
|
17
|
+
longest_cmd_name_length = commands_info.map { |c| c[:display_name].length }.max
|
18
18
|
|
19
19
|
output = StringIO.new
|
20
20
|
|
data/lib/irb/context.rb
CHANGED
@@ -8,6 +8,7 @@ require_relative "workspace"
|
|
8
8
|
require_relative "inspector"
|
9
9
|
require_relative "input-method"
|
10
10
|
require_relative "output-method"
|
11
|
+
require_relative "history"
|
11
12
|
|
12
13
|
module IRB
|
13
14
|
# A class that wraps the current state of the irb session, including the
|
@@ -151,6 +152,27 @@ module IRB
|
|
151
152
|
@command_aliases = IRB.conf[:COMMAND_ALIASES]
|
152
153
|
end
|
153
154
|
|
155
|
+
def save_history=(val)
|
156
|
+
IRB.conf[:SAVE_HISTORY] = val
|
157
|
+
if val
|
158
|
+
(IRB.conf[:MAIN_CONTEXT] || self).init_save_history
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def save_history
|
163
|
+
IRB.conf[:SAVE_HISTORY]
|
164
|
+
end
|
165
|
+
|
166
|
+
# A copy of the default <code>IRB.conf[:HISTORY_FILE]</code>
|
167
|
+
def history_file
|
168
|
+
IRB.conf[:HISTORY_FILE]
|
169
|
+
end
|
170
|
+
|
171
|
+
# Set <code>IRB.conf[:HISTORY_FILE]</code> to the given +hist+.
|
172
|
+
def history_file=(hist)
|
173
|
+
IRB.conf[:HISTORY_FILE] = hist
|
174
|
+
end
|
175
|
+
|
154
176
|
# The top-level workspace, see WorkSpace#main
|
155
177
|
def main
|
156
178
|
@workspace.main
|
@@ -554,5 +576,11 @@ module IRB
|
|
554
576
|
command = command_aliases.fetch(command.to_sym, command)
|
555
577
|
ExtendCommandBundle.load_command(command)&.respond_to?(:transform_args)
|
556
578
|
end
|
579
|
+
|
580
|
+
def init_save_history# :nodoc:
|
581
|
+
unless (class<<@io;self;end).include?(HistorySavingAbility)
|
582
|
+
@io.extend(HistorySavingAbility)
|
583
|
+
end
|
584
|
+
end
|
557
585
|
end
|
558
586
|
end
|
@@ -40,14 +40,14 @@ module IRB # :nodoc:
|
|
40
40
|
#
|
41
41
|
# If +no+ is +nil+, execution result history isn't used (default).
|
42
42
|
#
|
43
|
-
#
|
44
|
-
# IRB::
|
43
|
+
# EvalHistory values are available via <code>__</code> variable, see
|
44
|
+
# IRB::EvalHistory.
|
45
45
|
def eval_history=(no)
|
46
46
|
if no
|
47
47
|
if defined?(@eval_history) && @eval_history
|
48
48
|
@eval_history_values.size(no)
|
49
49
|
else
|
50
|
-
@eval_history_values =
|
50
|
+
@eval_history_values = EvalHistory.new(no)
|
51
51
|
IRB.conf[:__TMP__EHV__] = @eval_history_values
|
52
52
|
@workspace.evaluate("__ = IRB.conf[:__TMP__EHV__]")
|
53
53
|
IRB.conf.delete(:__TMP_EHV__)
|
@@ -89,7 +89,7 @@ module IRB # :nodoc:
|
|
89
89
|
# __[1]
|
90
90
|
# # => 10
|
91
91
|
#
|
92
|
-
class
|
92
|
+
class EvalHistory
|
93
93
|
|
94
94
|
def initialize(size = 16) # :nodoc:
|
95
95
|
@size = size
|
data/lib/irb/extend-command.rb
CHANGED
@@ -316,10 +316,9 @@ module IRB # :nodoc:
|
|
316
316
|
CE = ContextExtender # :nodoc:
|
317
317
|
|
318
318
|
@EXTEND_COMMANDS = [
|
319
|
-
[:eval_history=, "ext/
|
319
|
+
[:eval_history=, "ext/eval_history.rb"],
|
320
320
|
[:use_tracer=, "ext/tracer.rb"],
|
321
321
|
[:use_loader=, "ext/use-loader.rb"],
|
322
|
-
[:save_history=, "ext/save-history.rb"],
|
323
322
|
]
|
324
323
|
|
325
324
|
# Installs the default context extensions as irb commands:
|
@@ -327,7 +326,6 @@ module IRB # :nodoc:
|
|
327
326
|
# Context#eval_history=:: +irb/ext/history.rb+
|
328
327
|
# Context#use_tracer=:: +irb/ext/tracer.rb+
|
329
328
|
# Context#use_loader=:: +irb/ext/use-loader.rb+
|
330
|
-
# Context#save_history=:: +irb/ext/save-history.rb+
|
331
329
|
def self.install_extend_commands
|
332
330
|
for args in @EXTEND_COMMANDS
|
333
331
|
def_extend_command(*args)
|
@@ -1,55 +1,4 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
#
|
3
|
-
# save-history.rb -
|
4
|
-
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
5
|
-
#
|
6
|
-
|
7
1
|
module IRB
|
8
|
-
module HistorySavingAbility # :nodoc:
|
9
|
-
end
|
10
|
-
|
11
|
-
class Context
|
12
|
-
def init_save_history# :nodoc:
|
13
|
-
unless (class<<@io;self;end).include?(HistorySavingAbility)
|
14
|
-
@io.extend(HistorySavingAbility)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# A copy of the default <code>IRB.conf[:SAVE_HISTORY]</code>
|
19
|
-
def save_history
|
20
|
-
IRB.conf[:SAVE_HISTORY]
|
21
|
-
end
|
22
|
-
|
23
|
-
remove_method(:save_history=) if method_defined?(:save_history=)
|
24
|
-
# Sets <code>IRB.conf[:SAVE_HISTORY]</code> to the given +val+ and calls
|
25
|
-
# #init_save_history with this context.
|
26
|
-
#
|
27
|
-
# Will store the number of +val+ entries of history in the #history_file
|
28
|
-
#
|
29
|
-
# Add the following to your +.irbrc+ to change the number of history
|
30
|
-
# entries stored to 1000:
|
31
|
-
#
|
32
|
-
# IRB.conf[:SAVE_HISTORY] = 1000
|
33
|
-
def save_history=(val)
|
34
|
-
IRB.conf[:SAVE_HISTORY] = val
|
35
|
-
if val
|
36
|
-
main_context = IRB.conf[:MAIN_CONTEXT]
|
37
|
-
main_context = self unless main_context
|
38
|
-
main_context.init_save_history
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# A copy of the default <code>IRB.conf[:HISTORY_FILE]</code>
|
43
|
-
def history_file
|
44
|
-
IRB.conf[:HISTORY_FILE]
|
45
|
-
end
|
46
|
-
|
47
|
-
# Set <code>IRB.conf[:HISTORY_FILE]</code> to the given +hist+.
|
48
|
-
def history_file=(hist)
|
49
|
-
IRB.conf[:HISTORY_FILE] = hist
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
2
|
module HistorySavingAbility # :nodoc:
|
54
3
|
def HistorySavingAbility.extended(obj)
|
55
4
|
IRB.conf[:AT_EXIT].push proc{obj.save_history}
|
data/lib/irb/input-method.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
|
5
5
|
#
|
6
6
|
|
7
|
-
require_relative 'src_encoding'
|
8
7
|
require_relative 'completion'
|
9
8
|
require 'io/console'
|
10
9
|
require 'reline'
|
@@ -256,8 +255,6 @@ module IRB
|
|
256
255
|
end
|
257
256
|
|
258
257
|
class RelineInputMethod < InputMethod
|
259
|
-
include Reline
|
260
|
-
|
261
258
|
# Creates a new input method object using Reline
|
262
259
|
def initialize
|
263
260
|
IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
|
@@ -270,9 +267,7 @@ module IRB
|
|
270
267
|
@stdin = ::IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
|
271
268
|
@stdout = ::IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
|
272
269
|
|
273
|
-
|
274
|
-
Reline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
|
275
|
-
end
|
270
|
+
Reline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
|
276
271
|
Reline.completion_append_character = nil
|
277
272
|
Reline.completer_quote_characters = ''
|
278
273
|
Reline.completion_proc = IRB::InputCompletor::CompletionProc
|
@@ -401,10 +396,10 @@ module IRB
|
|
401
396
|
mod_key = RUBY_PLATFORM.match?(/darwin/) ? "Option" : "Alt"
|
402
397
|
message = "Press #{mod_key}+d to read the full document"
|
403
398
|
contents = [message] + doc.accept(formatter).split("\n")
|
404
|
-
contents = contents.take(preferred_dialog_height)
|
399
|
+
contents = contents.take(Reline.preferred_dialog_height)
|
405
400
|
|
406
401
|
y = cursor_pos_to_render.y
|
407
|
-
DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
|
402
|
+
Reline::DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
|
408
403
|
}
|
409
404
|
|
410
405
|
# Reads the next line from this input method.
|
@@ -415,8 +410,8 @@ module IRB
|
|
415
410
|
Reline.output = @stdout
|
416
411
|
Reline.prompt_proc = @prompt_proc
|
417
412
|
Reline.auto_indent_proc = @auto_indent_proc if @auto_indent_proc
|
418
|
-
if l = readmultiline(@prompt, false, &@check_termination_proc)
|
419
|
-
HISTORY.push(l) if !l.empty?
|
413
|
+
if l = Reline.readmultiline(@prompt, false, &@check_termination_proc)
|
414
|
+
Reline::HISTORY.push(l) if !l.empty?
|
420
415
|
@line[@line_no += 1] = l + "\n"
|
421
416
|
else
|
422
417
|
@eof = true
|
@@ -458,11 +453,7 @@ module IRB
|
|
458
453
|
def inspect
|
459
454
|
config = Reline::Config.new
|
460
455
|
str = "RelineInputMethod with Reline #{Reline::VERSION}"
|
461
|
-
|
462
|
-
inputrc_path = File.expand_path(config.inputrc_path)
|
463
|
-
else
|
464
|
-
inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
|
465
|
-
end
|
456
|
+
inputrc_path = File.expand_path(config.inputrc_path)
|
466
457
|
str += " and #{inputrc_path}" if File.exist?(inputrc_path)
|
467
458
|
str
|
468
459
|
end
|
data/lib/irb/version.rb
CHANGED
data/lib/irb.rb
CHANGED
@@ -154,7 +154,7 @@ require_relative "irb/easter-egg"
|
|
154
154
|
#
|
155
155
|
# IRB.conf[:EVAL_HISTORY] = <number>
|
156
156
|
#
|
157
|
-
# See IRB::Context#eval_history= and
|
157
|
+
# See IRB::Context#eval_history= and EvalHistory class. The history of command
|
158
158
|
# results is not permanently saved in any file.
|
159
159
|
#
|
160
160
|
# == Customizing the IRB Prompt
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aycabta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-07-
|
12
|
+
date: 2023-07-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: reline
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.3.
|
20
|
+
version: 0.3.6
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.3.
|
27
|
+
version: 0.3.6
|
28
28
|
description: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
|
29
29
|
email:
|
30
30
|
- aycabta@gmail.com
|
@@ -76,16 +76,16 @@ files:
|
|
76
76
|
- lib/irb/context.rb
|
77
77
|
- lib/irb/easter-egg.rb
|
78
78
|
- lib/irb/ext/change-ws.rb
|
79
|
-
- lib/irb/ext/
|
79
|
+
- lib/irb/ext/eval_history.rb
|
80
80
|
- lib/irb/ext/loader.rb
|
81
81
|
- lib/irb/ext/multi-irb.rb
|
82
|
-
- lib/irb/ext/save-history.rb
|
83
82
|
- lib/irb/ext/tracer.rb
|
84
83
|
- lib/irb/ext/use-loader.rb
|
85
84
|
- lib/irb/ext/workspaces.rb
|
86
85
|
- lib/irb/extend-command.rb
|
87
86
|
- lib/irb/frame.rb
|
88
87
|
- lib/irb/help.rb
|
88
|
+
- lib/irb/history.rb
|
89
89
|
- lib/irb/init.rb
|
90
90
|
- lib/irb/input-method.rb
|
91
91
|
- lib/irb/inspector.rb
|
@@ -99,7 +99,6 @@ files:
|
|
99
99
|
- lib/irb/output-method.rb
|
100
100
|
- lib/irb/ruby-lex.rb
|
101
101
|
- lib/irb/ruby_logo.aa
|
102
|
-
- lib/irb/src_encoding.rb
|
103
102
|
- lib/irb/version.rb
|
104
103
|
- lib/irb/workspace.rb
|
105
104
|
- lib/irb/ws-for-case-2.rb
|