irb 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +4 -0
- data/LICENSE.txt +3 -3
- data/irb.gemspec +1 -1
- data/lib/irb.rb +9 -2
- data/lib/irb/completion.rb +5 -9
- data/lib/irb/context.rb +20 -0
- data/lib/irb/ext/save-history.rb +2 -2
- data/lib/irb/init.rb +6 -3
- data/lib/irb/input-method.rb +4 -0
- data/lib/irb/locale.rb +8 -3
- data/lib/irb/ruby-lex.rb +9 -2
- data/lib/irb/version.rb +2 -2
- metadata +4 -4
- data/lib/irb/lc/.document +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1db19c9463f04b7e54357c0cdd3aaf2dc33e74f2d82f7ec4e6a1b949232c17f1
|
4
|
+
data.tar.gz: e8fb0dd9ae7bb63ec86f043c646530d2614f8cbc04a2ef9a4566b58206eeb139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffecda47f8fd505d5ae6adc071939668d77a248275554048f36300750f219660d7d876155a0767816f67d01abde2f9a308c5755e62a3fbe2a5e919667b27caa7
|
7
|
+
data.tar.gz: 6906dbf9af719531f725f7fb5175166382626fda407712c46e7087414df09115a5768866e9df36eacf4389bca11959e8a5091127a58a629f7d9d009a0d1e470d
|
data/.document
ADDED
data/LICENSE.txt
CHANGED
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
|
|
4
4
|
modification, are permitted provided that the following conditions
|
5
5
|
are met:
|
6
6
|
1. Redistributions of source code must retain the above copyright
|
7
|
-
notice, this list of conditions and the following disclaimer.
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
8
|
2. Redistributions in binary form must reproduce the above copyright
|
9
|
-
notice, this list of conditions and the following disclaimer in the
|
10
|
-
documentation and/or other materials provided with the distribution.
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
11
|
|
12
12
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
13
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
data/irb.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.license = "BSD-2-Clause"
|
18
18
|
|
19
19
|
spec.files = [
|
20
|
+
".document",
|
20
21
|
"Gemfile",
|
21
22
|
"LICENSE.txt",
|
22
23
|
"README.md",
|
@@ -52,7 +53,6 @@ Gem::Specification.new do |spec|
|
|
52
53
|
"lib/irb/init.rb",
|
53
54
|
"lib/irb/input-method.rb",
|
54
55
|
"lib/irb/inspector.rb",
|
55
|
-
"lib/irb/lc/.document",
|
56
56
|
"lib/irb/lc/error.rb",
|
57
57
|
"lib/irb/lc/help-message",
|
58
58
|
"lib/irb/lc/ja/encoding_aliases.rb",
|
data/lib/irb.rb
CHANGED
@@ -21,6 +21,7 @@ require "irb/locale"
|
|
21
21
|
require "irb/color"
|
22
22
|
|
23
23
|
require "irb/version"
|
24
|
+
require "irb/easter-egg"
|
24
25
|
|
25
26
|
# IRB stands for "interactive Ruby" and is a tool to interactively execute Ruby
|
26
27
|
# expressions read from the standard input.
|
@@ -131,7 +132,7 @@ require "irb/version"
|
|
131
132
|
#
|
132
133
|
# See IRB::Context#save_history= for more information.
|
133
134
|
#
|
134
|
-
# The history of
|
135
|
+
# The history of _results_ of commands evaluated is not stored by default,
|
135
136
|
# but can be turned on to be stored with this +.irbrc+ setting:
|
136
137
|
#
|
137
138
|
# IRB.conf[:EVAL_HISTORY] = <number>
|
@@ -736,7 +737,13 @@ module IRB
|
|
736
737
|
end
|
737
738
|
|
738
739
|
def output_value # :nodoc:
|
739
|
-
|
740
|
+
str = @context.inspect_last_value
|
741
|
+
multiline_p = /\A.*\Z/ !~ str
|
742
|
+
if multiline_p && @context.newline_before_multiline_output?
|
743
|
+
printf @context.return_format, "\n#{str}"
|
744
|
+
else
|
745
|
+
printf @context.return_format, str
|
746
|
+
end
|
740
747
|
end
|
741
748
|
|
742
749
|
# Outputs the local variables to this current session, including
|
data/lib/irb/completion.rb
CHANGED
@@ -203,7 +203,7 @@ module IRB
|
|
203
203
|
sep = $2
|
204
204
|
message = Regexp.quote($3)
|
205
205
|
|
206
|
-
gv = eval("global_variables", bind).collect{|m| m.to_s}.
|
206
|
+
gv = eval("global_variables", bind).collect{|m| m.to_s}.push("true", "false", "nil")
|
207
207
|
lv = eval("local_variables", bind).collect{|m| m.to_s}
|
208
208
|
iv = eval("instance_variables", bind).collect{|m| m.to_s}
|
209
209
|
cv = eval("self.class.constants", bind).collect{|m| m.to_s}
|
@@ -265,18 +265,14 @@ module IRB
|
|
265
265
|
end
|
266
266
|
end
|
267
267
|
|
268
|
-
PerfectMatchedProc = ->(matched) {
|
268
|
+
PerfectMatchedProc = ->(matched, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding) {
|
269
269
|
RDocRIDriver ||= RDoc::RI::Driver.new
|
270
270
|
if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
|
271
|
-
|
272
|
-
RDocRIDriver.page do |io|
|
273
|
-
IO.copy_stream(f, io)
|
274
|
-
end
|
275
|
-
end
|
271
|
+
IRB.send(:easter_egg)
|
276
272
|
return
|
277
273
|
end
|
278
|
-
namespace = retrieve_completion_data(matched, doc_namespace: true)
|
279
|
-
return unless
|
274
|
+
namespace = retrieve_completion_data(matched, bind: bind, doc_namespace: true)
|
275
|
+
return unless namespace
|
280
276
|
if namespace.is_a?(Array)
|
281
277
|
out = RDoc::Markup::Document.new
|
282
278
|
namespace.each do |m|
|
data/lib/irb/context.rb
CHANGED
@@ -133,6 +133,11 @@ module IRB
|
|
133
133
|
if @echo_on_assignment.nil?
|
134
134
|
@echo_on_assignment = false
|
135
135
|
end
|
136
|
+
|
137
|
+
@newline_before_multiline_output = IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT]
|
138
|
+
if @newline_before_multiline_output.nil?
|
139
|
+
@newline_before_multiline_output = true
|
140
|
+
end
|
136
141
|
end
|
137
142
|
|
138
143
|
# The top-level workspace, see WorkSpace#main
|
@@ -253,6 +258,20 @@ module IRB
|
|
253
258
|
# a = "omg"
|
254
259
|
# #=> omg
|
255
260
|
attr_accessor :echo_on_assignment
|
261
|
+
# Whether a newline is put before multiline output.
|
262
|
+
#
|
263
|
+
# Uses IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT] if available,
|
264
|
+
# or defaults to +true+.
|
265
|
+
#
|
266
|
+
# "abc\ndef"
|
267
|
+
# #=>
|
268
|
+
# abc
|
269
|
+
# def
|
270
|
+
# IRB.CurrentContext.newline_before_multiline_output = false
|
271
|
+
# "abc\ndef"
|
272
|
+
# #=> abc
|
273
|
+
# def
|
274
|
+
attr_accessor :newline_before_multiline_output
|
256
275
|
# Whether verbose messages are displayed or not.
|
257
276
|
#
|
258
277
|
# A copy of the default <code>IRB.conf[:VERBOSE]</code>
|
@@ -287,6 +306,7 @@ module IRB
|
|
287
306
|
alias ignore_eof? ignore_eof
|
288
307
|
alias echo? echo
|
289
308
|
alias echo_on_assignment? echo_on_assignment
|
309
|
+
alias newline_before_multiline_output? newline_before_multiline_output
|
290
310
|
|
291
311
|
# Returns whether messages are displayed or not.
|
292
312
|
def verbose?
|
data/lib/irb/ext/save-history.rb
CHANGED
@@ -72,7 +72,7 @@ module IRB
|
|
72
72
|
end
|
73
73
|
history_file = IRB.rc_file("_history") unless history_file
|
74
74
|
if File.exist?(history_file)
|
75
|
-
open(history_file) do |f|
|
75
|
+
open(history_file, "r:#{IRB.conf[:LC_MESSAGES].encoding}") do |f|
|
76
76
|
f.each { |l|
|
77
77
|
l = l.chomp
|
78
78
|
if self.class == ReidlineInputMethod and history.last&.end_with?("\\")
|
@@ -107,7 +107,7 @@ module IRB
|
|
107
107
|
raise
|
108
108
|
end
|
109
109
|
|
110
|
-
open(history_file,
|
110
|
+
open(history_file, "w:#{IRB.conf[:LC_MESSAGES].encoding}", 0600) do |f|
|
111
111
|
hist = history.map{ |l| l.split("\n").join("\\\n") }
|
112
112
|
f.puts(hist[-num..-1] || hist)
|
113
113
|
end
|
data/lib/irb/init.rb
CHANGED
@@ -296,15 +296,18 @@ module IRB # :nodoc:
|
|
296
296
|
DefaultEncodings = Struct.new(:external, :internal)
|
297
297
|
class << IRB
|
298
298
|
private
|
299
|
-
def set_encoding(extern, intern = nil)
|
299
|
+
def set_encoding(extern, intern = nil, override: true)
|
300
300
|
verbose, $VERBOSE = $VERBOSE, nil
|
301
301
|
Encoding.default_external = extern unless extern.nil? || extern.empty?
|
302
302
|
Encoding.default_internal = intern unless intern.nil? || intern.empty?
|
303
|
-
@CONF[:ENCODINGS] = IRB::DefaultEncodings.new(extern, intern)
|
304
303
|
[$stdin, $stdout, $stderr].each do |io|
|
305
304
|
io.set_encoding(extern, intern)
|
306
305
|
end
|
307
|
-
|
306
|
+
if override
|
307
|
+
@CONF[:LC_MESSAGES].instance_variable_set(:@override_encoding, extern)
|
308
|
+
else
|
309
|
+
@CONF[:LC_MESSAGES].instance_variable_set(:@encoding, extern)
|
310
|
+
end
|
308
311
|
ensure
|
309
312
|
$VERBOSE = verbose
|
310
313
|
end
|
data/lib/irb/input-method.rb
CHANGED
@@ -133,6 +133,9 @@ module IRB
|
|
133
133
|
include Readline
|
134
134
|
# Creates a new input method object using Readline
|
135
135
|
def initialize
|
136
|
+
if Readline.respond_to?(:encoding_system_needs)
|
137
|
+
IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false)
|
138
|
+
end
|
136
139
|
super
|
137
140
|
|
138
141
|
@line_no = 0
|
@@ -207,6 +210,7 @@ module IRB
|
|
207
210
|
include Reline
|
208
211
|
# Creates a new input method object using Readline
|
209
212
|
def initialize
|
213
|
+
IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
|
210
214
|
super
|
211
215
|
|
212
216
|
@line_no = 0
|
data/lib/irb/locale.rb
CHANGED
@@ -24,6 +24,7 @@ module IRB # :nodoc:
|
|
24
24
|
@@loaded = []
|
25
25
|
|
26
26
|
def initialize(locale = nil)
|
27
|
+
@override_encoding = nil
|
27
28
|
@lang = @territory = @encoding_name = @modifier = nil
|
28
29
|
@locale = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
|
29
30
|
if m = LOCALE_NAME_RE.match(@locale)
|
@@ -40,12 +41,16 @@ module IRB # :nodoc:
|
|
40
41
|
@encoding ||= (Encoding.find('locale') rescue Encoding::ASCII_8BIT)
|
41
42
|
end
|
42
43
|
|
43
|
-
attr_reader :lang, :territory, :
|
44
|
+
attr_reader :lang, :territory, :modifier
|
45
|
+
|
46
|
+
def encoding
|
47
|
+
@override_encoding || @encoding
|
48
|
+
end
|
44
49
|
|
45
50
|
def String(mes)
|
46
51
|
mes = super(mes)
|
47
|
-
if
|
48
|
-
mes.encode(
|
52
|
+
if encoding
|
53
|
+
mes.encode(encoding, undef: :replace)
|
49
54
|
else
|
50
55
|
mes
|
51
56
|
end
|
data/lib/irb/ruby-lex.rb
CHANGED
@@ -317,11 +317,13 @@ class RubyLex
|
|
317
317
|
|
318
318
|
def check_newline_depth_difference
|
319
319
|
depth_difference = 0
|
320
|
+
open_brace_on_line = 0
|
320
321
|
@tokens.each_with_index do |t, index|
|
321
322
|
case t[1]
|
322
323
|
when :on_ignored_nl, :on_nl, :on_comment
|
323
324
|
if index != (@tokens.size - 1)
|
324
325
|
depth_difference = 0
|
326
|
+
open_brace_on_line = 0
|
325
327
|
end
|
326
328
|
next
|
327
329
|
when :on_sp
|
@@ -330,8 +332,9 @@ class RubyLex
|
|
330
332
|
case t[1]
|
331
333
|
when :on_lbracket, :on_lbrace, :on_lparen
|
332
334
|
depth_difference += 1
|
335
|
+
open_brace_on_line += 1
|
333
336
|
when :on_rbracket, :on_rbrace, :on_rparen
|
334
|
-
depth_difference -= 1
|
337
|
+
depth_difference -= 1 if open_brace_on_line > 0
|
335
338
|
when :on_kw
|
336
339
|
next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME)
|
337
340
|
case t[2]
|
@@ -365,6 +368,7 @@ class RubyLex
|
|
365
368
|
is_first_printable_of_line = true
|
366
369
|
spaces_of_nest = []
|
367
370
|
spaces_at_line_head = 0
|
371
|
+
open_brace_on_line = 0
|
368
372
|
@tokens.each_with_index do |t, index|
|
369
373
|
case t[1]
|
370
374
|
when :on_ignored_nl, :on_nl, :on_comment
|
@@ -372,6 +376,7 @@ class RubyLex
|
|
372
376
|
spaces_at_line_head = 0
|
373
377
|
is_first_spaces_of_line = true
|
374
378
|
is_first_printable_of_line = true
|
379
|
+
open_brace_on_line = 0
|
375
380
|
next
|
376
381
|
when :on_sp
|
377
382
|
spaces_at_line_head = t[2].count(' ') if is_first_spaces_of_line
|
@@ -380,7 +385,8 @@ class RubyLex
|
|
380
385
|
end
|
381
386
|
case t[1]
|
382
387
|
when :on_lbracket, :on_lbrace, :on_lparen
|
383
|
-
spaces_of_nest.push(spaces_at_line_head)
|
388
|
+
spaces_of_nest.push(spaces_at_line_head + open_brace_on_line * 2)
|
389
|
+
open_brace_on_line += 1
|
384
390
|
when :on_rbracket, :on_rbrace, :on_rparen
|
385
391
|
if is_first_printable_of_line
|
386
392
|
corresponding_token_depth = spaces_of_nest.pop
|
@@ -388,6 +394,7 @@ class RubyLex
|
|
388
394
|
spaces_of_nest.pop
|
389
395
|
corresponding_token_depth = nil
|
390
396
|
end
|
397
|
+
open_brace_on_line -= 1
|
391
398
|
when :on_kw
|
392
399
|
next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME)
|
393
400
|
case t[2]
|
data/lib/irb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keiju ISHITSUKA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: reline
|
@@ -60,6 +60,7 @@ executables:
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".document"
|
63
64
|
- Gemfile
|
64
65
|
- LICENSE.txt
|
65
66
|
- README.md
|
@@ -95,7 +96,6 @@ files:
|
|
95
96
|
- lib/irb/init.rb
|
96
97
|
- lib/irb/input-method.rb
|
97
98
|
- lib/irb/inspector.rb
|
98
|
-
- lib/irb/lc/.document
|
99
99
|
- lib/irb/lc/error.rb
|
100
100
|
- lib/irb/lc/help-message
|
101
101
|
- lib/irb/lc/ja/encoding_aliases.rb
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
|
-
rubygems_version: 3.
|
135
|
+
rubygems_version: 3.1.2
|
136
136
|
signing_key:
|
137
137
|
specification_version: 4
|
138
138
|
summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
|
data/lib/irb/lc/.document
DELETED