irb 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/irb.gemspec +1 -1
- data/lib/irb.rb +34 -2
- data/lib/irb/context.rb +24 -4
- data/lib/irb/init.rb +5 -0
- data/lib/irb/input-method.rb +9 -0
- data/lib/irb/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cafd02c241d954487f11903643ef4a4218d39352c889f3be57a1e9314acb174
|
4
|
+
data.tar.gz: 0f4afd5294f5357835df0519b0a32cba425cf40a1afc225cf3acf0ae4d0cb04a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 958f6f1750e5cb951110a1de09beebee65e24c931989da99dd05a1207f050e96f37490e6def0c484b18a23a91c66ad8119a7aa2c5e48c7ad6eacb4590ea4c397
|
7
|
+
data.tar.gz: 1c6d64ed48b51f189ba9d5846ffdfeae02eff8e44554c66d54eeaab597b96381bdbe78aeba6f2f5fbb0929ee5517e87584eeebd50c65bc93e5cd3321c1b8260e
|
data/irb.gemspec
CHANGED
@@ -78,7 +78,7 @@ Gem::Specification.new do |spec|
|
|
78
78
|
|
79
79
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5")
|
80
80
|
|
81
|
-
spec.add_dependency "reline", ">= 0.
|
81
|
+
spec.add_dependency "reline", ">= 0.1.5"
|
82
82
|
spec.add_development_dependency "bundler"
|
83
83
|
spec.add_development_dependency "rake"
|
84
84
|
end
|
data/lib/irb.rb
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
#
|
11
11
|
#
|
12
12
|
require "ripper"
|
13
|
+
require "reline"
|
13
14
|
|
14
15
|
require_relative "irb/init"
|
15
16
|
require_relative "irb/context"
|
@@ -538,7 +539,15 @@ module IRB
|
|
538
539
|
begin
|
539
540
|
line.untaint if RUBY_VERSION < '2.7'
|
540
541
|
@context.evaluate(line, line_no, exception: exc)
|
541
|
-
|
542
|
+
if @context.echo?
|
543
|
+
if assignment_expression?(line)
|
544
|
+
if @context.echo_on_assignment?
|
545
|
+
output_value(@context.omit_on_assignment?)
|
546
|
+
end
|
547
|
+
else
|
548
|
+
output_value
|
549
|
+
end
|
550
|
+
end
|
542
551
|
rescue Interrupt => exc
|
543
552
|
rescue SystemExit, SignalException
|
544
553
|
raise
|
@@ -737,9 +746,32 @@ module IRB
|
|
737
746
|
p
|
738
747
|
end
|
739
748
|
|
740
|
-
def output_value # :nodoc:
|
749
|
+
def output_value(omit = false) # :nodoc:
|
741
750
|
str = @context.inspect_last_value
|
742
751
|
multiline_p = str.include?("\n")
|
752
|
+
if omit
|
753
|
+
winwidth = @context.io.winsize.last
|
754
|
+
if multiline_p
|
755
|
+
first_line = str.split("\n").first
|
756
|
+
result = @context.newline_before_multiline_output? ? (@context.return_format % first_line) : first_line
|
757
|
+
output_width = Reline::Unicode.calculate_width(result, true)
|
758
|
+
diff_size = output_width - Reline::Unicode.calculate_width(first_line, true)
|
759
|
+
if diff_size.positive? and output_width > winwidth
|
760
|
+
lines, _ = Reline::Unicode.split_by_width(first_line, winwidth - diff_size - 3)
|
761
|
+
str = "%s...\e[0m" % lines.first
|
762
|
+
multiline_p = false
|
763
|
+
else
|
764
|
+
str.gsub!(/(\A.*?\n).*/m, "\\1...")
|
765
|
+
end
|
766
|
+
else
|
767
|
+
output_width = Reline::Unicode.calculate_width(@context.return_format % str, true)
|
768
|
+
diff_size = output_width - Reline::Unicode.calculate_width(str, true)
|
769
|
+
if diff_size.positive? and output_width > winwidth
|
770
|
+
lines, _ = Reline::Unicode.split_by_width(str, winwidth - diff_size - 3)
|
771
|
+
str = "%s...\e[0m" % lines.first
|
772
|
+
end
|
773
|
+
end
|
774
|
+
end
|
743
775
|
if multiline_p && @context.newline_before_multiline_output?
|
744
776
|
printf @context.return_format, "\n#{str}"
|
745
777
|
else
|
data/lib/irb/context.rb
CHANGED
@@ -131,7 +131,12 @@ module IRB
|
|
131
131
|
|
132
132
|
@echo_on_assignment = IRB.conf[:ECHO_ON_ASSIGNMENT]
|
133
133
|
if @echo_on_assignment.nil?
|
134
|
-
@echo_on_assignment =
|
134
|
+
@echo_on_assignment = true
|
135
|
+
end
|
136
|
+
|
137
|
+
@omit_on_assignment = IRB.conf[:OMIT_ON_ASSIGNMENT]
|
138
|
+
if @omit_on_assignment.nil?
|
139
|
+
@omit_on_assignment = true
|
135
140
|
end
|
136
141
|
|
137
142
|
@newline_before_multiline_output = IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT]
|
@@ -251,13 +256,27 @@ module IRB
|
|
251
256
|
attr_accessor :echo
|
252
257
|
# Whether to echo for assignment expressions
|
253
258
|
#
|
254
|
-
# Uses <code>IRB.conf[:ECHO_ON_ASSIGNMENT]</code> if available, or defaults to +
|
259
|
+
# Uses <code>IRB.conf[:ECHO_ON_ASSIGNMENT]</code> if available, or defaults to +true+.
|
255
260
|
#
|
256
261
|
# a = "omg"
|
257
|
-
# IRB.CurrentContext.echo_on_assignment = true
|
258
|
-
# a = "omg"
|
259
262
|
# #=> omg
|
263
|
+
# IRB.CurrentContext.echo_on_assignment = false
|
264
|
+
# a = "omg"
|
260
265
|
attr_accessor :echo_on_assignment
|
266
|
+
# Whether to omit echo for assignment expressions
|
267
|
+
#
|
268
|
+
# Uses <code>IRB.conf[:OMIT_ON_ASSIGNMENT]</code> if available, or defaults to +true+.
|
269
|
+
#
|
270
|
+
# a = [1] * 10
|
271
|
+
# #=> [1, 1, 1, 1, 1, 1, 1, 1, ...
|
272
|
+
# [1] * 10
|
273
|
+
# #=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
274
|
+
# IRB.CurrentContext.omit_on_assignment = false
|
275
|
+
# a = [1] * 10
|
276
|
+
# #=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
277
|
+
# [1] * 10
|
278
|
+
# #=> [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
279
|
+
attr_accessor :omit_on_assignment
|
261
280
|
# Whether a newline is put before multiline output.
|
262
281
|
#
|
263
282
|
# Uses <code>IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT]</code> if available,
|
@@ -306,6 +325,7 @@ module IRB
|
|
306
325
|
alias ignore_eof? ignore_eof
|
307
326
|
alias echo? echo
|
308
327
|
alias echo_on_assignment? echo_on_assignment
|
328
|
+
alias omit_on_assignment? omit_on_assignment
|
309
329
|
alias newline_before_multiline_output? newline_before_multiline_output
|
310
330
|
|
311
331
|
# Returns whether messages are displayed or not.
|
data/lib/irb/init.rb
CHANGED
@@ -52,6 +52,7 @@ module IRB # :nodoc:
|
|
52
52
|
@CONF[:IGNORE_EOF] = false
|
53
53
|
@CONF[:ECHO] = nil
|
54
54
|
@CONF[:ECHO_ON_ASSIGNMENT] = nil
|
55
|
+
@CONF[:OMIT_ON_ASSIGNMENT] = nil
|
55
56
|
@CONF[:VERBOSE] = nil
|
56
57
|
|
57
58
|
@CONF[:EVAL_HISTORY] = nil
|
@@ -177,6 +178,10 @@ module IRB # :nodoc:
|
|
177
178
|
@CONF[:ECHO_ON_ASSIGNMENT] = true
|
178
179
|
when "--noecho-on-assignment"
|
179
180
|
@CONF[:ECHO_ON_ASSIGNMENT] = false
|
181
|
+
when "--omit-on-assignment"
|
182
|
+
@CONF[:OMIT_ON_ASSIGNMENT] = true
|
183
|
+
when "--noomit-on-assignment"
|
184
|
+
@CONF[:OMIT_ON_ASSIGNMENT] = false
|
180
185
|
when "--verbose"
|
181
186
|
@CONF[:VERBOSE] = true
|
182
187
|
when "--noverbose"
|
data/lib/irb/input-method.rb
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
require_relative 'src_encoding'
|
13
13
|
require_relative 'magic-file'
|
14
14
|
require_relative 'completion'
|
15
|
+
require 'io/console'
|
15
16
|
require 'reline'
|
16
17
|
|
17
18
|
module IRB
|
@@ -36,6 +37,14 @@ module IRB
|
|
36
37
|
end
|
37
38
|
public :gets
|
38
39
|
|
40
|
+
def winsize
|
41
|
+
if instance_variable_defined?(:@stdout)
|
42
|
+
@stdout.winsize
|
43
|
+
else
|
44
|
+
[24, 80]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
39
48
|
# Whether this input method is still readable when there is no more data to
|
40
49
|
# read.
|
41
50
|
#
|
data/lib/irb/version.rb
CHANGED
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.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiju ISHITSUKA
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.1.5
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.1.5
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|