irb 1.4.0 → 1.4.2

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.
@@ -47,7 +47,7 @@ module IRB # :nodoc:
47
47
 
48
48
  @EXTEND_COMMANDS = [
49
49
  [
50
- :irb_current_working_workspace, :CurrentWorkingWorkspace, "irb/cmd/chws",
50
+ :irb_current_working_workspace, :CurrentWorkingWorkspace, "cmd/chws",
51
51
  [:irb_print_working_workspace, OVERRIDE_ALL],
52
52
  [:irb_cwws, OVERRIDE_ALL],
53
53
  [:irb_pwws, OVERRIDE_ALL],
@@ -59,7 +59,7 @@ module IRB # :nodoc:
59
59
  [:irb_pwb, OVERRIDE_ALL],
60
60
  ],
61
61
  [
62
- :irb_change_workspace, :ChangeWorkspace, "irb/cmd/chws",
62
+ :irb_change_workspace, :ChangeWorkspace, "cmd/chws",
63
63
  [:irb_chws, OVERRIDE_ALL],
64
64
  [:irb_cws, OVERRIDE_ALL],
65
65
  [:chws, NO_OVERRIDE],
@@ -70,13 +70,13 @@ module IRB # :nodoc:
70
70
  ],
71
71
 
72
72
  [
73
- :irb_workspaces, :Workspaces, "irb/cmd/pushws",
73
+ :irb_workspaces, :Workspaces, "cmd/pushws",
74
74
  [:workspaces, NO_OVERRIDE],
75
75
  [:irb_bindings, OVERRIDE_ALL],
76
76
  [:bindings, NO_OVERRIDE],
77
77
  ],
78
78
  [
79
- :irb_push_workspace, :PushWorkspace, "irb/cmd/pushws",
79
+ :irb_push_workspace, :PushWorkspace, "cmd/pushws",
80
80
  [:irb_pushws, OVERRIDE_ALL],
81
81
  [:pushws, NO_OVERRIDE],
82
82
  [:irb_push_binding, OVERRIDE_ALL],
@@ -84,7 +84,7 @@ module IRB # :nodoc:
84
84
  [:pushb, NO_OVERRIDE],
85
85
  ],
86
86
  [
87
- :irb_pop_workspace, :PopWorkspace, "irb/cmd/pushws",
87
+ :irb_pop_workspace, :PopWorkspace, "cmd/pushws",
88
88
  [:irb_popws, OVERRIDE_ALL],
89
89
  [:popws, NO_OVERRIDE],
90
90
  [:irb_pop_binding, OVERRIDE_ALL],
@@ -93,55 +93,55 @@ module IRB # :nodoc:
93
93
  ],
94
94
 
95
95
  [
96
- :irb_load, :Load, "irb/cmd/load"],
96
+ :irb_load, :Load, "cmd/load"],
97
97
  [
98
- :irb_require, :Require, "irb/cmd/load"],
98
+ :irb_require, :Require, "cmd/load"],
99
99
  [
100
- :irb_source, :Source, "irb/cmd/load",
100
+ :irb_source, :Source, "cmd/load",
101
101
  [:source, NO_OVERRIDE],
102
102
  ],
103
103
 
104
104
  [
105
- :irb, :IrbCommand, "irb/cmd/subirb"],
105
+ :irb, :IrbCommand, "cmd/subirb"],
106
106
  [
107
- :irb_jobs, :Jobs, "irb/cmd/subirb",
107
+ :irb_jobs, :Jobs, "cmd/subirb",
108
108
  [:jobs, NO_OVERRIDE],
109
109
  ],
110
110
  [
111
- :irb_fg, :Foreground, "irb/cmd/subirb",
111
+ :irb_fg, :Foreground, "cmd/subirb",
112
112
  [:fg, NO_OVERRIDE],
113
113
  ],
114
114
  [
115
- :irb_kill, :Kill, "irb/cmd/subirb",
115
+ :irb_kill, :Kill, "cmd/subirb",
116
116
  [:kill, OVERRIDE_PRIVATE_ONLY],
117
117
  ],
118
118
 
119
119
  [
120
- :irb_help, :Help, "irb/cmd/help",
120
+ :irb_help, :Help, "cmd/help",
121
121
  [:help, NO_OVERRIDE],
122
122
  ],
123
123
 
124
124
  [
125
- :irb_info, :Info, "irb/cmd/info"
125
+ :irb_info, :Info, "cmd/info"
126
126
  ],
127
127
 
128
128
  [
129
- :irb_ls, :Ls, "irb/cmd/ls",
129
+ :irb_ls, :Ls, "cmd/ls",
130
130
  [:ls, NO_OVERRIDE],
131
131
  ],
132
132
 
133
133
  [
134
- :irb_measure, :Measure, "irb/cmd/measure",
134
+ :irb_measure, :Measure, "cmd/measure",
135
135
  [:measure, NO_OVERRIDE],
136
136
  ],
137
137
 
138
138
  [
139
- :irb_show_source, :ShowSource, "irb/cmd/show_source",
139
+ :irb_show_source, :ShowSource, "cmd/show_source",
140
140
  [:show_source, NO_OVERRIDE],
141
141
  ],
142
142
 
143
143
  [
144
- :irb_whereami, :Whereami, "irb/cmd/whereami",
144
+ :irb_whereami, :Whereami, "cmd/whereami",
145
145
  [:whereami, NO_OVERRIDE],
146
146
  ],
147
147
 
@@ -187,7 +187,7 @@ module IRB # :nodoc:
187
187
  kwargs = ", **kwargs" if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0"
188
188
  line = __LINE__; eval %[
189
189
  def #{cmd_name}(*opts#{kwargs}, &b)
190
- require "#{load_file}"
190
+ require_relative "#{load_file}"
191
191
  arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity
192
192
  args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
193
193
  args << "*opts#{kwargs}" if arity < 0
@@ -235,7 +235,7 @@ module IRB # :nodoc:
235
235
  alias_method to, from
236
236
  }
237
237
  else
238
- print "irb: warn: can't alias #{to} from #{from}.\n"
238
+ Kernel.print "irb: warn: can't alias #{to} from #{from}.\n"
239
239
  end
240
240
  end
241
241
 
@@ -262,10 +262,10 @@ module IRB # :nodoc:
262
262
  CE = ContextExtender # :nodoc:
263
263
 
264
264
  @EXTEND_COMMANDS = [
265
- [:eval_history=, "irb/ext/history.rb"],
266
- [:use_tracer=, "irb/ext/tracer.rb"],
267
- [:use_loader=, "irb/ext/use-loader.rb"],
268
- [:save_history=, "irb/ext/save-history.rb"],
265
+ [:eval_history=, "ext/history.rb"],
266
+ [:use_tracer=, "ext/tracer.rb"],
267
+ [:use_loader=, "ext/use-loader.rb"],
268
+ [:save_history=, "ext/save-history.rb"],
269
269
  ]
270
270
 
271
271
  # Installs the default context extensions as irb commands:
@@ -288,7 +288,7 @@ module IRB # :nodoc:
288
288
  line = __LINE__; Context.module_eval %[
289
289
  def #{cmd_name}(*opts, &b)
290
290
  Context.module_eval {remove_method(:#{cmd_name})}
291
- require "#{load_file}"
291
+ require_relative "#{load_file}"
292
292
  __send__ :#{cmd_name}, *opts, &b
293
293
  end
294
294
  for ali in aliases
data/lib/irb/init.rb CHANGED
@@ -289,6 +289,10 @@ module IRB # :nodoc:
289
289
  @CONF[:PROMPT_MODE] = prompt_mode
290
290
  when "--noprompt"
291
291
  @CONF[:PROMPT_MODE] = :NULL
292
+ when "--script"
293
+ noscript = false
294
+ when "--noscript"
295
+ noscript = true
292
296
  when "--inf-ruby-mode"
293
297
  @CONF[:PROMPT_MODE] = :INF_RUBY
294
298
  when "--sample-book-mode", "--simple-prompt"
@@ -309,16 +313,20 @@ module IRB # :nodoc:
309
313
  IRB.print_usage
310
314
  exit 0
311
315
  when "--"
312
- if opt = argv.shift
316
+ if !noscript && (opt = argv.shift)
313
317
  @CONF[:SCRIPT] = opt
314
318
  $0 = opt
315
319
  end
316
320
  break
317
- when /^-/
321
+ when /^-./
318
322
  fail UnrecognizedSwitch, opt
319
323
  else
320
- @CONF[:SCRIPT] = opt
321
- $0 = opt
324
+ if noscript
325
+ argv.unshift(opt)
326
+ else
327
+ @CONF[:SCRIPT] = opt
328
+ $0 = opt
329
+ end
322
330
  break
323
331
  end
324
332
  end
@@ -14,7 +14,6 @@ require_relative 'magic-file'
14
14
  require_relative 'completion'
15
15
  require 'io/console'
16
16
  require 'reline'
17
- require 'rdoc'
18
17
 
19
18
  module IRB
20
19
  STDIN_FILE_NAME = "(line)" # :nodoc:
@@ -39,7 +38,7 @@ module IRB
39
38
  public :gets
40
39
 
41
40
  def winsize
42
- if instance_variable_defined?(:@stdout)
41
+ if instance_variable_defined?(:@stdout) && @stdout.tty?
43
42
  @stdout.winsize
44
43
  else
45
44
  [24, 80]
@@ -84,8 +83,7 @@ module IRB
84
83
  #
85
84
  # See IO#eof? for more information.
86
85
  def eof?
87
- rs, = IO.select([@stdin], [], [], 0.00001)
88
- if rs and rs[0]
86
+ if @stdin.wait_readable(0.00001)
89
87
  c = @stdin.getc
90
88
  result = c.nil? ? true : false
91
89
  @stdin.ungetc(c) unless c.nil?
@@ -139,7 +137,7 @@ module IRB
139
137
  # Creates a new input method object
140
138
  def initialize(file)
141
139
  super
142
- @io = IRB::MagicFile.open(file)
140
+ @io = file.is_a?(IO) ? file : IRB::MagicFile.open(file)
143
141
  @external_encoding = @io.external_encoding
144
142
  end
145
143
  # The file name of this input method, usually given during initialization.
@@ -263,7 +261,7 @@ module IRB
263
261
  end
264
262
  end
265
263
 
266
- class ReidlineInputMethod < InputMethod
264
+ class RelineInputMethod < InputMethod
267
265
  include Reline
268
266
 
269
267
  # Creates a new input method object using Reline
@@ -319,8 +317,14 @@ module IRB
319
317
  alt_d = [
320
318
  [Reline::Key.new(nil, 0xE4, true)], # Normal Alt+d.
321
319
  [27, 100], # Normal Alt+d when convert-meta isn't used.
322
- [195, 164] # The "ä" that appears when Alt+d is pressed on xterm.
320
+ [195, 164], # The "ä" that appears when Alt+d is pressed on xterm.
321
+ [226, 136, 130] # The "∂" that appears when Alt+d in pressed on iTerm2.
323
322
  ]
323
+ begin
324
+ require 'rdoc'
325
+ rescue LoadError
326
+ return nil
327
+ end
324
328
 
325
329
  if just_cursor_moving and completion_journey_data.nil?
326
330
  return nil
@@ -466,4 +470,13 @@ module IRB
466
470
  str
467
471
  end
468
472
  end
473
+
474
+ class ReidlineInputMethod < RelineInputMethod
475
+ def initialize
476
+ warn <<~MSG.strip
477
+ IRB::ReidlineInputMethod is deprecated, please use IRB::RelineInputMethod instead.
478
+ MSG
479
+ super
480
+ end
481
+ end
469
482
  end
data/lib/irb/inspector.rb CHANGED
@@ -108,18 +108,10 @@ module IRB # :nodoc:
108
108
 
109
109
  Inspector.def_inspector([false, :to_s, :raw]){|v| v.to_s}
110
110
  Inspector.def_inspector([:p, :inspect]){|v|
111
- result = v.inspect
112
- if IRB.conf[:MAIN_CONTEXT]&.use_colorize? && Color.inspect_colorable?(v)
113
- result = Color.colorize_code(result)
114
- end
115
- result
111
+ Color.colorize_code(v.inspect, colorable: Color.colorable? && Color.inspect_colorable?(v))
116
112
  }
117
- Inspector.def_inspector([true, :pp, :pretty_inspect], proc{require "irb/color_printer"}){|v|
118
- if IRB.conf[:MAIN_CONTEXT]&.use_colorize?
119
- IRB::ColorPrinter.pp(v, '').chomp
120
- else
121
- v.pretty_inspect.chomp
122
- end
113
+ Inspector.def_inspector([true, :pp, :pretty_inspect], proc{require_relative "color_printer"}){|v|
114
+ IRB::ColorPrinter.pp(v, '').chomp
123
115
  }
124
116
  Inspector.def_inspector([:yaml, :YAML], proc{require "yaml"}){|v|
125
117
  begin
data/lib/irb/lc/error.rb CHANGED
@@ -10,8 +10,9 @@
10
10
  #
11
11
  #
12
12
 
13
- # :stopdoc:
14
13
  module IRB
14
+ # :stopdoc:
15
+
15
16
  class UnrecognizedSwitch < StandardError
16
17
  def initialize(val)
17
18
  super("Unrecognized switch: #{val}")
@@ -47,11 +48,6 @@ module IRB
47
48
  super("No such job(#{val}).")
48
49
  end
49
50
  end
50
- class CantShiftToMultiIrbMode < StandardError
51
- def initialize
52
- super("Can't shift to multi irb mode.")
53
- end
54
- end
55
51
  class CantChangeBinding < StandardError
56
52
  def initialize(val)
57
53
  super("Can't change binding to (#{val}).")
@@ -67,5 +63,6 @@ module IRB
67
63
  super("Define illegal RC_NAME_GENERATOR.")
68
64
  end
69
65
  end
66
+
67
+ # :startdoc:
70
68
  end
71
- # :startdoc:
@@ -1,61 +1,51 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # irb/lc/help-message.rb -
4
- # $Release Version: 0.9.6$
5
- # $Revision$
6
- # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
- #
8
- # --
9
- #
10
- #
11
- #
12
1
  Usage: irb.rb [options] [programfile] [arguments]
13
- -f Suppress read of ~/.irbrc
14
- -d Set $DEBUG to true (same as `ruby -d')
15
- -r load-module Same as `ruby -r'
16
- -I path Specify $LOAD_PATH directory
17
- -U Same as `ruby -U`
18
- -E enc Same as `ruby -E`
19
- -w Same as `ruby -w`
20
- -W[level=2] Same as `ruby -W`
2
+ -f Don't initialize from configuration file.
3
+ -d Set $DEBUG and $VERBOSE to true (same as 'ruby -d').
4
+ -r load-module Require load-module (same as 'ruby -r').
5
+ -I path Specify $LOAD_PATH directory (same as 'ruby -I').
6
+ -U Set external and internal encodings to UTF-8.
7
+ -E ex[:in] Set default external (ex) and internal (in) encodings
8
+ (same as 'ruby -E').
9
+ -w Suppress warnings (same as 'ruby -w').
10
+ -W[level=2] Set warning level: 0=silence, 1=medium, 2=verbose
11
+ (same as 'ruby -W').
21
12
  --context-mode n Set n[0-4] to method to create Binding Object,
22
- when new workspace was created
23
- --extra-doc-dir Add an extra doc dir for the doc dialog
24
- --echo Show result (default)
25
- --noecho Don't show result
13
+ when new workspace was created.
14
+ --extra-doc-dir Add an extra doc dir for the doc dialog.
15
+ --echo Show result (default).
16
+ --noecho Don't show result.
26
17
  --echo-on-assignment
27
- Show result on assignment
18
+ Show result on assignment.
28
19
  --noecho-on-assignment
29
- Don't show result on assignment
20
+ Don't show result on assignment.
30
21
  --truncate-echo-on-assignment
31
- Show truncated result on assignment (default)
32
- --inspect Use `inspect' for output
33
- --noinspect Don't use inspect for output
34
- --multiline Use multiline editor module
35
- --nomultiline Don't use multiline editor module
36
- --singleline Use singleline editor module
37
- --nosingleline Don't use singleline editor module
38
- --colorize Use colorization
39
- --nocolorize Don't use colorization
40
- --autocomplete Use autocompletion
41
- --noautocomplete Don't use autocompletion
42
- --prompt prompt-mode/--prompt-mode prompt-mode
43
- Switch prompt mode. Pre-defined prompt modes are
44
- `default', `simple', `xmp' and `inf-ruby'
22
+ Show truncated result on assignment (default).
23
+ --inspect Use 'inspect' for output.
24
+ --noinspect Don't use 'inspect' for output.
25
+ --multiline Use multiline editor module.
26
+ --nomultiline Don't use multiline editor module (default).
27
+ --singleline Use single line editor module.
28
+ --nosingleline Don't use single line editor module (default).
29
+ --colorize Use color-highlighting (default).
30
+ --nocolorize Don't use color-highlighting.
31
+ --autocomplete Use auto-completion (default).
32
+ --noautocomplete Don't use auto-completion.
33
+ --prompt prompt-mode, --prompt-mode prompt-mode
34
+ Set prompt mode. Pre-defined prompt modes are:
35
+ 'default', 'classic', 'simple', 'inf-ruby', 'xmp', 'null'.
45
36
  --inf-ruby-mode Use prompt appropriate for inf-ruby-mode on emacs.
46
37
  Suppresses --multiline and --singleline.
47
- --sample-book-mode/--simple-prompt
48
- Simple prompt mode
49
- --noprompt No prompt mode
38
+ --sample-book-mode, --simple-prompt
39
+ Set prompt mode to 'simple'.
40
+ --noprompt Don't output prompt.
41
+ --script Script mode (default, treat first argument as script)
42
+ --noscript No script mode (leave arguments in argv)
50
43
  --single-irb Share self with sub-irb.
51
- --tracer Display trace for each execution of commands.
52
- --back-trace-limit n
53
- Display backtrace top n and tail n. The default
54
- value is 16.
55
- --verbose Show details
56
- --noverbose Don't show details
57
- -v, --version Print the version of irb
58
- -h, --help Print help
59
- -- Separate options of irb from the list of command-line args
60
-
61
- # vim:fileencoding=utf-8
44
+ --tracer Show stack trace for each command.
45
+ --back-trace-limit n[=16]
46
+ Display backtrace top n and bottom n.
47
+ --verbose Show details.
48
+ --noverbose Don't show details.
49
+ -v, --version Print the version of irb.
50
+ -h, --help Print help.
51
+ -- Separate options of irb from the list of command-line args.
@@ -1,11 +1,13 @@
1
1
  # frozen_string_literal: false
2
- # :stopdoc:
3
2
  module IRB
3
+ # :stopdoc:
4
+
4
5
  class Locale
5
6
  @@legacy_encoding_alias_map = {
6
7
  'ujis' => Encoding::EUC_JP,
7
8
  'euc' => Encoding::EUC_JP
8
9
  }.freeze
9
10
  end
11
+
12
+ # :startdoc:
10
13
  end
11
- # :startdoc:
@@ -10,8 +10,9 @@
10
10
  #
11
11
  #
12
12
 
13
- # :stopdoc:
14
13
  module IRB
14
+ # :stopdoc:
15
+
15
16
  class UnrecognizedSwitch < StandardError
16
17
  def initialize(val)
17
18
  super("スイッチ(#{val})が分りません")
@@ -47,11 +48,6 @@ module IRB
47
48
  super("そのようなジョブ(#{val})はありません.")
48
49
  end
49
50
  end
50
- class CantShiftToMultiIrbMode < StandardError
51
- def initialize
52
- super("multi-irb modeに移れません.")
53
- end
54
- end
55
51
  class CantChangeBinding < StandardError
56
52
  def initialize(val)
57
53
  super("バインディング(#{val})に変更できません.")
@@ -67,6 +63,7 @@ module IRB
67
63
  super("RC_NAME_GENERATORが正しく定義されていません.")
68
64
  end
69
65
  end
66
+
67
+ # :startdoc:
70
68
  end
71
- # :startdoc:
72
69
  # vim:fileencoding=utf-8
@@ -1,13 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
- # irb/lc/ja/help-message.rb -
3
- # $Release Version: 0.9.6$
4
- # $Revision$
5
- # by Keiju ISHITSUKA(keiju@ruby-lang.org)
6
- #
7
- # --
8
- #
9
- #
10
- #
11
1
  Usage: irb.rb [options] [programfile] [arguments]
12
2
  -f ~/.irbrc を読み込まない.
13
3
  -d $DEBUG をtrueにする(ruby -d と同じ)
@@ -53,5 +43,3 @@ Usage: irb.rb [options] [programfile] [arguments]
53
43
  -v, --version irbのバージョンを表示する.
54
44
  -h, --help irb のヘルプを表示する.
55
45
  -- 以降のコマンドライン引数をオプションとして扱わない.
56
-
57
- # vim:fileencoding=utf-8
data/lib/irb/ruby-lex.rb CHANGED
@@ -139,7 +139,7 @@ class RubyLex
139
139
  def self.ripper_lex_without_warning(code, context: nil)
140
140
  verbose, $VERBOSE = $VERBOSE, nil
141
141
  if context
142
- lvars = context&.workspace&.binding&.local_variables
142
+ lvars = context.workspace&.binding&.local_variables
143
143
  if lvars && !lvars.empty?
144
144
  code = "#{lvars.join('=')}=nil\n#{code}"
145
145
  line_no = 0
@@ -147,30 +147,24 @@ class RubyLex
147
147
  line_no = 1
148
148
  end
149
149
  end
150
- tokens = nil
150
+
151
151
  compile_with_errors_suppressed(code, line_no: line_no) do |inner_code, line_no|
152
152
  lexer = Ripper::Lexer.new(inner_code, '-', line_no)
153
153
  if lexer.respond_to?(:scan) # Ruby 2.7+
154
- tokens = []
155
- pos_to_index = {}
156
- lexer.scan.each do |t|
154
+ lexer.scan.each_with_object([]) do |t, tokens|
157
155
  next if t.pos.first == 0
158
- if pos_to_index.has_key?(t.pos)
159
- index = pos_to_index[t.pos]
160
- found_tk = tokens[index]
161
- if ERROR_TOKENS.include?(found_tk.event) && !ERROR_TOKENS.include?(t.event)
162
- tokens[index] = t
163
- end
156
+ prev_tk = tokens.last
157
+ position_overlapped = prev_tk && t.pos[0] == prev_tk.pos[0] && t.pos[1] < prev_tk.pos[1] + prev_tk.tok.bytesize
158
+ if position_overlapped
159
+ tokens[-1] = t if ERROR_TOKENS.include?(prev_tk.event) && !ERROR_TOKENS.include?(t.event)
164
160
  else
165
- pos_to_index[t.pos] = tokens.size
166
161
  tokens << t
167
162
  end
168
163
  end
169
164
  else
170
- tokens = lexer.parse.reject { |it| it.pos.first == 0 }
165
+ lexer.parse.reject { |it| it.pos.first == 0 }
171
166
  end
172
167
  end
173
- tokens
174
168
  ensure
175
169
  $VERBOSE = verbose
176
170
  end
@@ -209,12 +203,7 @@ class RubyLex
209
203
  last_line = lines[line_index]&.byteslice(0, byte_pointer)
210
204
  code += last_line if last_line
211
205
  @tokens = self.class.ripper_lex_without_warning(code, context: context)
212
- corresponding_token_depth = check_corresponding_token_depth(lines, line_index)
213
- if corresponding_token_depth
214
- corresponding_token_depth
215
- else
216
- nil
217
- end
206
+ check_corresponding_token_depth(lines, line_index)
218
207
  end
219
208
  end
220
209
  end
@@ -308,7 +297,7 @@ class RubyLex
308
297
  return true
309
298
  elsif tokens.size >= 1 and tokens[-1].event == :on_heredoc_end # "EOH\n"
310
299
  return false
311
- elsif tokens.size >= 2 and defined?(Ripper::EXPR_BEG) and tokens[-2].state.anybits?(Ripper::EXPR_BEG | Ripper::EXPR_FNAME) and tokens[-2].tok !~ /\A\.\.\.?\z/
300
+ elsif tokens.size >= 2 and tokens[-2].state.anybits?(Ripper::EXPR_BEG | Ripper::EXPR_FNAME) and tokens[-2].tok !~ /\A\.\.\.?\z/
312
301
  # end of literal except for regexp
313
302
  # endless range at end of line is not a continue
314
303
  return true
@@ -389,21 +378,20 @@ class RubyLex
389
378
  $VERBOSE = verbose
390
379
  end
391
380
 
392
- if defined?(Ripper::EXPR_BEG)
393
- last_lex_state = tokens.last.state
394
- if last_lex_state.allbits?(Ripper::EXPR_BEG)
395
- return false
396
- elsif last_lex_state.allbits?(Ripper::EXPR_DOT)
397
- return true
398
- elsif last_lex_state.allbits?(Ripper::EXPR_CLASS)
399
- return true
400
- elsif last_lex_state.allbits?(Ripper::EXPR_FNAME)
401
- return true
402
- elsif last_lex_state.allbits?(Ripper::EXPR_VALUE)
403
- return true
404
- elsif last_lex_state.allbits?(Ripper::EXPR_ARG)
405
- return false
406
- end
381
+ last_lex_state = tokens.last.state
382
+
383
+ if last_lex_state.allbits?(Ripper::EXPR_BEG)
384
+ return false
385
+ elsif last_lex_state.allbits?(Ripper::EXPR_DOT)
386
+ return true
387
+ elsif last_lex_state.allbits?(Ripper::EXPR_CLASS)
388
+ return true
389
+ elsif last_lex_state.allbits?(Ripper::EXPR_FNAME)
390
+ return true
391
+ elsif last_lex_state.allbits?(Ripper::EXPR_VALUE)
392
+ return true
393
+ elsif last_lex_state.allbits?(Ripper::EXPR_ARG)
394
+ return false
407
395
  end
408
396
 
409
397
  false
data/lib/irb/version.rb CHANGED
@@ -11,7 +11,7 @@
11
11
  #
12
12
 
13
13
  module IRB # :nodoc:
14
- VERSION = "1.4.0"
14
+ VERSION = "1.4.2"
15
15
  @RELEASE_VERSION = VERSION
16
- @LAST_UPDATE_DATE = "2021-12-25"
16
+ @LAST_UPDATE_DATE = "2022-10-03"
17
17
  end
data/lib/irb/workspace.rb CHANGED
@@ -158,27 +158,20 @@ EOF
158
158
  end
159
159
  end
160
160
 
161
- # NOT using #use_colorize? of IRB.conf[:MAIN_CONTEXT] because this method may be called before IRB::Irb#run
162
- use_colorize = IRB.conf.fetch(:USE_COLORIZE, true)
163
- if use_colorize
164
- lines = Color.colorize_code(code).lines
165
- else
166
- lines = code.lines
167
- end
161
+ lines = Color.colorize_code(code).lines
168
162
  pos -= 1
169
163
 
170
164
  start_pos = [pos - 5, 0].max
171
165
  end_pos = [pos + 5, lines.size - 1].min
172
166
 
173
- if use_colorize
174
- fmt = " %2s #{Color.colorize("%#{end_pos.to_s.length}d", [:BLUE, :BOLD])}: %s"
175
- else
176
- fmt = " %2s %#{end_pos.to_s.length}d: %s"
177
- end
167
+ line_number_fmt = Color.colorize("%#{end_pos.to_s.length}d", [:BLUE, :BOLD])
168
+ fmt = " %2s #{line_number_fmt}: %s"
169
+
178
170
  body = (start_pos..end_pos).map do |current_pos|
179
171
  sprintf(fmt, pos == current_pos ? '=>' : '', current_pos + 1, lines[current_pos])
180
172
  end.join("")
181
- "\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear if use_colorize}\n"
173
+
174
+ "\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear}\n"
182
175
  end
183
176
 
184
177
  def IRB.delete_caller