irb 1.2.3 → 1.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 455620204255c774ac81923f080599183cda03da4990605ccdd516b17e60bfed
4
- data.tar.gz: e1617267b3c9b240dd4a5115549ad2c333f054dee05eaa8408071126a4e37eab
3
+ metadata.gz: 0b760eaf9b7cc0f0029395a3a6de59420595d82f9610442b6b382576e030b86b
4
+ data.tar.gz: 0e50bdf359e3ccb0e9ae5ec351e47d34601e68a0073a65d9bf310df3fbe95360
5
5
  SHA512:
6
- metadata.gz: 9842eb424f88442ff8915b15ebf1754ccb95a86643ada5619a750829d80ccb513e39f65f4b804fbb4d23f18439cd6c09f47d64fe7d2f01c069d459f2a70c685a
7
- data.tar.gz: c6e859ae895a47df11eed8298e943b6b841f6412ae507a16ca852df235aaf8fc0f227752f3d68060d217945829aae5a329f9868b8dd15b1837a6ffc191f911b7
6
+ metadata.gz: e82e4dac7bf886a261f2f2008c5e12eab54adfe75c5a42c6b870eb0c30c8dc87a18f48275857054ba19091737903e96a120ca69a2ccdb9cdcf3b494129997972
7
+ data.tar.gz: 40b3e75fb3de5422b6cafaebd94ad0f4283999e957c719b86ef4ade5aca96e9eb47bb94794342985a557061326c93bff333e4b8950cbafe4239879301208e79c
data/lib/irb.rb CHANGED
@@ -271,7 +271,7 @@ require "irb/easter-egg"
271
271
  # On the other hand, each conf in IRB@Command+line+options is used to
272
272
  # individually configure IRB.irb.
273
273
  #
274
- # If a proc is set for IRB.conf[:IRB_RC], its will be invoked after execution
274
+ # If a proc is set for <code>IRB.conf[:IRB_RC]</code>, its will be invoked after execution
275
275
  # of that proc with the context of the current session as its argument. Each
276
276
  # session can be configured using this mechanism.
277
277
  #
@@ -399,7 +399,7 @@ module IRB
399
399
  irb.run(@CONF)
400
400
  end
401
401
 
402
- # Calls each event hook of IRB.conf[:AT_EXIT] when the current session quits.
402
+ # Calls each event hook of <code>IRB.conf[:TA_EXIT]</code> when the current session quits.
403
403
  def IRB.irb_at_exit
404
404
  @CONF[:AT_EXIT].each{|hook| hook.call}
405
405
  end
@@ -554,7 +554,8 @@ module IRB
554
554
 
555
555
  def handle_exception(exc)
556
556
  if exc.backtrace && exc.backtrace[0] =~ /\/irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
557
- !(SyntaxError === exc)
557
+ !(SyntaxError === exc) && !(EncodingError === exc)
558
+ # The backtrace of invalid encoding hash (ex. {"\xAE": 1}) raises EncodingError without lineno.
558
559
  irb_bug = true
559
560
  else
560
561
  irb_bug = false
@@ -738,7 +739,7 @@ module IRB
738
739
 
739
740
  def output_value # :nodoc:
740
741
  str = @context.inspect_last_value
741
- multiline_p = /\A.*\Z/ !~ str
742
+ multiline_p = str.include?("\n")
742
743
  if multiline_p && @context.newline_before_multiline_output?
743
744
  printf @context.return_format, "\n#{str}"
744
745
  else
@@ -99,7 +99,11 @@ module IRB
99
99
  return nil if doc_namespace
100
100
  if Symbol.respond_to?(:all_symbols)
101
101
  sym = $1
102
- candidates = Symbol.all_symbols.collect{|s| ":" + s.id2name}
102
+ candidates = Symbol.all_symbols.collect do |s|
103
+ ":" + s.id2name.encode(Encoding.default_external)
104
+ rescue Encoding::UndefinedConversionError
105
+ # ignore
106
+ end
103
107
  candidates.grep(/^#{Regexp.quote(sym)}/)
104
108
  else
105
109
  []
@@ -144,7 +148,7 @@ module IRB
144
148
  select_message(receiver, message, candidates, sep)
145
149
  end
146
150
 
147
- when /^(?<num>-?(0[dbo])?[0-9_]+(\.[0-9_]+)?(([eE][+-]?[0-9]+)?i?|r)?)(?<sep>\.|::)(?<mes>[^.]*)$/
151
+ when /^(?<num>-?(?:0[dbo])?[0-9_]+(?:\.[0-9_]+)?(?:(?:[eE][+-]?[0-9]+)?i?|r)?)(?<sep>\.|::)(?<mes>[^.]*)$/
148
152
  # Numeric
149
153
  receiver = $~[:num]
150
154
  sep = $~[:sep]
@@ -240,7 +240,7 @@ module IRB
240
240
  attr_accessor :ignore_eof
241
241
  # Whether to echo the return value to output or not.
242
242
  #
243
- # Uses IRB.conf[:ECHO] if available, or defaults to +true+.
243
+ # Uses <code>IRB.conf[:ECHO]</code> if available, or defaults to +true+.
244
244
  #
245
245
  # puts "hello"
246
246
  # # hello
@@ -251,7 +251,7 @@ module IRB
251
251
  attr_accessor :echo
252
252
  # Whether to echo for assignment expressions
253
253
  #
254
- # Uses IRB.conf[:ECHO_ON_ASSIGNMENT] if available, or defaults to +false+.
254
+ # Uses <code>IRB.conf[:ECHO_ON_ASSIGNMENT]</code> if available, or defaults to +false+.
255
255
  #
256
256
  # a = "omg"
257
257
  # IRB.CurrentContext.echo_on_assignment = true
@@ -260,7 +260,7 @@ module IRB
260
260
  attr_accessor :echo_on_assignment
261
261
  # Whether a newline is put before multiline output.
262
262
  #
263
- # Uses IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT] if available,
263
+ # Uses <code>IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT]</code> if available,
264
264
  # or defaults to +true+.
265
265
  #
266
266
  # "abc\ndef"
@@ -47,7 +47,7 @@ module IRB
47
47
  alias use_loader? use_loader
48
48
 
49
49
  remove_method :use_loader= if method_defined?(:use_loader=)
50
- # Sets IRB.conf[:USE_LOADER]
50
+ # Sets <code>IRB.conf[:USE_LOADER]</code>
51
51
  #
52
52
  # See #use_loader for more information.
53
53
  def use_loader=(opt)
@@ -121,6 +121,10 @@ module IRB # :nodoc:
121
121
  [:help, NO_OVERRIDE],
122
122
  ],
123
123
 
124
+ [
125
+ :irb_info, :Info, "irb/cmd/info"
126
+ ],
127
+
124
128
  ]
125
129
 
126
130
  # Installs the default irb commands:
@@ -169,11 +173,14 @@ module IRB # :nodoc:
169
173
  args << "&block"
170
174
  args = args.join(", ")
171
175
  line = __LINE__; eval %[
172
- def #{cmd_name}(\#{args})
173
- ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
176
+ unless self.class.class_variable_defined?(:@@#{cmd_name}_)
177
+ self.class.class_variable_set(:@@#{cmd_name}_, true)
178
+ def #{cmd_name}_(\#{args})
179
+ ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
180
+ end
174
181
  end
175
182
  ], nil, __FILE__, line
176
- send :#{cmd_name}, *opts, &b
183
+ send :#{cmd_name}_, *opts, &b
177
184
  end
178
185
  ], nil, __FILE__, line
179
186
  else
@@ -271,10 +271,19 @@ module IRB # :nodoc:
271
271
  if irbrc = ENV["IRBRC"]
272
272
  yield proc{|rc| rc == "rc" ? irbrc : irbrc+rc}
273
273
  end
274
+ if xdg_config_home = ENV["XDG_CONFIG_HOME"]
275
+ irb_home = File.join(xdg_config_home, "irb")
276
+ unless File.exist? irb_home
277
+ require 'fileutils'
278
+ FileUtils.mkdir_p irb_home
279
+ end
280
+ yield proc{|rc| irb_home + "/irb#{rc}"}
281
+ end
274
282
  if home = ENV["HOME"]
275
283
  yield proc{|rc| home+"/.irb#{rc}"}
276
284
  end
277
285
  current_dir = Dir.pwd
286
+ yield proc{|rc| current_dir+"/.config/irb/irb#{rc}"}
278
287
  yield proc{|rc| current_dir+"/.irb#{rc}"}
279
288
  yield proc{|rc| current_dir+"/irb#{rc.sub(/\A_?/, '.')}"}
280
289
  yield proc{|rc| current_dir+"/_irb#{rc}"}
@@ -43,6 +43,11 @@ module IRB
43
43
  def readable_after_eof?
44
44
  false
45
45
  end
46
+
47
+ # For debug message
48
+ def inspect
49
+ 'Abstract InputMethod'
50
+ end
46
51
  end
47
52
 
48
53
  class StdioInputMethod < InputMethod
@@ -93,6 +98,11 @@ module IRB
93
98
  def encoding
94
99
  @stdin.external_encoding
95
100
  end
101
+
102
+ # For debug message
103
+ def inspect
104
+ 'StdioInputMethod'
105
+ end
96
106
  end
97
107
 
98
108
  # Use a File for IO with irb, see InputMethod
@@ -125,6 +135,11 @@ module IRB
125
135
  def encoding
126
136
  @io.external_encoding
127
137
  end
138
+
139
+ # For debug message
140
+ def inspect
141
+ 'FileInputMethod'
142
+ end
128
143
  end
129
144
 
130
145
  begin
@@ -202,6 +217,15 @@ module IRB
202
217
  end
203
218
  Readline.completion_append_character = nil
204
219
  Readline.completion_proc = IRB::InputCompletor::CompletionProc
220
+
221
+ # For debug message
222
+ def inspect
223
+ readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline'
224
+ str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}"
225
+ inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
226
+ str += " and #{inputrc_path}" if File.exist?(inputrc_path)
227
+ str
228
+ end
205
229
  end
206
230
  rescue LoadError
207
231
  end
@@ -297,5 +321,18 @@ module IRB
297
321
  def encoding
298
322
  @stdin.external_encoding
299
323
  end
324
+
325
+ # For debug message
326
+ def inspect
327
+ config = Reline::Config.new
328
+ str = "ReidlineInputMethod with Reline #{Reline::VERSION}"
329
+ if config.respond_to?(:inputrc_path)
330
+ inputrc_path = config.inputrc_path
331
+ else
332
+ inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
333
+ end
334
+ str += " and #{inputrc_path}" if File.exist?(inputrc_path)
335
+ str
336
+ end
300
337
  end
301
338
  end
@@ -11,6 +11,7 @@
11
11
  #
12
12
 
13
13
  require "ripper"
14
+ require "jruby" if RUBY_ENGINE == "jruby"
14
15
 
15
16
  # :stopdoc:
16
17
  class RubyLex
@@ -211,6 +212,8 @@ class RubyLex
211
212
  else
212
213
  RubyVM::InstructionSequence.compile(code)
213
214
  end
215
+ rescue EncodingError
216
+ # This is for a hash with invalid encoding symbol, {"\xAE": 1}
214
217
  rescue SyntaxError => e
215
218
  case e.message
216
219
  when /unterminated (?:string|regexp) meets end of file/
@@ -11,7 +11,7 @@
11
11
  #
12
12
 
13
13
  module IRB # :nodoc:
14
- VERSION = "1.2.3"
14
+ VERSION = "1.2.4"
15
15
  @RELEASE_VERSION = VERSION
16
- @LAST_UPDATE_DATE = "2020-02-15"
16
+ @LAST_UPDATE_DATE = "2020-05-02"
17
17
  end
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.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keiju ISHITSUKA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-15 00:00:00.000000000 Z
11
+ date: 2020-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reline