irb 1.3.6 → 1.3.8.pre.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7071322837c419efbce74bd5aa91c9b83a9a3fd31e893e72376b763b2bbf4409
4
- data.tar.gz: fa4e508771f91e4da313913592a7caa713cb82069f57d4dab059426baa764fc4
3
+ metadata.gz: 24e47cee826906315d012e38c51e586295517aa5973cb581bdd69565013eb4fd
4
+ data.tar.gz: a18f6ca335c55748a79d3670fec5bba5125ca0c413f9aead0a1b6552ce4dd8b0
5
5
  SHA512:
6
- metadata.gz: 2b040a17c30df8f8512c176acfb1884237c050d5e4dab769f08aa75a00da23dcba1be9fab15d37671e4617abee3f6279363fed80c0980687cdcbed417bf5e3f4
7
- data.tar.gz: 0a021169f28c114aeac7b7375eda932cdd4b357056b092a8499a61da6d4d1b01d019591e94eaaf134392a8b5c92cd632d0dfc7bf4b243831df93cc0514cd2eb1
6
+ metadata.gz: 3e869bf3f5e4cfaba313977894f5632485fc0757c9d353cff96ce17b4734b56d1050e76a5716090940a7ddb072f8a223711891038b56a4f9415950b3d68e0de8
7
+ data.tar.gz: d872b90f23591f57fce7d3c7d9be345aa6e4441c561817504f85dddf08fff8a7c3512157c375ccc5e2cd94c812161bd06ef315b6c834ae4e97c90da8957fb91b
data/doc/irb/irb.rd.ja CHANGED
@@ -40,15 +40,18 @@ irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本
40
40
  irb.rb [options] file_name opts
41
41
  options:
42
42
  -f ~/.irbrc を読み込まない.
43
- -m bcモード(分数, 行列の計算ができる)
44
43
  -d $DEBUG をtrueにする(ruby -d と同じ)
45
- -Kc ruby -Kcと同じ
46
44
  -r load-module ruby -r と同じ.
47
- --verbose これから実行する行を表示する(デフォルト)
48
- --noverbose これから実行する行を表示しない
49
- --echo 実行結果を表示する(デフォルト)
50
- --noecho 実行結果を表示しない
51
- --inspect 結果出力にinspectを用いる(bcモード以外はデフォルト).
45
+ -I path $LOAD_PATH に path を追加する.
46
+ -U ruby -U と同じ.
47
+ -E enc ruby -E と同じ.
48
+ -w ruby -w と同じ.
49
+ -W[level=2] ruby -W と同じ.
50
+ --context-mode n 新しいワークスペースを作成した時に関連する Binding
51
+ オブジェクトの作成方法を 0 から 3 のいずれかに設定する.
52
+ --echo 実行結果を表示する(デフォルト).
53
+ --noecho 実行結果を表示しない.
54
+ --inspect 結果出力にinspectを用いる.
52
55
  --noinspect 結果出力にinspectを用いない.
53
56
  --singleline シングルラインエディタを利用する.
54
57
  --nosingleline シングルラインエディタを利用しない. デフォルトの動
@@ -56,23 +59,30 @@ irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本
56
59
  用しようとする.
57
60
  --colorize 色付けを利用する.
58
61
  --nocolorize 色付けを利用しない.
62
+ --autocomplete オートコンプリートを利用する.
63
+ --noautocomplete オートコンプリートを利用しない.
59
64
  --prompt prompt-mode
60
65
  --prompt-mode prompt-mode
61
66
  プロンプトモードを切替えます. 現在定義されているプ
62
67
  ロンプトモードは, default, simple, xmp, inf-rubyが
63
- 用意されています. デフォルトはdefaultプロンプトモー
64
- ドになっています.
65
-
68
+ 用意されています.
66
69
  --inf-ruby-mode emacsのinf-ruby-mode用のプロンプト表示を行なう. 特
67
70
  に指定がない限り, ラインエディタは使わなくなる.
68
71
  --simple-prompt
69
72
  非常にシンプルなプロンプトを用いるモードです.
70
73
  --noprompt プロンプト表示を行なわない.
74
+ --single-irb irb 中で self を実行して得られるオブジェクトをサ
75
+ ブ irb と共有する.
71
76
  --tracer コマンド実行時にトレースを行なう.
72
77
  --back-trace-limit n
73
78
  バックトレース表示をバックトレースの頭から n, 後ろ
74
79
  からnだけ行なう. デフォルトは16
75
- -v, --version irbのバージョンを表示する
80
+
81
+ --verbose 詳細なメッセージを出力する.
82
+ --noverbose 詳細なメッセージを出力しない(デフォルト).
83
+ -v, --version irbのバージョンを表示する.
84
+ -h, --help irb のヘルプを表示する.
85
+ -- 以降のコマンドライン引数をオプションとして扱わない.
76
86
 
77
87
  = コンフィギュレーション
78
88
 
@@ -137,12 +147,12 @@ PROMPT_I, PROMPT_N, PROMPT_S, PROMPT_Cは, フォーマットを指定します.
137
147
 
138
148
  例えば, デフォルトのプロンプトモードは:
139
149
 
140
- IRB.conf[:PROMPT_MODE][:DEFAULT] = {
150
+ IRB.conf[:PROMPT][:DEFAULT] = {
141
151
  :PROMPT_I => "%N(%m):%03n:%i> ",
142
152
  :PROMPT_N => "%N(%m):%03n:%i> ",
143
153
  :PROMPT_S => "%N(%m):%03n:%i%l ",
144
154
  :PROMPT_C => "%N(%m):%03n:%i* ",
145
- :RETURN => "%s\n"
155
+ :RETURN => "=> %s\n"
146
156
  }
147
157
 
148
158
  となっています.
@@ -374,7 +384,7 @@ rubyでは, 以下のプログラムはエラーになります.
374
384
  パイルしてローカル変数を決定するからです. それに対し, irbは実行可能に
375
385
  なる(式が閉じる)と自動的に評価しているからです. 上記の例では,
376
386
 
377
- evel "foo = 0"
387
+ eval "foo = 0"
378
388
 
379
389
  を行なった時点で評価を行ない, その時点で変数が定義されるため, 次式で
380
390
  変数fooは定義されているからです.
data/irb.gemspec CHANGED
@@ -36,5 +36,5 @@ Gem::Specification.new do |spec|
36
36
 
37
37
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5")
38
38
 
39
- spec.add_dependency "reline", ">= 0.2.5"
39
+ spec.add_dependency "reline", ">= 0.2.8.pre.3"
40
40
  end
data/lib/irb/cmd/info.rb CHANGED
@@ -14,6 +14,12 @@ module IRB
14
14
  str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n"
15
15
  str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file)
16
16
  str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n"
17
+ str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty?
18
+ str += "LC_ALL env: #{ENV["LC_ALL"]}\n" if ENV["LC_ALL"] && !ENV["LC_ALL"].empty?
19
+ if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
20
+ codepage = `chcp`.sub(/.*: (\d+)\n/, '\1')
21
+ str += "Code page: #{codepage}\n"
22
+ end
17
23
  str
18
24
  end
19
25
  alias_method :to_s, :inspect
data/lib/irb/cmd/ls.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "reline"
4
- require 'set'
5
4
  require_relative "nop"
6
5
  require_relative "../color"
7
6
 
@@ -17,32 +16,27 @@ module IRB
17
16
  klass = (obj.class == Class || obj.class == Module ? obj : obj.class)
18
17
 
19
18
  o.dump("constants", obj.constants) if obj.respond_to?(:constants)
20
- dump_singleton_methods(o, klass, obj)
21
- dump_instance_methods(o, klass)
19
+ dump_methods(o, klass, obj)
22
20
  o.dump("instance variables", obj.instance_variables)
23
21
  o.dump("class variables", klass.class_variables)
24
22
  o.dump("locals", locals)
25
23
  end
26
24
 
27
- def dump_singleton_methods(o, klass, obj)
28
- maps = class_method_map(obj.singleton_class.ancestors.take_while { |c| c != klass })
25
+ def dump_methods(o, klass, obj)
26
+ singleton_class = begin obj.singleton_class; rescue TypeError; nil end
27
+ maps = class_method_map((singleton_class || klass).ancestors)
29
28
  maps.each do |mod, methods|
30
- name = mod == obj.singleton_class ? "#{klass}.methods" : "#{mod}#methods"
29
+ name = mod == singleton_class ? "#{klass}.methods" : "#{mod}#methods"
31
30
  o.dump(name, methods)
32
31
  end
33
32
  end
34
33
 
35
- def dump_instance_methods(o, klass)
36
- maps = class_method_map(klass.ancestors)
37
- maps.each do |mod, methods|
38
- o.dump("#{mod}#methods", methods)
39
- end
40
- end
41
-
42
34
  def class_method_map(classes)
43
- dumped = Set.new
35
+ dumped = Array.new
44
36
  classes.reject { |mod| mod >= Object }.map do |mod|
45
- methods = mod.public_instance_methods(false).select { |m| dumped.add?(m) }
37
+ methods = mod.public_instance_methods(false).select do |m|
38
+ dumped.push(m) unless dumped.include?(m)
39
+ end
46
40
  [mod, methods]
47
41
  end.reverse
48
42
  end
@@ -9,6 +9,9 @@ module IRB
9
9
  end
10
10
 
11
11
  def execute(type = nil, arg = nil, &block)
12
+ # Please check IRB.init_config in lib/irb/init.rb that sets
13
+ # IRB.conf[:MEASURE_PROC] to register default "measure" methods,
14
+ # "measure :time" (abbreviated as "measure") and "measure :stackprof".
12
15
  case type
13
16
  when :off
14
17
  IRB.conf[:MEASURE] = nil
@@ -59,11 +59,21 @@ module IRB
59
59
  def find_end(file, first_line)
60
60
  return first_line unless File.exist?(file)
61
61
  lex = RubyLex.new
62
+ lines = File.read(file).lines[(first_line - 1)..-1]
63
+ tokens = RubyLex.ripper_lex_without_warning(lines.join)
64
+
62
65
  code = +""
63
- File.read(file).lines[(first_line - 1)..-1].each_with_index do |line, i|
64
- _ltype, _indent, continue, code_block_open = lex.check_state(code << line)
66
+ prev_tokens = []
67
+
68
+ # chunk with line number
69
+ tokens.chunk { |tok| tok[0][0] }.each do |lnum, chunk|
70
+ code << lines[lnum]
71
+ prev_tokens.concat chunk
72
+
73
+ continue = lex.process_continue(prev_tokens)
74
+ code_block_open = lex.check_code_block(code, prev_tokens)
65
75
  if !continue && !code_block_open
66
- return first_line + i
76
+ return first_line + lnum
67
77
  end
68
78
  end
69
79
  first_line
data/lib/irb/context.rb CHANGED
@@ -54,6 +54,7 @@ module IRB
54
54
  @use_multiline = nil
55
55
  end
56
56
  @use_colorize = IRB.conf[:USE_COLORIZE]
57
+ @use_autocomplete = IRB.conf[:USE_AUTOCOMPLETE]
57
58
  @verbose = IRB.conf[:VERBOSE]
58
59
  @io = nil
59
60
 
@@ -185,6 +186,8 @@ module IRB
185
186
  #
186
187
  # A copy of the default <code>IRB.conf[:USE_COLORIZE]</code>
187
188
  attr_reader :use_colorize
189
+ # A copy of the default <code>IRB.conf[:USE_AUTOCOMPLETE]</code>
190
+ attr_reader :use_autocomplete
188
191
  # A copy of the default <code>IRB.conf[:INSPECT_MODE]</code>
189
192
  attr_reader :inspect_mode
190
193
 
@@ -311,6 +314,8 @@ module IRB
311
314
  alias use_readline? use_singleline
312
315
  # Alias for #use_colorize
313
316
  alias use_colorize? use_colorize
317
+ # Alias for #use_autocomplete
318
+ alias use_autocomplete? use_autocomplete
314
319
  # Alias for #rc
315
320
  alias rc? rc
316
321
  alias ignore_sigint? ignore_sigint
data/lib/irb/init.rb CHANGED
@@ -45,6 +45,7 @@ module IRB # :nodoc:
45
45
 
46
46
  @CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod)
47
47
  @CONF[:USE_COLORIZE] = !ENV['NO_COLOR']
48
+ @CONF[:USE_AUTOCOMPLETE] = true
48
49
  @CONF[:INSPECT_MODE] = true
49
50
  @CONF[:USE_TRACER] = false
50
51
  @CONF[:USE_LOADER] = false
@@ -274,6 +275,10 @@ module IRB # :nodoc:
274
275
  @CONF[:USE_COLORIZE] = true
275
276
  when "--nocolorize"
276
277
  @CONF[:USE_COLORIZE] = false
278
+ when "--autocomplete"
279
+ @CONF[:USE_AUTOCOMPLETE] = true
280
+ when "--noautocomplete"
281
+ @CONF[:USE_AUTOCOMPLETE] = false
277
282
  when /^--prompt-mode(?:=(.+))?/, /^--prompt(?:=(.+))?/
278
283
  opt = $1 || argv.shift
279
284
  prompt_mode = opt.upcase.tr("-", "_").intern
@@ -14,6 +14,7 @@ require_relative 'magic-file'
14
14
  require_relative 'completion'
15
15
  require 'io/console'
16
16
  require 'reline'
17
+ require 'rdoc'
17
18
 
18
19
  module IRB
19
20
  STDIN_FILE_NAME = "(line)" # :nodoc:
@@ -294,6 +295,10 @@ module IRB
294
295
  end
295
296
  end
296
297
  Reline.dig_perfect_match_proc = IRB::InputCompletor::PerfectMatchedProc
298
+ Reline.autocompletion = IRB.conf[:USE_AUTOCOMPLETE]
299
+ if IRB.conf[:USE_AUTOCOMPLETE]
300
+ Reline.add_dialog_proc(:show_doc, SHOW_DOC_DIALOG, Reline::DEFAULT_DIALOG_CONTEXT)
301
+ end
297
302
  end
298
303
 
299
304
  def check_termination(&block)
@@ -308,6 +313,55 @@ module IRB
308
313
  @auto_indent_proc = block
309
314
  end
310
315
 
316
+ SHOW_DOC_DIALOG = ->() {
317
+ begin
318
+ require 'rdoc'
319
+ rescue LoadError
320
+ return nil
321
+ end
322
+ if just_cursor_moving and completion_journey_data.nil?
323
+ return nil
324
+ end
325
+ cursor_pos_to_render, result, pointer = context.pop(3)
326
+ return nil if result.nil? or pointer.nil?
327
+ name = result[pointer]
328
+ name = IRB::InputCompletor.retrieve_completion_data(name, doc_namespace: true)
329
+
330
+ driver = RDoc::RI::Driver.new
331
+ begin
332
+ name = driver.expand_name(name)
333
+ rescue RDoc::RI::Driver::NotFoundError
334
+ return nil
335
+ rescue
336
+ return nil # unknown error
337
+ end
338
+ doc = nil
339
+ used_for_class = false
340
+ if not name =~ /#|\./
341
+ found, klasses, includes, extends = driver.classes_and_includes_and_extends_for(name)
342
+ if not found.empty?
343
+ doc = driver.class_document(name, found, klasses, includes, extends)
344
+ used_for_class = true
345
+ end
346
+ end
347
+ unless used_for_class
348
+ doc = RDoc::Markup::Document.new
349
+ begin
350
+ driver.add_method(doc, name)
351
+ rescue RDoc::RI::Driver::NotFoundError
352
+ doc = nil
353
+ rescue
354
+ return nil # unknown error
355
+ end
356
+ end
357
+ return nil if doc.nil?
358
+ formatter = RDoc::Markup::ToAnsi.new
359
+ formatter.width = 40
360
+ str = doc.accept(formatter)
361
+
362
+ [Reline::CursorPos.new(cursor_pos_to_render.x + 40, cursor_pos_to_render.y + pointer), str.split("\n"), nil, '49']
363
+ }
364
+
311
365
  # Reads the next line from this input method.
312
366
  #
313
367
  # See IO#gets for more information.
@@ -30,6 +30,8 @@ Usage: irb.rb [options] [programfile] [arguments]
30
30
  --nosingleline Don't use singleline editor module
31
31
  --colorize Use colorization
32
32
  --nocolorize Don't use colorization
33
+ --autocomplete Use autocompletion
34
+ --noautocomplete Don't use autocompletion
33
35
  --prompt prompt-mode/--prompt-mode prompt-mode
34
36
  Switch prompt mode. Pre-defined prompt modes are
35
37
  `default', `simple', `xmp' and `inf-ruby'
@@ -29,6 +29,8 @@ Usage: irb.rb [options] [programfile] [arguments]
29
29
  --nosingleline シングルラインエディタを利用しない.
30
30
  --colorize 色付けを利用する.
31
31
  --nocolorize 色付けを利用しない.
32
+ --autocomplete オートコンプリートを利用する.
33
+ --noautocomplete オートコンプリートを利用しない.
32
34
  --prompt prompt-mode/--prompt-mode prompt-mode
33
35
  プロンプトモードを切替えます. 現在定義されているプ
34
36
  ロンプトモードは, default, simple, xmp, inf-rubyが
data/lib/irb/ruby-lex.rb CHANGED
@@ -30,26 +30,31 @@ class RubyLex
30
30
  @prompt = nil
31
31
  end
32
32
 
33
- def self.compile_with_errors_suppressed(code)
34
- line_no = 1
33
+ def self.compile_with_errors_suppressed(code, line_no: 1)
35
34
  begin
36
35
  result = yield code, line_no
37
36
  rescue ArgumentError
37
+ # Ruby can issue an error for the code if there is an
38
+ # incomplete magic comment for encoding in it. Force an
39
+ # expression with a new line before the code in this
40
+ # case to prevent magic comment handling. To make sure
41
+ # line numbers in the lexed code remain the same,
42
+ # decrease the line number by one.
38
43
  code = ";\n#{code}"
39
- line_no = 0
44
+ line_no -= 1
40
45
  result = yield code, line_no
41
46
  end
42
47
  result
43
48
  end
44
49
 
45
50
  # io functions
46
- def set_input(io, p = nil, &block)
51
+ def set_input(io, p = nil, context: nil, &block)
47
52
  @io = io
48
53
  if @io.respond_to?(:check_termination)
49
54
  @io.check_termination do |code|
50
55
  if Reline::IOGate.in_pasting?
51
56
  lex = RubyLex.new
52
- rest = lex.check_termination_in_prev_line(code)
57
+ rest = lex.check_termination_in_prev_line(code, context: context)
53
58
  if rest
54
59
  Reline.delete_text
55
60
  rest.bytes.reverse_each do |c|
@@ -61,7 +66,7 @@ class RubyLex
61
66
  end
62
67
  else
63
68
  code.gsub!(/\s*\z/, '').concat("\n")
64
- ltype, indent, continue, code_block_open = check_state(code)
69
+ ltype, indent, continue, code_block_open = check_state(code, context: context)
65
70
  if ltype or indent > 0 or continue or code_block_open
66
71
  false
67
72
  else
@@ -74,7 +79,7 @@ class RubyLex
74
79
  @io.dynamic_prompt do |lines|
75
80
  lines << '' if lines.empty?
76
81
  result = []
77
- tokens = self.class.ripper_lex_without_warning(lines.map{ |l| l + "\n" }.join)
82
+ tokens = self.class.ripper_lex_without_warning(lines.map{ |l| l + "\n" }.join, context: context)
78
83
  code = String.new
79
84
  partial_tokens = []
80
85
  unprocessed_tokens = []
@@ -86,7 +91,7 @@ class RubyLex
86
91
  t_str = t[2]
87
92
  t_str.each_line("\n") do |s|
88
93
  code << s << "\n"
89
- ltype, indent, continue, code_block_open = check_state(code, partial_tokens)
94
+ ltype, indent, continue, code_block_open = check_state(code, partial_tokens, context: context)
90
95
  result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
91
96
  line_num_offset += 1
92
97
  end
@@ -96,7 +101,7 @@ class RubyLex
96
101
  end
97
102
  end
98
103
  unless unprocessed_tokens.empty?
99
- ltype, indent, continue, code_block_open = check_state(code, unprocessed_tokens)
104
+ ltype, indent, continue, code_block_open = check_state(code, unprocessed_tokens, context: context)
100
105
  result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
101
106
  end
102
107
  result
@@ -129,15 +134,25 @@ class RubyLex
129
134
  :on_param_error
130
135
  ]
131
136
 
132
- def self.ripper_lex_without_warning(code)
137
+ def self.ripper_lex_without_warning(code, context: nil)
133
138
  verbose, $VERBOSE = $VERBOSE, nil
139
+ if context
140
+ lvars = context&.workspace&.binding&.local_variables
141
+ if lvars && !lvars.empty?
142
+ code = "#{lvars.join('=')}=nil\n#{code}"
143
+ line_no = 0
144
+ else
145
+ line_no = 1
146
+ end
147
+ end
134
148
  tokens = nil
135
- compile_with_errors_suppressed(code) do |inner_code, line_no|
149
+ compile_with_errors_suppressed(code, line_no: line_no) do |inner_code, line_no|
136
150
  lexer = Ripper::Lexer.new(inner_code, '-', line_no)
137
151
  if lexer.respond_to?(:scan) # Ruby 2.7+
138
152
  tokens = []
139
153
  pos_to_index = {}
140
154
  lexer.scan.each do |t|
155
+ next if t.pos.first == 0
141
156
  if pos_to_index.has_key?(t[0])
142
157
  index = pos_to_index[t[0]]
143
158
  found_tk = tokens[index]
@@ -182,7 +197,7 @@ class RubyLex
182
197
  if @io.respond_to?(:auto_indent) and context.auto_indent_mode
183
198
  @io.auto_indent do |lines, line_index, byte_pointer, is_newline|
184
199
  if is_newline
185
- @tokens = self.class.ripper_lex_without_warning(lines[0..line_index].join("\n"))
200
+ @tokens = self.class.ripper_lex_without_warning(lines[0..line_index].join("\n"), context: context)
186
201
  prev_spaces = find_prev_spaces(line_index)
187
202
  depth_difference = check_newline_depth_difference
188
203
  depth_difference = 0 if depth_difference < 0
@@ -191,7 +206,7 @@ class RubyLex
191
206
  code = line_index.zero? ? '' : lines[0..(line_index - 1)].map{ |l| l + "\n" }.join
192
207
  last_line = lines[line_index]&.byteslice(0, byte_pointer)
193
208
  code += last_line if last_line
194
- @tokens = self.class.ripper_lex_without_warning(code)
209
+ @tokens = self.class.ripper_lex_without_warning(code, context: context)
195
210
  corresponding_token_depth = check_corresponding_token_depth
196
211
  if corresponding_token_depth
197
212
  corresponding_token_depth
@@ -203,8 +218,8 @@ class RubyLex
203
218
  end
204
219
  end
205
220
 
206
- def check_state(code, tokens = nil)
207
- tokens = self.class.ripper_lex_without_warning(code) unless tokens
221
+ def check_state(code, tokens = nil, context: nil)
222
+ tokens = self.class.ripper_lex_without_warning(code, context: context) unless tokens
208
223
  ltype = process_literal_type(tokens)
209
224
  indent = process_nesting_level(tokens)
210
225
  continue = process_continue(tokens)
@@ -700,7 +715,7 @@ class RubyLex
700
715
  start_token << t
701
716
  end_type << :on_regexp_end
702
717
  when :on_symbeg
703
- acceptable_single_tokens = %i{on_ident on_const on_op on_cvar on_ivar on_gvar on_kw}
718
+ acceptable_single_tokens = %i{on_ident on_const on_op on_cvar on_ivar on_gvar on_kw on_int}
704
719
  if (i + 1) < tokens.size and acceptable_single_tokens.all?{ |st| tokens[i + 1][1] != st }
705
720
  start_token << t
706
721
  end_type << :on_tstring_end
@@ -754,8 +769,8 @@ class RubyLex
754
769
  end
755
770
  end
756
771
 
757
- def check_termination_in_prev_line(code)
758
- tokens = self.class.ripper_lex_without_warning(code)
772
+ def check_termination_in_prev_line(code, context: nil)
773
+ tokens = self.class.ripper_lex_without_warning(code, context: context)
759
774
  past_first_newline = false
760
775
  index = tokens.rindex do |t|
761
776
  # traverse first token before last line
data/lib/irb/version.rb CHANGED
@@ -11,7 +11,7 @@
11
11
  #
12
12
 
13
13
  module IRB # :nodoc:
14
- VERSION = "1.3.6"
14
+ VERSION = "1.3.8.pre.3"
15
15
  @RELEASE_VERSION = VERSION
16
- @LAST_UPDATE_DATE = "2021-06-19"
16
+ @LAST_UPDATE_DATE = "2021-08-30"
17
17
  end
data/lib/irb.rb CHANGED
@@ -72,6 +72,8 @@ require_relative "irb/easter-egg"
72
72
  # --nosingleline Don't use singleline editor module
73
73
  # --colorize Use colorization
74
74
  # --nocolorize Don't use colorization
75
+ # --autocomplete Use autocompletion
76
+ # --noautocomplete Don't use autocompletion
75
77
  # --prompt prompt-mode/--prompt-mode prompt-mode
76
78
  # Switch prompt mode. Pre-defined prompt modes are
77
79
  # `default', `simple', `xmp' and `inf-ruby'
@@ -114,6 +116,7 @@ require_relative "irb/easter-egg"
114
116
  # IRB.conf[:USE_SINGLELINE] = nil
115
117
  # IRB.conf[:USE_COLORIZE] = true
116
118
  # IRB.conf[:USE_TRACER] = false
119
+ # IRB.conf[:USE_AUTOCOMPLETE] = true
117
120
  # IRB.conf[:IGNORE_SIGINT] = true
118
121
  # IRB.conf[:IGNORE_EOF] = false
119
122
  # IRB.conf[:PROMPT_MODE] = :DEFAULT
@@ -524,7 +527,7 @@ module IRB
524
527
  @context.io.prompt
525
528
  end
526
529
 
527
- @scanner.set_input(@context.io) do
530
+ @scanner.set_input(@context.io, context: @context) do
528
531
  signal_status(:IN_INPUT) do
529
532
  if l = @context.io.gets
530
533
  print l if @context.verbose?
data/man/irb.1 CHANGED
@@ -18,6 +18,7 @@
18
18
  .Op Fl - Ns Oo no Oc Ns singleline
19
19
  .Op Fl - Ns Oo no Oc Ns echo
20
20
  .Op Fl - Ns Oo no Oc Ns colorize
21
+ .Op Fl - Ns Oo no Oc Ns autocomplete
21
22
  .Op Fl - Ns Oo no Oc Ns verbose
22
23
  .Op Fl -prompt Ar mode
23
24
  .Op Fl -prompt-mode Ar mode
@@ -118,6 +119,13 @@ Use colorization.
118
119
  Don't use colorization.
119
120
  .Pp
120
121
  .Pp
122
+ .It Fl -autocomplete
123
+ Use autocompletion.
124
+ .Pp
125
+ .It Fl -noautocomplete
126
+ Don't use autocompletion.
127
+ .Pp
128
+ .Pp
121
129
  .It Fl -verbose
122
130
  Show details.
123
131
  .Pp
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.3.8.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keiju ISHITSUKA
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-21 00:00:00.000000000 Z
11
+ date: 2021-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reline
15
- prerelease: false
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - ">="
19
18
  - !ruby/object:Gem::Version
20
- version: 0.2.5
19
+ version: 0.2.8.pre.3
21
20
  type: :runtime
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.2.5
26
+ version: 0.2.8.pre.3
27
27
  description: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
28
28
  email:
29
29
  - keiju@ruby-lang.org
@@ -97,7 +97,7 @@ licenses:
97
97
  - Ruby
98
98
  - BSD-2-Clause
99
99
  metadata: {}
100
- post_install_message:
100
+ post_install_message:
101
101
  rdoc_options: []
102
102
  require_paths:
103
103
  - lib
@@ -108,12 +108,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  version: '2.5'
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - ">="
111
+ - - ">"
112
112
  - !ruby/object:Gem::Version
113
- version: '0'
113
+ version: 1.3.1
114
114
  requirements: []
115
- rubygems_version: 3.1.4
116
- signing_key:
115
+ rubygems_version: 3.2.22
116
+ signing_key:
117
117
  specification_version: 4
118
118
  summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
119
119
  test_files: []