irb 1.3.6 → 1.4.1

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: be0bdb184f8483785b83b91bc57339e994a15b2d1435720e8f17b9f04b2b924e
4
+ data.tar.gz: 02ca5b9f06cedc077c79f07ad33765225736f9d7ffa9bb93671cf739131a2d9c
5
5
  SHA512:
6
- metadata.gz: 2b040a17c30df8f8512c176acfb1884237c050d5e4dab769f08aa75a00da23dcba1be9fab15d37671e4617abee3f6279363fed80c0980687cdcbed417bf5e3f4
7
- data.tar.gz: 0a021169f28c114aeac7b7375eda932cdd4b357056b092a8499a61da6d4d1b01d019591e94eaaf134392a8b5c92cd632d0dfc7bf4b243831df93cc0514cd2eb1
6
+ metadata.gz: faa52653f45b98a0ce82b215110376e3cac3faefa34928a50067e101c3171a0fbc492ba3b7a23334ac81f23448526e6931fca45925a07ab914aa2634c8e1de9a
7
+ data.tar.gz: 4da73a1293f021bcb3a0ed996ac4f48f3c73884d34efa438987b230cda72ce3aa0c6ac67865e57655cdcc8ffd49cb6ca267c564711345247ed889857f60156c1
data/Gemfile CHANGED
@@ -1,15 +1,13 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
3
  gemspec
6
4
 
7
5
  group :development do
8
- gem "bundler"
9
6
  is_unix = RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
10
7
  is_truffleruby = RUBY_DESCRIPTION =~ /truffleruby/
11
- gem 'vterm', '>= 0.0.5' if is_unix && ENV['WITH_VTERM']
12
- gem 'yamatanooroti', '>= 0.0.6'
8
+ gem "vterm", ">= 0.0.5" if is_unix && ENV['WITH_VTERM']
9
+ gem "yamatanooroti", ">= 0.0.6"
13
10
  gem "rake"
14
11
  gem "stackprof" if is_unix && !is_truffleruby
12
+ gem "test-unit"
15
13
  end
data/Rakefile CHANGED
@@ -4,14 +4,23 @@ require "rake/testtask"
4
4
  Rake::TestTask.new(:test) do |t|
5
5
  t.libs << "test" << "test/lib"
6
6
  t.libs << "lib"
7
+ t.ruby_opts << "-rhelper"
7
8
  t.test_files = FileList["test/irb/test_*.rb"]
8
9
  end
9
10
 
10
11
  Rake::TestTask.new(:test_yamatanooroti) do |t|
11
- t.libs << 'test'
12
+ t.libs << 'test' << "test/lib"
12
13
  t.libs << 'lib'
13
14
  #t.loader = :direct
15
+ t.ruby_opts << "-rhelper"
14
16
  t.pattern = 'test/irb/yamatanooroti/test_*.rb'
15
17
  end
16
18
 
19
+ task :sync_tool do
20
+ require 'fileutils'
21
+ FileUtils.cp "../ruby/tool/lib/core_assertions.rb", "./test/lib"
22
+ FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
23
+ FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
24
+ end
25
+
17
26
  task :default => :test
data/doc/irb/irb.rd.ja CHANGED
@@ -40,15 +40,24 @@ 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
+ --echo-on-assignment
55
+ 代入時に実行結果を表示する.
56
+ --noecho-on-assignment
57
+ 代入時に実行結果を表示しない.
58
+ --truncate-echo-on-assignment
59
+ 代入時に省略された実行結果を表示する(デフォルト).
60
+ --inspect 結果出力にinspectを用いる.
52
61
  --noinspect 結果出力にinspectを用いない.
53
62
  --singleline シングルラインエディタを利用する.
54
63
  --nosingleline シングルラインエディタを利用しない. デフォルトの動
@@ -56,23 +65,30 @@ irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本
56
65
  用しようとする.
57
66
  --colorize 色付けを利用する.
58
67
  --nocolorize 色付けを利用しない.
68
+ --autocomplete オートコンプリートを利用する.
69
+ --noautocomplete オートコンプリートを利用しない.
59
70
  --prompt prompt-mode
60
71
  --prompt-mode prompt-mode
61
72
  プロンプトモードを切替えます. 現在定義されているプ
62
73
  ロンプトモードは, default, simple, xmp, inf-rubyが
63
- 用意されています. デフォルトはdefaultプロンプトモー
64
- ドになっています.
65
-
74
+ 用意されています.
66
75
  --inf-ruby-mode emacsのinf-ruby-mode用のプロンプト表示を行なう. 特
67
76
  に指定がない限り, ラインエディタは使わなくなる.
68
77
  --simple-prompt
69
78
  非常にシンプルなプロンプトを用いるモードです.
70
79
  --noprompt プロンプト表示を行なわない.
80
+ --single-irb irb 中で self を実行して得られるオブジェクトをサ
81
+ ブ irb と共有する.
71
82
  --tracer コマンド実行時にトレースを行なう.
72
83
  --back-trace-limit n
73
84
  バックトレース表示をバックトレースの頭から n, 後ろ
74
85
  からnだけ行なう. デフォルトは16
75
- -v, --version irbのバージョンを表示する
86
+
87
+ --verbose 詳細なメッセージを出力する.
88
+ --noverbose 詳細なメッセージを出力しない(デフォルト).
89
+ -v, --version irbのバージョンを表示する.
90
+ -h, --help irb のヘルプを表示する.
91
+ -- 以降のコマンドライン引数をオプションとして扱わない.
76
92
 
77
93
  = コンフィギュレーション
78
94
 
@@ -137,12 +153,12 @@ PROMPT_I, PROMPT_N, PROMPT_S, PROMPT_Cは, フォーマットを指定します.
137
153
 
138
154
  例えば, デフォルトのプロンプトモードは:
139
155
 
140
- IRB.conf[:PROMPT_MODE][:DEFAULT] = {
156
+ IRB.conf[:PROMPT][:DEFAULT] = {
141
157
  :PROMPT_I => "%N(%m):%03n:%i> ",
142
158
  :PROMPT_N => "%N(%m):%03n:%i> ",
143
159
  :PROMPT_S => "%N(%m):%03n:%i%l ",
144
160
  :PROMPT_C => "%N(%m):%03n:%i* ",
145
- :RETURN => "%s\n"
161
+ :RETURN => "=> %s\n"
146
162
  }
147
163
 
148
164
  となっています.
@@ -374,7 +390,7 @@ rubyでは, 以下のプログラムはエラーになります.
374
390
  パイルしてローカル変数を決定するからです. それに対し, irbは実行可能に
375
391
  なる(式が閉じる)と自動的に評価しているからです. 上記の例では,
376
392
 
377
- evel "foo = 0"
393
+ eval "foo = 0"
378
394
 
379
395
  を行なった時点で評価を行ない, その時点で変数が定義されるため, 次式で
380
396
  変数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.3.0"
40
40
  end
data/lib/irb/cmd/help.rb CHANGED
@@ -17,7 +17,8 @@ module IRB
17
17
  class Help < Nop
18
18
  def execute(*names)
19
19
  require 'rdoc/ri/driver'
20
- IRB::ExtendCommand::Help.const_set(:Ri, RDoc::RI::Driver.new)
20
+ opts = RDoc::RI::Driver.process_args([])
21
+ IRB::ExtendCommand::Help.const_set(:Ri, RDoc::RI::Driver.new(opts))
21
22
  rescue LoadError, SystemExit
22
23
  IRB::ExtendCommand::Help.remove_method(:execute)
23
24
  # raise NoMethodError in ensure
data/lib/irb/cmd/info.rb CHANGED
@@ -14,6 +14,13 @@ 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
+ str += "East Asian Ambiguous Width: #{Reline.ambiguous_width.inspect}\n"
20
+ if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
21
+ codepage = `chcp`.b.sub(/.*: (\d+)\n/, '\1')
22
+ str += "Code page: #{codepage}\n"
23
+ end
17
24
  str
18
25
  end
19
26
  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,18 @@ 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
- 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)
62
+ lines = File.read(file).lines[(first_line - 1)..-1]
63
+ tokens = RubyLex.ripper_lex_without_warning(lines.join)
64
+ prev_tokens = []
65
+
66
+ # chunk with line number
67
+ tokens.chunk { |tok| tok.pos[0] }.each do |lnum, chunk|
68
+ code = lines[0..lnum].join
69
+ prev_tokens.concat chunk
70
+ continue = lex.process_continue(prev_tokens)
71
+ code_block_open = lex.check_code_block(code, prev_tokens)
65
72
  if !continue && !code_block_open
66
- return first_line + i
73
+ return first_line + lnum
67
74
  end
68
75
  end
69
76
  first_line
@@ -38,16 +38,48 @@ module IRB
38
38
 
39
39
  BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("
40
40
 
41
- def self.retrieve_files_to_require_from_load_path
42
- @@files_from_load_path ||= $LOAD_PATH.flat_map { |path|
43
- begin
44
- Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: path)
45
- rescue Errno::ENOENT
46
- []
41
+ def self.absolute_path?(p) # TODO Remove this method after 2.6 EOL.
42
+ if File.respond_to?(:absolute_path?)
43
+ File.absolute_path?(p)
44
+ else
45
+ if File.absolute_path(p) == p
46
+ true
47
+ else
48
+ false
47
49
  end
48
- }.uniq.map { |path|
49
- path.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '')
50
- }
50
+ end
51
+ end
52
+
53
+ def self.retrieve_gem_and_system_load_path
54
+ gem_paths = Gem::Specification.latest_specs(true).map { |s|
55
+ s.require_paths.map { |p|
56
+ if absolute_path?(p)
57
+ p
58
+ else
59
+ File.join(s.full_gem_path, p)
60
+ end
61
+ }
62
+ }.flatten if defined?(Gem::Specification)
63
+ (gem_paths.to_a | $LOAD_PATH).sort
64
+ end
65
+
66
+ def self.retrieve_files_to_require_from_load_path
67
+ @@files_from_load_path ||=
68
+ (
69
+ shortest = []
70
+ rest = retrieve_gem_and_system_load_path.each_with_object([]) { |path, result|
71
+ begin
72
+ names = Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: path)
73
+ rescue Errno::ENOENT
74
+ nil
75
+ end
76
+ next if names.empty?
77
+ names.map! { |n| n.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '') }.sort!
78
+ shortest << names.shift
79
+ result.concat(names)
80
+ }
81
+ shortest.sort! | rest
82
+ )
51
83
  end
52
84
 
53
85
  def self.retrieve_files_to_require_relative_from_current_dir
@@ -160,12 +192,12 @@ module IRB
160
192
  sym = $1
161
193
  candidates = Symbol.all_symbols.collect do |s|
162
194
  ":" + s.id2name.encode(Encoding.default_external)
163
- rescue Encoding::UndefinedConversionError
195
+ rescue EncodingError
164
196
  # ignore
165
197
  end
166
198
  candidates.grep(/^#{Regexp.quote(sym)}/)
167
199
 
168
- when /^::([A-Z][^:\.\(]*)$/
200
+ when /^::([A-Z][^:\.\(\)]*)$/
169
201
  # Absolute Constant or class methods
170
202
  receiver = $1
171
203
  candidates = Object.constants.collect{|m| m.to_s}
@@ -258,7 +290,7 @@ module IRB
258
290
  all_gvars.grep(Regexp.new(Regexp.quote(gvar)))
259
291
  end
260
292
 
261
- when /^([^."].*)(\.|::)([^.]*)$/
293
+ when /^([^.:"].*)(\.|::)([^.]*)$/
262
294
  # variable.func or func.func
263
295
  receiver = $1
264
296
  sep = $2
@@ -296,7 +328,8 @@ module IRB
296
328
  candidates.uniq!
297
329
  end
298
330
  if doc_namespace
299
- "#{rec.class.name}#{sep}#{candidates.find{ |i| i == message }}"
331
+ rec_class = rec.is_a?(Module) ? rec : rec.class
332
+ "#{rec_class.name}#{sep}#{candidates.find{ |i| i == message }}"
300
333
  else
301
334
  select_message(receiver, message, candidates, sep)
302
335
  end
@@ -315,12 +348,19 @@ module IRB
315
348
  end
316
349
 
317
350
  else
318
- candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
319
- candidates |= ReservedWords
320
-
321
351
  if doc_namespace
322
- candidates.find{ |i| i == input }
352
+ vars = eval("local_variables | instance_variables", bind).collect{|m| m.to_s}
353
+ perfect_match_var = vars.find{|m| m.to_s == input}
354
+ if perfect_match_var
355
+ eval("#{perfect_match_var}.class.name", bind)
356
+ else
357
+ candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
358
+ candidates |= ReservedWords
359
+ candidates.find{ |i| i == input }
360
+ end
323
361
  else
362
+ candidates = eval("methods | private_methods | local_variables | instance_variables | self.class.constants", bind).collect{|m| m.to_s}
363
+ candidates |= ReservedWords
324
364
  candidates.grep(/^#{Regexp.quote(input)}/)
325
365
  end
326
366
  end
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
 
@@ -124,6 +125,8 @@ module IRB
124
125
  end
125
126
  self.save_history = IRB.conf[:SAVE_HISTORY] if IRB.conf[:SAVE_HISTORY]
126
127
 
128
+ @extra_doc_dirs = IRB.conf[:EXTRA_DOC_DIRS]
129
+
127
130
  @echo = IRB.conf[:ECHO]
128
131
  if @echo.nil?
129
132
  @echo = true
@@ -147,18 +150,18 @@ module IRB
147
150
 
148
151
  # The toplevel workspace, see #home_workspace
149
152
  attr_reader :workspace_home
150
- # WorkSpace in the current context
153
+ # WorkSpace in the current context.
151
154
  attr_accessor :workspace
152
- # The current thread in this context
155
+ # The current thread in this context.
153
156
  attr_reader :thread
154
- # The current input method
157
+ # The current input method.
155
158
  #
156
159
  # Can be either StdioInputMethod, ReadlineInputMethod,
157
160
  # ReidlineInputMethod, FileInputMethod or other specified when the
158
161
  # context is created. See ::new for more # information on +input_method+.
159
162
  attr_accessor :io
160
163
 
161
- # Current irb session
164
+ # Current irb session.
162
165
  attr_accessor :irb
163
166
  # A copy of the default <code>IRB.conf[:AP_NAME]</code>
164
167
  attr_accessor :ap_name
@@ -185,20 +188,22 @@ module IRB
185
188
  #
186
189
  # A copy of the default <code>IRB.conf[:USE_COLORIZE]</code>
187
190
  attr_reader :use_colorize
191
+ # A copy of the default <code>IRB.conf[:USE_AUTOCOMPLETE]</code>
192
+ attr_reader :use_autocomplete
188
193
  # A copy of the default <code>IRB.conf[:INSPECT_MODE]</code>
189
194
  attr_reader :inspect_mode
190
195
 
191
196
  # A copy of the default <code>IRB.conf[:PROMPT_MODE]</code>
192
197
  attr_reader :prompt_mode
193
- # Standard IRB prompt
198
+ # Standard IRB prompt.
194
199
  #
195
200
  # See IRB@Customizing+the+IRB+Prompt for more information.
196
201
  attr_accessor :prompt_i
197
- # IRB prompt for continuated strings
202
+ # IRB prompt for continuated strings.
198
203
  #
199
204
  # See IRB@Customizing+the+IRB+Prompt for more information.
200
205
  attr_accessor :prompt_s
201
- # IRB prompt for continuated statement (e.g. immediately after an +if+)
206
+ # IRB prompt for continuated statement. (e.g. immediately after an +if+)
202
207
  #
203
208
  # See IRB@Customizing+the+IRB+Prompt for more information.
204
209
  attr_accessor :prompt_c
@@ -238,6 +243,9 @@ module IRB
238
243
  #
239
244
  # If set to +false+, <code>^D</code> will quit irb.
240
245
  attr_accessor :ignore_eof
246
+ # Specify the installation locations of the ri file to be displayed in the
247
+ # document dialog.
248
+ attr_accessor :extra_doc_dirs
241
249
  # Whether to echo the return value to output or not.
242
250
  #
243
251
  # Uses <code>IRB.conf[:ECHO]</code> if available, or defaults to +true+.
@@ -249,7 +257,7 @@ module IRB
249
257
  # puts "omg"
250
258
  # # omg
251
259
  attr_accessor :echo
252
- # Whether to echo for assignment expressions
260
+ # Whether to echo for assignment expressions.
253
261
  #
254
262
  # If set to +false+, the value of assignment will not be shown.
255
263
  #
@@ -261,13 +269,28 @@ module IRB
261
269
  #
262
270
  # a = "omg"
263
271
  # #=> omg
272
+ #
264
273
  # a = "omg" * 10
265
274
  # #=> omgomgomgomgomgomgomg...
275
+ #
266
276
  # IRB.CurrentContext.echo_on_assignment = false
267
277
  # a = "omg"
278
+ #
268
279
  # IRB.CurrentContext.echo_on_assignment = true
269
- # a = "omg"
280
+ # a = "omg" * 10
270
281
  # #=> omgomgomgomgomgomgomgomgomgomg
282
+ #
283
+ # To set the behaviour of showing on assignment in irb:
284
+ #
285
+ # IRB.conf[:ECHO_ON_ASSIGNMENT] = :truncate or true or false
286
+ #
287
+ # or
288
+ #
289
+ # irb_context.echo_on_assignment = :truncate or true or false
290
+ #
291
+ # or
292
+ #
293
+ # IRB.CurrentContext.echo_on_assignment = :truncate or true or false
271
294
  attr_accessor :echo_on_assignment
272
295
  # Whether a newline is put before multiline output.
273
296
  #
@@ -311,6 +334,8 @@ module IRB
311
334
  alias use_readline? use_singleline
312
335
  # Alias for #use_colorize
313
336
  alias use_colorize? use_colorize
337
+ # Alias for #use_autocomplete
338
+ alias use_autocomplete? use_autocomplete
314
339
  # Alias for #rc
315
340
  alias rc? rc
316
341
  alias ignore_sigint? ignore_sigint
@@ -366,6 +391,7 @@ module IRB
366
391
  @prompt_c = pconf[:PROMPT_C]
367
392
  @prompt_n = pconf[:PROMPT_N]
368
393
  @return_format = pconf[:RETURN]
394
+ @return_format = "%s\n" if @return_format == nil
369
395
  if ai = pconf.include?(:AUTO_INDENT)
370
396
  @auto_indent_mode = ai
371
397
  else
@@ -458,6 +484,8 @@ module IRB
458
484
  # Exits the current session, see IRB.irb_exit
459
485
  def exit(ret = 0)
460
486
  IRB.irb_exit(@irb, ret)
487
+ rescue UncaughtThrowError
488
+ super
461
489
  end
462
490
 
463
491
  NOPRINTING_IVARS = ["@last_value"] # :nodoc:
data/lib/irb/init.rb CHANGED
@@ -45,11 +45,13 @@ 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
51
52
  @CONF[:IGNORE_SIGINT] = true
52
53
  @CONF[:IGNORE_EOF] = false
54
+ @CONF[:EXTRA_DOC_DIRS] = []
53
55
  @CONF[:ECHO] = nil
54
56
  @CONF[:ECHO_ON_ASSIGNMENT] = nil
55
57
  @CONF[:VERBOSE] = nil
@@ -256,6 +258,9 @@ module IRB # :nodoc:
256
258
  @CONF[:USE_MULTILINE] = true
257
259
  when "--nomultiline", "--noreidline"
258
260
  @CONF[:USE_MULTILINE] = false
261
+ when /^--extra-doc-dir(?:=(.+))?/
262
+ opt = $1 || argv.shift
263
+ @CONF[:EXTRA_DOC_DIRS] << opt
259
264
  when "--echo"
260
265
  @CONF[:ECHO] = true
261
266
  when "--noecho"
@@ -274,6 +279,10 @@ module IRB # :nodoc:
274
279
  @CONF[:USE_COLORIZE] = true
275
280
  when "--nocolorize"
276
281
  @CONF[:USE_COLORIZE] = false
282
+ when "--autocomplete"
283
+ @CONF[:USE_AUTOCOMPLETE] = true
284
+ when "--noautocomplete"
285
+ @CONF[:USE_AUTOCOMPLETE] = false
277
286
  when /^--prompt-mode(?:=(.+))?/, /^--prompt(?:=(.+))?/
278
287
  opt = $1 || argv.shift
279
288
  prompt_mode = opt.upcase.tr("-", "_").intern