irb 1.7.1 → 1.7.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: d8dc3e14a57010a1ece61f5ca0111e98742f29daea5ab1ad1bdc48e0de6e55b2
4
- data.tar.gz: 7da9b8c9e3e3c68384c0f65eb030d7874c8f0d07c20ce651ab7b54f5bfdfb9bd
3
+ metadata.gz: c2a6b9078ea3fdbc051de74cf073657fe864a7e4094b68298a408179148f6c13
4
+ data.tar.gz: 9f0f6e81955f1c0fa34819bc28e82fee343d286b72984160f71a1709a6820d7e
5
5
  SHA512:
6
- metadata.gz: 73173c7af8ffa50bfa26a49ad1c2b7a2db12a89b006980b2b0d649bc6a03b776359ce03d20a9a7dde493c3c64e70e85864809436b546b571f23e77774748f35e
7
- data.tar.gz: 371777b42d560af3196092e98555a46d9c93c4efa592e8f38365dd0f5be6863ea4a50d6160baedf7d7d7c6914087394cde33e0fd57e17bec68a63f64f8265a89
6
+ metadata.gz: dc2c47f28a408d0751b62b5da054b3e340d2dba56ce3b3d1fedd2708a3f649f6a31b2c8d5e85a50d81ad8cf8e648c084354da0c0379b7976058e5a82eee839a7
7
+ data.tar.gz: 1bf46c2cc017987a81c2c16c18bb1b83d16cc8fab9eaf2e04e33532dd8e8d9a722d03ba1df406988d4b87b7679896af2ac27cb3659cddb55c6fa00b4f02ac94f
data/irb.gemspec CHANGED
@@ -41,5 +41,5 @@ Gem::Specification.new do |spec|
41
41
 
42
42
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7")
43
43
 
44
- spec.add_dependency "reline", ">= 0.3.0"
44
+ spec.add_dependency "reline", ">= 0.3.6"
45
45
  end
@@ -14,7 +14,7 @@ module IRB
14
14
  def execute(*args)
15
15
  commands_info = IRB::ExtendCommandBundle.all_commands_info
16
16
  commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] }
17
- longest_cmd_name_length = commands_info.map { |c| c[:display_name] }.max { |a, b| a.length <=> b.length }.length
17
+ longest_cmd_name_length = commands_info.map { |c| c[:display_name].length }.max
18
18
 
19
19
  output = StringIO.new
20
20
 
data/lib/irb/context.rb CHANGED
@@ -8,6 +8,7 @@ require_relative "workspace"
8
8
  require_relative "inspector"
9
9
  require_relative "input-method"
10
10
  require_relative "output-method"
11
+ require_relative "history"
11
12
 
12
13
  module IRB
13
14
  # A class that wraps the current state of the irb session, including the
@@ -151,6 +152,27 @@ module IRB
151
152
  @command_aliases = IRB.conf[:COMMAND_ALIASES]
152
153
  end
153
154
 
155
+ def save_history=(val)
156
+ IRB.conf[:SAVE_HISTORY] = val
157
+ if val
158
+ (IRB.conf[:MAIN_CONTEXT] || self).init_save_history
159
+ end
160
+ end
161
+
162
+ def save_history
163
+ IRB.conf[:SAVE_HISTORY]
164
+ end
165
+
166
+ # A copy of the default <code>IRB.conf[:HISTORY_FILE]</code>
167
+ def history_file
168
+ IRB.conf[:HISTORY_FILE]
169
+ end
170
+
171
+ # Set <code>IRB.conf[:HISTORY_FILE]</code> to the given +hist+.
172
+ def history_file=(hist)
173
+ IRB.conf[:HISTORY_FILE] = hist
174
+ end
175
+
154
176
  # The top-level workspace, see WorkSpace#main
155
177
  def main
156
178
  @workspace.main
@@ -554,5 +576,11 @@ module IRB
554
576
  command = command_aliases.fetch(command.to_sym, command)
555
577
  ExtendCommandBundle.load_command(command)&.respond_to?(:transform_args)
556
578
  end
579
+
580
+ def init_save_history# :nodoc:
581
+ unless (class<<@io;self;end).include?(HistorySavingAbility)
582
+ @io.extend(HistorySavingAbility)
583
+ end
584
+ end
557
585
  end
558
586
  end
@@ -40,14 +40,14 @@ module IRB # :nodoc:
40
40
  #
41
41
  # If +no+ is +nil+, execution result history isn't used (default).
42
42
  #
43
- # History values are available via <code>__</code> variable, see
44
- # IRB::History.
43
+ # EvalHistory values are available via <code>__</code> variable, see
44
+ # IRB::EvalHistory.
45
45
  def eval_history=(no)
46
46
  if no
47
47
  if defined?(@eval_history) && @eval_history
48
48
  @eval_history_values.size(no)
49
49
  else
50
- @eval_history_values = History.new(no)
50
+ @eval_history_values = EvalHistory.new(no)
51
51
  IRB.conf[:__TMP__EHV__] = @eval_history_values
52
52
  @workspace.evaluate("__ = IRB.conf[:__TMP__EHV__]")
53
53
  IRB.conf.delete(:__TMP_EHV__)
@@ -89,7 +89,7 @@ module IRB # :nodoc:
89
89
  # __[1]
90
90
  # # => 10
91
91
  #
92
- class History
92
+ class EvalHistory
93
93
 
94
94
  def initialize(size = 16) # :nodoc:
95
95
  @size = size
@@ -316,10 +316,9 @@ module IRB # :nodoc:
316
316
  CE = ContextExtender # :nodoc:
317
317
 
318
318
  @EXTEND_COMMANDS = [
319
- [:eval_history=, "ext/history.rb"],
319
+ [:eval_history=, "ext/eval_history.rb"],
320
320
  [:use_tracer=, "ext/tracer.rb"],
321
321
  [:use_loader=, "ext/use-loader.rb"],
322
- [:save_history=, "ext/save-history.rb"],
323
322
  ]
324
323
 
325
324
  # Installs the default context extensions as irb commands:
@@ -327,7 +326,6 @@ module IRB # :nodoc:
327
326
  # Context#eval_history=:: +irb/ext/history.rb+
328
327
  # Context#use_tracer=:: +irb/ext/tracer.rb+
329
328
  # Context#use_loader=:: +irb/ext/use-loader.rb+
330
- # Context#save_history=:: +irb/ext/save-history.rb+
331
329
  def self.install_extend_commands
332
330
  for args in @EXTEND_COMMANDS
333
331
  def_extend_command(*args)
@@ -1,55 +1,4 @@
1
- # frozen_string_literal: false
2
- #
3
- # save-history.rb -
4
- # by Keiju ISHITSUKA(keiju@ruby-lang.org)
5
- #
6
-
7
1
  module IRB
8
- module HistorySavingAbility # :nodoc:
9
- end
10
-
11
- class Context
12
- def init_save_history# :nodoc:
13
- unless (class<<@io;self;end).include?(HistorySavingAbility)
14
- @io.extend(HistorySavingAbility)
15
- end
16
- end
17
-
18
- # A copy of the default <code>IRB.conf[:SAVE_HISTORY]</code>
19
- def save_history
20
- IRB.conf[:SAVE_HISTORY]
21
- end
22
-
23
- remove_method(:save_history=) if method_defined?(:save_history=)
24
- # Sets <code>IRB.conf[:SAVE_HISTORY]</code> to the given +val+ and calls
25
- # #init_save_history with this context.
26
- #
27
- # Will store the number of +val+ entries of history in the #history_file
28
- #
29
- # Add the following to your +.irbrc+ to change the number of history
30
- # entries stored to 1000:
31
- #
32
- # IRB.conf[:SAVE_HISTORY] = 1000
33
- def save_history=(val)
34
- IRB.conf[:SAVE_HISTORY] = val
35
- if val
36
- main_context = IRB.conf[:MAIN_CONTEXT]
37
- main_context = self unless main_context
38
- main_context.init_save_history
39
- end
40
- end
41
-
42
- # A copy of the default <code>IRB.conf[:HISTORY_FILE]</code>
43
- def history_file
44
- IRB.conf[:HISTORY_FILE]
45
- end
46
-
47
- # Set <code>IRB.conf[:HISTORY_FILE]</code> to the given +hist+.
48
- def history_file=(hist)
49
- IRB.conf[:HISTORY_FILE] = hist
50
- end
51
- end
52
-
53
2
  module HistorySavingAbility # :nodoc:
54
3
  def HistorySavingAbility.extended(obj)
55
4
  IRB.conf[:AT_EXIT].push proc{obj.save_history}
@@ -4,7 +4,6 @@
4
4
  # by Keiju ISHITSUKA(keiju@ruby-lang.org)
5
5
  #
6
6
 
7
- require_relative 'src_encoding'
8
7
  require_relative 'completion'
9
8
  require 'io/console'
10
9
  require 'reline'
@@ -256,8 +255,6 @@ module IRB
256
255
  end
257
256
 
258
257
  class RelineInputMethod < InputMethod
259
- include Reline
260
-
261
258
  # Creates a new input method object using Reline
262
259
  def initialize
263
260
  IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
@@ -270,9 +267,7 @@ module IRB
270
267
  @stdin = ::IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
271
268
  @stdout = ::IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
272
269
 
273
- if Reline.respond_to?("basic_word_break_characters=")
274
- Reline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
275
- end
270
+ Reline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
276
271
  Reline.completion_append_character = nil
277
272
  Reline.completer_quote_characters = ''
278
273
  Reline.completion_proc = IRB::InputCompletor::CompletionProc
@@ -401,10 +396,10 @@ module IRB
401
396
  mod_key = RUBY_PLATFORM.match?(/darwin/) ? "Option" : "Alt"
402
397
  message = "Press #{mod_key}+d to read the full document"
403
398
  contents = [message] + doc.accept(formatter).split("\n")
404
- contents = contents.take(preferred_dialog_height) if respond_to?(:preferred_dialog_height)
399
+ contents = contents.take(preferred_dialog_height)
405
400
 
406
401
  y = cursor_pos_to_render.y
407
- DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
402
+ Reline::DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
408
403
  }
409
404
 
410
405
  # Reads the next line from this input method.
@@ -415,8 +410,8 @@ module IRB
415
410
  Reline.output = @stdout
416
411
  Reline.prompt_proc = @prompt_proc
417
412
  Reline.auto_indent_proc = @auto_indent_proc if @auto_indent_proc
418
- if l = readmultiline(@prompt, false, &@check_termination_proc)
419
- HISTORY.push(l) if !l.empty?
413
+ if l = Reline.readmultiline(@prompt, false, &@check_termination_proc)
414
+ Reline::HISTORY.push(l) if !l.empty?
420
415
  @line[@line_no += 1] = l + "\n"
421
416
  else
422
417
  @eof = true
@@ -458,11 +453,7 @@ module IRB
458
453
  def inspect
459
454
  config = Reline::Config.new
460
455
  str = "RelineInputMethod with Reline #{Reline::VERSION}"
461
- if config.respond_to?(:inputrc_path)
462
- inputrc_path = File.expand_path(config.inputrc_path)
463
- else
464
- inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
465
- end
456
+ inputrc_path = File.expand_path(config.inputrc_path)
466
457
  str += " and #{inputrc_path}" if File.exist?(inputrc_path)
467
458
  str
468
459
  end
data/lib/irb/version.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
 
7
7
  module IRB # :nodoc:
8
- VERSION = "1.7.1"
8
+ VERSION = "1.7.3"
9
9
  @RELEASE_VERSION = VERSION
10
- @LAST_UPDATE_DATE = "2023-07-01"
10
+ @LAST_UPDATE_DATE = "2023-07-12"
11
11
  end
data/lib/irb.rb CHANGED
@@ -154,7 +154,7 @@ require_relative "irb/easter-egg"
154
154
  #
155
155
  # IRB.conf[:EVAL_HISTORY] = <number>
156
156
  #
157
- # See IRB::Context#eval_history= and History class. The history of command
157
+ # See IRB::Context#eval_history= and EvalHistory class. The history of command
158
158
  # results is not permanently saved in any file.
159
159
  #
160
160
  # == Customizing the IRB Prompt
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - aycabta
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-07-02 00:00:00.000000000 Z
12
+ date: 2023-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: reline
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 0.3.0
20
+ version: 0.3.6
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.3.0
27
+ version: 0.3.6
28
28
  description: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
29
29
  email:
30
30
  - aycabta@gmail.com
@@ -76,16 +76,16 @@ files:
76
76
  - lib/irb/context.rb
77
77
  - lib/irb/easter-egg.rb
78
78
  - lib/irb/ext/change-ws.rb
79
- - lib/irb/ext/history.rb
79
+ - lib/irb/ext/eval_history.rb
80
80
  - lib/irb/ext/loader.rb
81
81
  - lib/irb/ext/multi-irb.rb
82
- - lib/irb/ext/save-history.rb
83
82
  - lib/irb/ext/tracer.rb
84
83
  - lib/irb/ext/use-loader.rb
85
84
  - lib/irb/ext/workspaces.rb
86
85
  - lib/irb/extend-command.rb
87
86
  - lib/irb/frame.rb
88
87
  - lib/irb/help.rb
88
+ - lib/irb/history.rb
89
89
  - lib/irb/init.rb
90
90
  - lib/irb/input-method.rb
91
91
  - lib/irb/inspector.rb
@@ -99,7 +99,6 @@ files:
99
99
  - lib/irb/output-method.rb
100
100
  - lib/irb/ruby-lex.rb
101
101
  - lib/irb/ruby_logo.aa
102
- - lib/irb/src_encoding.rb
103
102
  - lib/irb/version.rb
104
103
  - lib/irb/workspace.rb
105
104
  - lib/irb/ws-for-case-2.rb
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: false
2
- # DO NOT WRITE ANY MAGIC COMMENT HERE.
3
- module IRB
4
- def self.default_src_encoding
5
- return __ENCODING__
6
- end
7
- end