irb 1.1.0.pre.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +10 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +55 -0
  5. data/Rakefile +10 -0
  6. data/bin/console +6 -0
  7. data/bin/setup +6 -0
  8. data/doc/irb/irb-tools.rd.ja +184 -0
  9. data/doc/irb/irb.rd.ja +411 -0
  10. data/exe/irb +11 -0
  11. data/irb.gemspec +84 -0
  12. data/lib/irb.rb +870 -0
  13. data/lib/irb/cmd/chws.rb +34 -0
  14. data/lib/irb/cmd/fork.rb +39 -0
  15. data/lib/irb/cmd/help.rb +46 -0
  16. data/lib/irb/cmd/load.rb +67 -0
  17. data/lib/irb/cmd/nop.rb +39 -0
  18. data/lib/irb/cmd/pushws.rb +41 -0
  19. data/lib/irb/cmd/subirb.rb +43 -0
  20. data/lib/irb/color.rb +233 -0
  21. data/lib/irb/completion.rb +339 -0
  22. data/lib/irb/context.rb +458 -0
  23. data/lib/irb/ext/change-ws.rb +46 -0
  24. data/lib/irb/ext/history.rb +157 -0
  25. data/lib/irb/ext/loader.rb +129 -0
  26. data/lib/irb/ext/multi-irb.rb +265 -0
  27. data/lib/irb/ext/save-history.rb +117 -0
  28. data/lib/irb/ext/tracer.rb +72 -0
  29. data/lib/irb/ext/use-loader.rb +77 -0
  30. data/lib/irb/ext/workspaces.rb +67 -0
  31. data/lib/irb/extend-command.rb +328 -0
  32. data/lib/irb/frame.rb +81 -0
  33. data/lib/irb/help.rb +37 -0
  34. data/lib/irb/init.rb +312 -0
  35. data/lib/irb/input-method.rb +298 -0
  36. data/lib/irb/inspector.rb +142 -0
  37. data/lib/irb/lc/.document +4 -0
  38. data/lib/irb/lc/error.rb +32 -0
  39. data/lib/irb/lc/help-message +52 -0
  40. data/lib/irb/lc/ja/encoding_aliases.rb +11 -0
  41. data/lib/irb/lc/ja/error.rb +31 -0
  42. data/lib/irb/lc/ja/help-message +55 -0
  43. data/lib/irb/locale.rb +182 -0
  44. data/lib/irb/magic-file.rb +38 -0
  45. data/lib/irb/notifier.rb +232 -0
  46. data/lib/irb/output-method.rb +92 -0
  47. data/lib/irb/ruby-lex.rb +499 -0
  48. data/lib/irb/ruby_logo.aa +38 -0
  49. data/lib/irb/slex.rb +282 -0
  50. data/lib/irb/src_encoding.rb +7 -0
  51. data/lib/irb/version.rb +17 -0
  52. data/lib/irb/workspace.rb +181 -0
  53. data/lib/irb/ws-for-case-2.rb +15 -0
  54. data/lib/irb/xmp.rb +170 -0
  55. data/man/irb.1 +207 -0
  56. metadata +140 -0
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: false
2
+ #
3
+ # irb/ws-for-case-2.rb -
4
+ # $Release Version: 0.9.6$
5
+ # $Revision$
6
+ # by Keiju ISHITSUKA(keiju@ruby-lang.org)
7
+ #
8
+ # --
9
+ #
10
+ #
11
+ #
12
+
13
+ while true
14
+ IRB::BINDING_QUEUE.push _ = binding
15
+ end
@@ -0,0 +1,170 @@
1
+ # frozen_string_literal: false
2
+ #
3
+ # xmp.rb - irb version of gotoken xmp
4
+ # $Release Version: 0.9$
5
+ # $Revision$
6
+ # by Keiju ISHITSUKA(Nippon Rational Inc.)
7
+ #
8
+ # --
9
+ #
10
+ #
11
+ #
12
+
13
+ require "irb"
14
+ require_relative "frame"
15
+
16
+ # An example printer for irb.
17
+ #
18
+ # It's much like the standard library PrettyPrint, that shows the value of each
19
+ # expression as it runs.
20
+ #
21
+ # In order to use this library, you must first require it:
22
+ #
23
+ # require 'irb/xmp'
24
+ #
25
+ # Now, you can take advantage of the Object#xmp convenience method.
26
+ #
27
+ # xmp <<END
28
+ # foo = "bar"
29
+ # baz = 42
30
+ # END
31
+ # #=> foo = "bar"
32
+ # #==>"bar"
33
+ # #=> baz = 42
34
+ # #==>42
35
+ #
36
+ # You can also create an XMP object, with an optional binding to print
37
+ # expressions in the given binding:
38
+ #
39
+ # ctx = binding
40
+ # x = XMP.new ctx
41
+ # x.puts
42
+ # #=> today = "a good day"
43
+ # #==>"a good day"
44
+ # ctx.eval 'today # is what?'
45
+ # #=> "a good day"
46
+ class XMP
47
+
48
+ # Creates a new XMP object.
49
+ #
50
+ # The top-level binding or, optional +bind+ parameter will be used when
51
+ # creating the workspace. See WorkSpace.new for more information.
52
+ #
53
+ # This uses the +:XMP+ prompt mode, see IRB@Customizing+the+IRB+Prompt for
54
+ # full detail.
55
+ def initialize(bind = nil)
56
+ IRB.init_config(nil)
57
+
58
+ IRB.conf[:PROMPT_MODE] = :XMP
59
+
60
+ bind = IRB::Frame.top(1) unless bind
61
+ ws = IRB::WorkSpace.new(bind)
62
+ @io = StringInputMethod.new
63
+ @irb = IRB::Irb.new(ws, @io)
64
+ @irb.context.ignore_sigint = false
65
+
66
+ IRB.conf[:MAIN_CONTEXT] = @irb.context
67
+ end
68
+
69
+ # Evaluates the given +exps+, for example:
70
+ #
71
+ # require 'irb/xmp'
72
+ # x = XMP.new
73
+ #
74
+ # x.puts '{:a => 1, :b => 2, :c => 3}'
75
+ # #=> {:a => 1, :b => 2, :c => 3}
76
+ # # ==>{:a=>1, :b=>2, :c=>3}
77
+ # x.puts 'foo = "bar"'
78
+ # # => foo = "bar"
79
+ # # ==>"bar"
80
+ def puts(exps)
81
+ @io.puts exps
82
+
83
+ if @irb.context.ignore_sigint
84
+ begin
85
+ trap_proc_b = trap("SIGINT"){@irb.signal_handle}
86
+ catch(:IRB_EXIT) do
87
+ @irb.eval_input
88
+ end
89
+ ensure
90
+ trap("SIGINT", trap_proc_b)
91
+ end
92
+ else
93
+ catch(:IRB_EXIT) do
94
+ @irb.eval_input
95
+ end
96
+ end
97
+ end
98
+
99
+ # A custom InputMethod class used by XMP for evaluating string io.
100
+ class StringInputMethod < IRB::InputMethod
101
+ # Creates a new StringInputMethod object
102
+ def initialize
103
+ super
104
+ @exps = []
105
+ end
106
+
107
+ # Whether there are any expressions left in this printer.
108
+ def eof?
109
+ @exps.empty?
110
+ end
111
+
112
+ # Reads the next expression from this printer.
113
+ #
114
+ # See IO#gets for more information.
115
+ def gets
116
+ while l = @exps.shift
117
+ next if /^\s+$/ =~ l
118
+ l.concat "\n"
119
+ print @prompt, l
120
+ break
121
+ end
122
+ l
123
+ end
124
+
125
+ # Concatenates all expressions in this printer, separated by newlines.
126
+ #
127
+ # An Encoding::CompatibilityError is raised of the given +exps+'s encoding
128
+ # doesn't match the previous expression evaluated.
129
+ def puts(exps)
130
+ if @encoding and exps.encoding != @encoding
131
+ enc = Encoding.compatible?(@exps.join("\n"), exps)
132
+ if enc.nil?
133
+ raise Encoding::CompatibilityError, "Encoding in which the passed expression is encoded is not compatible to the preceding's one"
134
+ else
135
+ @encoding = enc
136
+ end
137
+ else
138
+ @encoding = exps.encoding
139
+ end
140
+ @exps.concat exps.split(/\n/)
141
+ end
142
+
143
+ # Returns the encoding of last expression printed by #puts.
144
+ attr_reader :encoding
145
+ end
146
+ end
147
+
148
+ # A convenience method that's only available when the you require the IRB::XMP standard library.
149
+ #
150
+ # Creates a new XMP object, using the given expressions as the +exps+
151
+ # parameter, and optional binding as +bind+ or uses the top-level binding. Then
152
+ # evaluates the given expressions using the +:XMP+ prompt mode.
153
+ #
154
+ # For example:
155
+ #
156
+ # require 'irb/xmp'
157
+ # ctx = binding
158
+ # xmp 'foo = "bar"', ctx
159
+ # #=> foo = "bar"
160
+ # #==>"bar"
161
+ # ctx.eval 'foo'
162
+ # #=> "bar"
163
+ #
164
+ # See XMP.new for more information.
165
+ def xmp(exps, bind = nil)
166
+ bind = IRB::Frame.top(1) unless bind
167
+ xmp = XMP.new(bind)
168
+ xmp.puts exps
169
+ xmp
170
+ end
@@ -0,0 +1,207 @@
1
+ .\"Ruby is copyrighted by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ .Dd August 11, 2019
3
+ .Dt IRB \&1 "Ruby Programmer's Reference Guide"
4
+ .Os UNIX
5
+ .Sh NAME
6
+ .Nm irb
7
+ .Nd Interactive Ruby Shell
8
+ .Sh SYNOPSIS
9
+ .Nm
10
+ .Op Fl -version
11
+ .Op Fl dfUw
12
+ .Op Fl I Ar directory
13
+ .Op Fl r Ar library
14
+ .Op Fl E Ar external Ns Op : Ns Ar internal
15
+ .Op Fl W Ns Op Ar level
16
+ .Op Fl - Ns Oo no Oc Ns inspect
17
+ .Op Fl - Ns Oo no Oc Ns multiline
18
+ .Op Fl - Ns Oo no Oc Ns singleline
19
+ .Op Fl - Ns Oo no Oc Ns echo
20
+ .Op Fl - Ns Oo no Oc Ns colorize
21
+ .Op Fl - Ns Oo no Oc Ns verbose
22
+ .Op Fl -prompt Ar mode
23
+ .Op Fl -prompt-mode Ar mode
24
+ .Op Fl -inf-ruby-mode
25
+ .Op Fl -simple-prompt
26
+ .Op Fl -noprompt
27
+ .Op Fl -tracer
28
+ .Op Fl -back-trace-limit Ar n
29
+ .Op Fl -
30
+ .Op program_file
31
+ .Op argument ...
32
+ .Pp
33
+ .Sh DESCRIPTION
34
+ .Nm
35
+ is the REPL(read-eval-print loop) environment for Ruby programs.
36
+ .Pp
37
+ .Sh OPTIONS
38
+ .Bl -tag -width "1234567890123" -compact
39
+ .Pp
40
+ .It Fl -version
41
+ Prints the version of
42
+ .Nm .
43
+ .Pp
44
+ .It Fl E Ar external Ns Op : Ns Ar internal
45
+ .It Fl -encoding Ar external Ns Op : Ns Ar internal
46
+ Same as `ruby -E' .
47
+ Specifies the default value(s) for external encodings and internal encoding. Values should be separated with colon (:).
48
+ .Pp
49
+ You can omit the one for internal encodings, then the value
50
+ .Pf ( Li "Encoding.default_internal" ) will be nil.
51
+ .Pp
52
+ .It Fl I Ar path
53
+ Same as `ruby -I' .
54
+ Specifies
55
+ .Li $LOAD_PATH
56
+ directory
57
+ .Pp
58
+ .It Fl U
59
+ Same as `ruby -U' .
60
+ Sets the default value for internal encodings
61
+ .Pf ( Li "Encoding.default_internal" ) to UTF-8.
62
+ .Pp
63
+ .It Fl d
64
+ Same as `ruby -d' .
65
+ Sets
66
+ .Li $DEBUG
67
+ to true.
68
+ .Pp
69
+ .It Fl f
70
+ Suppresses read of
71
+ .Pa ~/.irbrc .
72
+ .Pp
73
+ .It Fl w
74
+ Same as `ruby -w' .
75
+ .Pp
76
+ .Pp
77
+ .It Fl W
78
+ Same as `ruby -W' .
79
+ .Pp
80
+ .It Fl h
81
+ .It Fl -help
82
+ Prints a summary of the options.
83
+ .Pp
84
+ .It Fl r Ar library
85
+ Same as `ruby -r'.
86
+ Causes irb to load the library using require.
87
+ .Pp
88
+ .It Fl -inspect
89
+ Uses `inspect' for output (default except for bc mode)
90
+ .Pp
91
+ .It Fl -noinspect
92
+ Doesn't use inspect for output
93
+ .Pp
94
+ .It Fl -multiline
95
+ Uses multiline editor module.
96
+ .Pp
97
+ .It Fl -nomultiline
98
+ Doesn't use multiline editor module.
99
+ .Pp
100
+ .It Fl -singleline
101
+ Uses singleline editor module.
102
+ .Pp
103
+ .It Fl -nosingleline
104
+ Doesn't use singleline editor module.
105
+ .Pp
106
+ .Pp
107
+ .It Fl -echo
108
+ Show result(default).
109
+ .Pp
110
+ .It Fl -noecho
111
+ Don't show result.
112
+ .Pp
113
+ .Pp
114
+ .It Fl -colorize
115
+ Use colorization.
116
+ .Pp
117
+ .It Fl -nocolorize
118
+ Don't use colorization.
119
+ .Pp
120
+ .Pp
121
+ .It Fl -verbose
122
+ Show details.
123
+ .Pp
124
+ .It Fl -noverbose
125
+ Don't show details.
126
+ .Pp
127
+ .It Fl -prompt Ar mode
128
+ .It Fl -prompt-mode Ar mode
129
+ Switch prompt mode. Pre-defined prompt modes are
130
+ `default', `simple', `xmp' and `inf-ruby'.
131
+ .Pp
132
+ .It Fl -inf-ruby-mode
133
+ Uses prompt appropriate for inf-ruby-mode on emacs.
134
+ Suppresses --multiline and --singleline.
135
+ .Pp
136
+ .It Fl -simple-prompt
137
+ Makes prompts simple.
138
+ .Pp
139
+ .It Fl -noprompt
140
+ No prompt mode.
141
+ .Pp
142
+ .It Fl -tracer
143
+ Displays trace for each execution of commands.
144
+ .Pp
145
+ .It Fl -back-trace-limit Ar n
146
+ Displays backtrace top
147
+ .Ar n
148
+ and tail
149
+ .Ar n Ns .
150
+ The default value is 16.
151
+ .El
152
+ .Pp
153
+ .Sh ENVIRONMENT
154
+ .Bl -tag -compact
155
+ .It Ev IRBRC
156
+ .Pp
157
+ .El
158
+ .Pp
159
+ Also
160
+ .Nm
161
+ depends on same variables as
162
+ .Xr ruby 1 .
163
+ .Pp
164
+ .Sh FILES
165
+ .Bl -tag -compact
166
+ .It Pa ~/.irbrc
167
+ Personal irb initialization.
168
+ .Pp
169
+ .El
170
+ .Pp
171
+ .Sh EXAMPLES
172
+ .Dl % irb
173
+ .Dl irb(main):001:0> Ic 1 + 1
174
+ .Dl 2
175
+ .Dl irb(main):002:0> Ic def t(x)
176
+ .Dl irb(main):003:1> Ic x + 1
177
+ .Dl irb(main):004:1> Ic end
178
+ .Dl => :t
179
+ .Dl irb(main):005:0> Ic t(3)
180
+ .Dl => 4
181
+ .Dl irb(main):006:0> Ic if t(3) == 4
182
+ .Dl irb(main):007:1> Ic p :ok
183
+ .Dl irb(main):008:1> Ic end
184
+ .Dl :ok
185
+ .Dl => :ok
186
+ .Dl irb(main):009:0> Ic quit
187
+ .Dl %
188
+ .Pp
189
+ .Sh SEE ALSO
190
+ .Xr ruby 1 .
191
+ .Pp
192
+ .Sh REPORTING BUGS
193
+ .Bl -bullet
194
+ .It
195
+ Security vulnerabilities should be reported via an email to
196
+ .Mt security@ruby-lang.org .
197
+ Reported problems will be published after being fixed.
198
+ .Pp
199
+ .It
200
+ Other bugs and feature requests can be reported via the
201
+ Ruby Issue Tracking System
202
+ .Pq Lk https://bugs.ruby-lang.org/ .
203
+ Do not report security vulnerabilities
204
+ via this system because it publishes the vulnerabilities immediately.
205
+ .El
206
+ .Sh AUTHORS
207
+ Written by Keiju ISHITSUKA.
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: irb
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0.pre.4
5
+ platform: ruby
6
+ authors:
7
+ - Keiju ISHITSUKA
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-11-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: reline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
56
+ email:
57
+ - keiju@ruby-lang.org
58
+ executables:
59
+ - irb
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - doc/irb/irb-tools.rd.ja
70
+ - doc/irb/irb.rd.ja
71
+ - exe/irb
72
+ - irb.gemspec
73
+ - lib/irb.rb
74
+ - lib/irb/cmd/chws.rb
75
+ - lib/irb/cmd/fork.rb
76
+ - lib/irb/cmd/help.rb
77
+ - lib/irb/cmd/load.rb
78
+ - lib/irb/cmd/nop.rb
79
+ - lib/irb/cmd/pushws.rb
80
+ - lib/irb/cmd/subirb.rb
81
+ - lib/irb/color.rb
82
+ - lib/irb/completion.rb
83
+ - lib/irb/context.rb
84
+ - lib/irb/ext/change-ws.rb
85
+ - lib/irb/ext/history.rb
86
+ - lib/irb/ext/loader.rb
87
+ - lib/irb/ext/multi-irb.rb
88
+ - lib/irb/ext/save-history.rb
89
+ - lib/irb/ext/tracer.rb
90
+ - lib/irb/ext/use-loader.rb
91
+ - lib/irb/ext/workspaces.rb
92
+ - lib/irb/extend-command.rb
93
+ - lib/irb/frame.rb
94
+ - lib/irb/help.rb
95
+ - lib/irb/init.rb
96
+ - lib/irb/input-method.rb
97
+ - lib/irb/inspector.rb
98
+ - lib/irb/lc/.document
99
+ - lib/irb/lc/error.rb
100
+ - lib/irb/lc/help-message
101
+ - lib/irb/lc/ja/encoding_aliases.rb
102
+ - lib/irb/lc/ja/error.rb
103
+ - lib/irb/lc/ja/help-message
104
+ - lib/irb/locale.rb
105
+ - lib/irb/magic-file.rb
106
+ - lib/irb/notifier.rb
107
+ - lib/irb/output-method.rb
108
+ - lib/irb/ruby-lex.rb
109
+ - lib/irb/ruby_logo.aa
110
+ - lib/irb/slex.rb
111
+ - lib/irb/src_encoding.rb
112
+ - lib/irb/version.rb
113
+ - lib/irb/workspace.rb
114
+ - lib/irb/ws-for-case-2.rb
115
+ - lib/irb/xmp.rb
116
+ - man/irb.1
117
+ homepage: https://github.com/ruby/irb
118
+ licenses:
119
+ - BSD-2-Clause
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '2.4'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">"
133
+ - !ruby/object:Gem::Version
134
+ version: 1.3.1
135
+ requirements: []
136
+ rubygems_version: 3.0.6
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
140
+ test_files: []