irb 1.11.0 → 1.11.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: 8029dc02923cbb80a77625adad559929050e1e699ef613a2de18cfdc998aef48
4
- data.tar.gz: 4b4165fdd602583745cadd66ad9229eab74e473cf613f25c54a8446a2d9b1589
3
+ metadata.gz: 17969636013c03ffd08d5b53570ec0eda8620855092bd863c5b851e668343007
4
+ data.tar.gz: 7900a886588ebca5839e2b6fac6d538e58febd2706cdbbe979e098f2950d2d79
5
5
  SHA512:
6
- metadata.gz: 1a93cf1c63baba6feba0e9b093ce9f0c200556657cab25760acef18370f1e23d3094865c9c1a8f66d6b1544f3715928f9d8d1212f629e6cec83d0f87ab8eb18c
7
- data.tar.gz: 0171eda936e605d6ea83f9d0a98381f93f441bee435748c41839a04b2b672cae0fa9ab4ee3c276141df3e3ab40141581e3e7167ad710accf2790de664f5e7b34
6
+ metadata.gz: e9d8fe7568718ce10db38ed1a85ad92473c21ca81738cadaa8a8258adcf18cdbfc5755c61621c336ac4bc53c57a08ad26311a4fc671fb98ad0cd5130c2e7527e
7
+ data.tar.gz: 729f6a0f6ba9fe6cfac3e2ed9e752531006f60c386b3e51fd84c877eeb1b3cdcb0fee1a7bf44c3c0bfa7f0f56def8ad8c7d99413b9b96b304d17e0c15d90aa87
data/README.md CHANGED
@@ -15,6 +15,10 @@ The `irb` command from your shell will start the interpreter.
15
15
  - [Debugging with IRB](#debugging-with-irb)
16
16
  - [More about `debug.gem`](#more-about-debuggem)
17
17
  - [Advantages Over `debug.gem`'s Console](#advantages-over-debuggems-console)
18
+ - [Type Based Completion](#type-based-completion)
19
+ - [How to Enable IRB::TypeCompletor](#how-to-enable-irbtypecompletor)
20
+ - [Advantage over Default IRB::RegexpCompletor](#advantage-over-default-irbregexpcompletor)
21
+ - [Difference between Steep's Completion](#difference-between-steeps-completion)
18
22
  - [Configuration](#configuration)
19
23
  - [Environment Variables](#environment-variables)
20
24
  - [Documentation](#documentation)
@@ -105,15 +109,9 @@ Hello World
105
109
 
106
110
  The following commands are available on IRB. You can get the same output from the `show_cmds` command.
107
111
 
108
- ```
109
- Workspace
110
- cwws Show the current workspace.
111
- chws Change the current workspace to an object.
112
- workspaces Show workspaces.
113
- pushws Push an object to the workspace stack.
114
- popws Pop a workspace from the workspace stack.
115
-
112
+ ```txt
116
113
  IRB
114
+ exit Exit the current irb session.
117
115
  irb_load Load a Ruby file.
118
116
  irb_require Require a Ruby file.
119
117
  source Loads a given file in the current session.
@@ -121,6 +119,13 @@ IRB
121
119
  show_cmds List all available commands and their description.
122
120
  history Shows the input history. `-g [query]` or `-G [query]` allows you to filter the output.
123
121
 
122
+ Workspace
123
+ cwws Show the current workspace.
124
+ chws Change the current workspace to an object.
125
+ workspaces Show workspaces.
126
+ pushws Push an object to the workspace stack.
127
+ popws Pop a workspace from the workspace stack.
128
+
124
129
  Multi-irb (DEPRECATED)
125
130
  irb Start a child IRB.
126
131
  jobs List of current sessions.
@@ -149,6 +154,10 @@ Context
149
154
  ls Show methods, constants, and variables. `-g [query]` or `-G [query]` allows you to filter out the output.
150
155
  show_source Show the source code of a given method or constant.
151
156
  whereami Show the source code around binding.irb again.
157
+
158
+ Aliases
159
+ $ Alias for `show_source`
160
+ @ Alias for `whereami`
152
161
  ```
153
162
 
154
163
  ## Debugging with IRB
@@ -242,15 +251,33 @@ IRB's default completion `IRB::RegexpCompletor` uses Regexp. IRB has another exp
242
251
 
243
252
  ### How to Enable IRB::TypeCompletor
244
253
 
245
- To enable IRB::TypeCompletor, run IRB with `--type-completor` option
254
+ Install [ruby/repl_type_completor](https://github.com/ruby/repl_type_completor/) with:
255
+ ```
256
+ $ gem install repl_type_completor
257
+ ```
258
+ Or add these lines to your project's Gemfile.
259
+ ```ruby
260
+ gem 'irb'
261
+ gem 'repl_type_completor', group: [:development, :test]
262
+ ```
263
+
264
+ Now you can use type based completion by:
265
+
266
+ Running IRB with the `--type-completor` option
246
267
  ```
247
268
  $ irb --type-completor
248
269
  ```
249
- Or write the code below to IRB's rc-file.
270
+
271
+ Or writing this line to IRB's rc-file (e.g. `~/.irbrc`)
250
272
  ```ruby
251
273
  IRB.conf[:COMPLETOR] = :type # default is :regexp
252
274
  ```
253
- You also need `gem repl_type_completor` to use this feature.
275
+
276
+ Or setting the environment variable `IRB_COMPLETOR`
277
+ ```ruby
278
+ ENV['IRB_COMPLETOR'] = 'type'
279
+ IRB.start
280
+ ```
254
281
 
255
282
  To check if it's enabled, type `irb_info` into IRB and see the `Completion` section.
256
283
  ```
data/irb.gemspec CHANGED
@@ -41,6 +41,6 @@ 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.8"
44
+ spec.add_dependency "reline", ">= 0.4.2"
45
45
  spec.add_dependency "rdoc"
46
46
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "nop"
4
+
5
+ module IRB
6
+ # :stopdoc:
7
+
8
+ module ExtendCommand
9
+ class Exit < Nop
10
+ category "IRB"
11
+ description "Exit the current irb session."
12
+
13
+ def execute(*)
14
+ IRB.irb_exit
15
+ rescue UncaughtThrowError
16
+ Kernel.exit
17
+ end
18
+ end
19
+ end
20
+
21
+ # :startdoc:
22
+ end
@@ -406,7 +406,13 @@ module IRB
406
406
  else
407
407
  select_message(receiver, message, candidates.sort)
408
408
  end
409
-
409
+ when /^\s*$/
410
+ # empty input
411
+ if doc_namespace
412
+ nil
413
+ else
414
+ []
415
+ end
410
416
  else
411
417
  if doc_namespace
412
418
  vars = (bind.local_variables | bind.eval_instance_variables).collect{|m| m.to_s}
data/lib/irb/context.rb CHANGED
@@ -573,14 +573,6 @@ module IRB
573
573
  @inspect_method.inspect_value(@last_value)
574
574
  end
575
575
 
576
- alias __exit__ exit
577
- # Exits the current session, see IRB.irb_exit
578
- def exit(ret = 0)
579
- IRB.irb_exit(@irb, ret)
580
- rescue UncaughtThrowError
581
- super
582
- end
583
-
584
576
  NOPRINTING_IVARS = ["@last_value"] # :nodoc:
585
577
  NO_INSPECTING_IVARS = ["@irb", "@io"] # :nodoc:
586
578
  IDNAME_IVARS = ["@prompt_mode"] # :nodoc:
@@ -16,15 +16,6 @@ module IRB # :nodoc:
16
16
  # See #install_alias_method.
17
17
  OVERRIDE_ALL = 0x02
18
18
 
19
- # Quits the current irb context
20
- #
21
- # +ret+ is the optional signal or message to send to Context#exit
22
- #
23
- # Same as <code>IRB.CurrentContext.exit</code>.
24
- def irb_exit(ret = 0)
25
- irb_context.exit(ret)
26
- end
27
-
28
19
  # Displays current configuration.
29
20
  #
30
21
  # Modifying the configuration is achieved by sending a message to IRB.conf.
@@ -35,13 +26,16 @@ module IRB # :nodoc:
35
26
  @ALIASES = [
36
27
  [:context, :irb_context, NO_OVERRIDE],
37
28
  [:conf, :irb_context, NO_OVERRIDE],
38
- [:irb_quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
39
- [:exit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
40
- [:quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
41
29
  ]
42
30
 
43
31
 
44
32
  @EXTEND_COMMANDS = [
33
+ [
34
+ :irb_exit, :Exit, "cmd/exit",
35
+ [:exit, OVERRIDE_PRIVATE_ONLY],
36
+ [:quit, OVERRIDE_PRIVATE_ONLY],
37
+ [:irb_quit, OVERRIDE_PRIVATE_ONLY],
38
+ ],
45
39
  [
46
40
  :irb_current_working_workspace, :CurrentWorkingWorkspace, "cmd/chws",
47
41
  [:cwws, NO_OVERRIDE],
@@ -291,11 +291,13 @@ module IRB
291
291
  @auto_indent_proc = block
292
292
  end
293
293
 
294
+ def retrieve_doc_namespace(matched)
295
+ preposing, _target, postposing, bind = @completion_params
296
+ @completor.doc_namespace(preposing, matched, postposing, bind: bind)
297
+ end
298
+
294
299
  def show_doc_dialog_proc
295
- doc_namespace = ->(matched) {
296
- preposing, _target, postposing, bind = @completion_params
297
- @completor.doc_namespace(preposing, matched, postposing, bind: bind)
298
- }
300
+ input_method = self # self is changed in the lambda below.
299
301
  ->() {
300
302
  dialog.trap_key = nil
301
303
  alt_d = [
@@ -311,7 +313,7 @@ module IRB
311
313
  cursor_pos_to_render, result, pointer, autocomplete_dialog = context.pop(4)
312
314
  return nil if result.nil? or pointer.nil? or pointer < 0
313
315
 
314
- name = doc_namespace.call(result[pointer])
316
+ name = input_method.retrieve_doc_namespace(result[pointer])
315
317
  # Use first one because document dialog does not support multiple namespaces.
316
318
  name = name.first if name.is_a?(Array)
317
319
 
@@ -419,8 +421,7 @@ module IRB
419
421
  return
420
422
  end
421
423
 
422
- _target, preposing, postposing, bind = @completion_params
423
- namespace = @completor.doc_namespace(preposing, matched, postposing, bind: bind)
424
+ namespace = retrieve_doc_namespace(matched)
424
425
  return unless namespace
425
426
 
426
427
  driver ||= RDoc::RI::Driver.new
@@ -19,7 +19,7 @@ module IRB
19
19
  def find_source(signature, super_level = 0)
20
20
  context_binding = @irb_context.workspace.binding
21
21
  case signature
22
- when /\A[A-Z]\w*(::[A-Z]\w*)*\z/ # Const::Name
22
+ when /\A(::)?[A-Z]\w*(::[A-Z]\w*)*\z/ # Const::Name
23
23
  eval(signature, context_binding) # trigger autoload
24
24
  base = context_binding.receiver.yield_self { |r| r.is_a?(Module) ? r : Object }
25
25
  file, line = base.const_source_location(signature)
@@ -34,7 +34,8 @@ module IRB
34
34
  return unless receiver.respond_to?(method, true)
35
35
  file, line = method_target(receiver, super_level, method, "receiver")
36
36
  end
37
- if file && line && File.exist?(file)
37
+ # If the line is zero, it means that the target's source is probably in a binary file, which we should ignore.
38
+ if file && line && !line.zero? && File.exist?(file)
38
39
  Source.new(file: file, first_line: line, last_line: find_end(file, line))
39
40
  end
40
41
  end
data/lib/irb/version.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  #
6
6
 
7
7
  module IRB # :nodoc:
8
- VERSION = "1.11.0"
8
+ VERSION = "1.11.1"
9
9
  @RELEASE_VERSION = VERSION
10
- @LAST_UPDATE_DATE = "2023-12-19"
10
+ @LAST_UPDATE_DATE = "2024-01-08"
11
11
  end
data/lib/irb.rb CHANGED
@@ -705,12 +705,6 @@ require_relative "irb/pager"
705
705
  # Command-line option <tt>-W[_level_]<tt>
706
706
  # sets warning level; 0=silence, 1=medium, 2=verbose.
707
707
  #
708
- # :stopdoc:
709
- # === Performance Measurement
710
- #
711
- # IRB.conf[:MEASURE] IRB.conf[:MEASURE_CALLBACKS] IRB.conf[:MEASURE_PROC]
712
- # :startdoc:
713
- #
714
708
  # == Other Features
715
709
  #
716
710
  # === Load Modules
@@ -771,12 +765,6 @@ require_relative "irb/pager"
771
765
  #
772
766
  # Note that the configuration file entry overrides the command-line options.
773
767
  #
774
- # :stopdoc:
775
- # === \Context Mode
776
- #
777
- # IRB.conf[:CONTEXT_MODE]
778
- # :startdoc:
779
- #
780
768
  # === \IRB Name
781
769
  #
782
770
  # You can specify a name for \IRB.
@@ -815,12 +803,6 @@ require_relative "irb/pager"
815
803
  # Each time the configuration is changed,
816
804
  # that proc is called with argument +conf+:
817
805
  #
818
- # :stopdoc:
819
- # === \Locale
820
- #
821
- # IRB.conf[:LC_MESSAGES]
822
- # :startdoc:
823
- #
824
806
  # === Encodings
825
807
  #
826
808
  # Command-line option <tt>-E _ex_[:_in_]</tt>
@@ -904,8 +886,8 @@ module IRB
904
886
  end
905
887
 
906
888
  # Quits irb
907
- def IRB.irb_exit(irb, ret)
908
- throw :IRB_EXIT, ret
889
+ def IRB.irb_exit(*)
890
+ throw :IRB_EXIT
909
891
  end
910
892
 
911
893
  # Aborts then interrupts irb.
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.11.0
4
+ version: 1.11.1
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-12-20 00:00:00.000000000 Z
12
+ date: 2024-01-09 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.8
20
+ version: 0.4.2
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.8
27
+ version: 0.4.2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rdoc
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -68,6 +68,7 @@ files:
68
68
  - lib/irb/cmd/debug.rb
69
69
  - lib/irb/cmd/delete.rb
70
70
  - lib/irb/cmd/edit.rb
71
+ - lib/irb/cmd/exit.rb
71
72
  - lib/irb/cmd/finish.rb
72
73
  - lib/irb/cmd/help.rb
73
74
  - lib/irb/cmd/history.rb
@@ -148,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
149
  - !ruby/object:Gem::Version
149
150
  version: '0'
150
151
  requirements: []
151
- rubygems_version: 3.5.1
152
+ rubygems_version: 3.5.4
152
153
  signing_key:
153
154
  specification_version: 4
154
155
  summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).