irb 1.0.0 → 1.4.1
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.
- checksums.yaml +4 -4
- data/.document +4 -0
- data/Gemfile +10 -2
- data/LICENSE.txt +3 -3
- data/README.md +3 -3
- data/Rakefile +17 -1
- data/doc/irb/irb-tools.rd.ja +184 -0
- data/doc/irb/irb.rd.ja +427 -0
- data/irb.gemspec +18 -4
- data/lib/irb/cmd/fork.rb +2 -4
- data/lib/irb/cmd/help.rb +10 -5
- data/lib/irb/cmd/info.rb +32 -0
- data/lib/irb/cmd/ls.rb +101 -0
- data/lib/irb/cmd/measure.rb +43 -0
- data/lib/irb/cmd/nop.rb +10 -4
- data/lib/irb/cmd/pushws.rb +0 -1
- data/lib/irb/cmd/show_source.rb +93 -0
- data/lib/irb/cmd/whereami.rb +20 -0
- data/lib/irb/color.rb +246 -0
- data/lib/irb/color_printer.rb +47 -0
- data/lib/irb/completion.rb +254 -55
- data/lib/irb/context.rb +165 -72
- data/lib/irb/easter-egg.rb +138 -0
- data/lib/irb/ext/change-ws.rb +0 -1
- data/lib/irb/ext/history.rb +47 -11
- data/lib/irb/ext/loader.rb +46 -20
- data/lib/irb/ext/multi-irb.rb +7 -7
- data/lib/irb/ext/save-history.rb +36 -11
- data/lib/irb/ext/tracer.rb +14 -2
- data/lib/irb/ext/use-loader.rb +4 -3
- data/lib/irb/ext/workspaces.rb +0 -1
- data/lib/irb/extend-command.rb +113 -63
- data/lib/irb/frame.rb +12 -7
- data/lib/irb/help.rb +0 -1
- data/lib/irb/init.rb +146 -26
- data/lib/irb/input-method.rb +287 -9
- data/lib/irb/inspector.rb +15 -11
- data/lib/irb/lc/error.rb +55 -16
- data/lib/irb/lc/help-message +25 -13
- data/lib/irb/lc/ja/error.rb +55 -14
- data/lib/irb/lc/ja/help-message +11 -6
- data/lib/irb/locale.rb +13 -4
- data/lib/irb/notifier.rb +12 -8
- data/lib/irb/output-method.rb +6 -6
- data/lib/irb/ruby-lex.rb +673 -992
- data/lib/irb/ruby_logo.aa +37 -0
- data/lib/irb/version.rb +2 -2
- data/lib/irb/workspace.rb +65 -21
- data/lib/irb/xmp.rb +1 -1
- data/lib/irb.rb +276 -96
- data/man/irb.1 +229 -0
- metadata +25 -31
- data/.gitignore +0 -9
- data/.travis.yml +0 -6
- data/lib/irb/lc/.document +0 -4
- data/lib/irb/ruby-token.rb +0 -267
- data/lib/irb/slex.rb +0 -282
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
-+smJYYN?mm-
|
3
|
+
HB"BBYT TQg NggT
|
4
|
+
9Q+g Nm,T 8g NJW
|
5
|
+
YS+ N2NJ"Sg N?
|
6
|
+
BQg #( gT Nggggk J
|
7
|
+
5j NJ NJ NNge
|
8
|
+
#Q #JJ NgT N(
|
9
|
+
@j bj mT J
|
10
|
+
Bj @/d NJ (
|
11
|
+
#q #(( NgT #J
|
12
|
+
5d #(t mT $d
|
13
|
+
#q @(@J NJB;
|
14
|
+
@( 5d ? HHH H HQmgggggggmN qD
|
15
|
+
5d #uN 2QdH E O
|
16
|
+
5 5JSd Nd NJH @d j
|
17
|
+
Fd @J4d s NQH #d (
|
18
|
+
#( #o6d Nd NgH #d #d
|
19
|
+
4 B&Od v NgT #d F
|
20
|
+
#( 9JGd NH NgUd F
|
21
|
+
#d #GJQ d NP $
|
22
|
+
#J #U+#Q N Q # j
|
23
|
+
j /W BQ+ BQ d NJ NJ
|
24
|
+
- NjJH HBIjTQggPJQgW N W k #J
|
25
|
+
#J b HYWgggN j s Nag d NN b #d
|
26
|
+
#J 5- D s Ngg N d Nd F
|
27
|
+
Fd BKH2 #+ s NNgg J Q J ]
|
28
|
+
F H @ J N y K(d P I
|
29
|
+
F4 E N? #d y #Q NJ E j
|
30
|
+
F W Nd q m Bg NxW N(H-
|
31
|
+
F d b @ m Hd gW vKJ
|
32
|
+
NJ d K d s Bg aT FDd
|
33
|
+
b # d N m BQ mV N>
|
34
|
+
e5 Nd #d NggggggQWH HHHH NJ -
|
35
|
+
m7 NW H N HSVO1z=?11-
|
36
|
+
NgTH bB kH WBHWWHBHWmQgg&gggggNNN
|
37
|
+
NNggggggNN
|
data/lib/irb/version.rb
CHANGED
data/lib/irb/workspace.rb
CHANGED
@@ -9,6 +9,10 @@
|
|
9
9
|
#
|
10
10
|
#
|
11
11
|
#
|
12
|
+
|
13
|
+
require "delegate"
|
14
|
+
|
15
|
+
IRB::TOPLEVEL_BINDING = binding
|
12
16
|
module IRB # :nodoc:
|
13
17
|
class WorkSpace
|
14
18
|
# Creates a new workspace.
|
@@ -48,18 +52,26 @@ EOF
|
|
48
52
|
end
|
49
53
|
@binding = BINDING_QUEUE.pop
|
50
54
|
|
51
|
-
when 3 # binding in function on TOPLEVEL_BINDING
|
52
|
-
@binding = eval("
|
55
|
+
when 3 # binding in function on TOPLEVEL_BINDING
|
56
|
+
@binding = eval("self.class.remove_method(:irb_binding) if defined?(irb_binding); private; def irb_binding; binding; end; irb_binding",
|
53
57
|
TOPLEVEL_BINDING,
|
54
58
|
__FILE__,
|
55
59
|
__LINE__ - 3)
|
60
|
+
when 4 # binding is a copy of TOPLEVEL_BINDING (default)
|
61
|
+
# Note that this will typically be IRB::TOPLEVEL_BINDING
|
62
|
+
# This is to avoid RubyGems' local variables (see issue #17623)
|
63
|
+
@binding = TOPLEVEL_BINDING.dup
|
56
64
|
end
|
57
65
|
end
|
66
|
+
|
58
67
|
if main.empty?
|
59
68
|
@main = eval("self", @binding)
|
60
69
|
else
|
61
70
|
@main = main[0]
|
62
|
-
|
71
|
+
end
|
72
|
+
IRB.conf[:__MAIN__] = @main
|
73
|
+
|
74
|
+
unless main.empty?
|
63
75
|
case @main
|
64
76
|
when Module
|
65
77
|
@binding = eval("IRB.conf[:__MAIN__].module_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
|
@@ -67,10 +79,32 @@ EOF
|
|
67
79
|
begin
|
68
80
|
@binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
|
69
81
|
rescue TypeError
|
70
|
-
|
82
|
+
fail CantChangeBinding, @main.inspect
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
case @main
|
88
|
+
when Object
|
89
|
+
use_delegator = @main.frozen?
|
90
|
+
else
|
91
|
+
use_delegator = true
|
92
|
+
end
|
93
|
+
|
94
|
+
if use_delegator
|
95
|
+
@main = SimpleDelegator.new(@main)
|
96
|
+
IRB.conf[:__MAIN__] = @main
|
97
|
+
@main.singleton_class.class_eval do
|
98
|
+
private
|
99
|
+
define_method(:exit) do |*a, &b|
|
100
|
+
# Do nothing, will be overridden
|
71
101
|
end
|
102
|
+
define_method(:binding, Kernel.instance_method(:binding))
|
103
|
+
define_method(:local_variables, Kernel.instance_method(:local_variables))
|
72
104
|
end
|
105
|
+
@binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, *@binding.source_location)
|
73
106
|
end
|
107
|
+
|
74
108
|
@binding.local_variable_set(:_, nil)
|
75
109
|
end
|
76
110
|
|
@@ -95,46 +129,56 @@ EOF
|
|
95
129
|
|
96
130
|
# error message manipulator
|
97
131
|
def filter_backtrace(bt)
|
132
|
+
return nil if bt =~ /\/irb\/.*\.rb/
|
133
|
+
return nil if bt =~ /\/irb\.rb/
|
134
|
+
return nil if bt =~ /tool\/lib\/.*\.rb|runner\.rb/ # for tests in Ruby repository
|
98
135
|
case IRB.conf[:CONTEXT_MODE]
|
99
|
-
when 0
|
100
|
-
return nil if bt =~ /\(irb_local_binding\)/
|
101
136
|
when 1
|
102
|
-
if
|
103
|
-
bt =~ %r!irb/.*\.rb! or
|
104
|
-
bt =~ /irb\.rb/)
|
105
|
-
return nil
|
106
|
-
end
|
107
|
-
when 2
|
108
|
-
return nil if bt =~ /irb\/.*\.rb/
|
109
|
-
return nil if bt =~ /irb\.rb/
|
137
|
+
return nil if bt =~ %r!/tmp/irb-binding!
|
110
138
|
when 3
|
111
|
-
return nil if bt =~ /irb\/.*\.rb/
|
112
|
-
return nil if bt =~ /irb\.rb/
|
113
139
|
bt = bt.sub(/:\s*in `irb_binding'/, '')
|
114
140
|
end
|
115
141
|
bt
|
116
142
|
end
|
117
143
|
|
118
144
|
def code_around_binding
|
119
|
-
|
145
|
+
if @binding.respond_to?(:source_location)
|
146
|
+
file, pos = @binding.source_location
|
147
|
+
else
|
148
|
+
file, pos = @binding.eval('[__FILE__, __LINE__]')
|
149
|
+
end
|
120
150
|
|
121
|
-
|
151
|
+
if defined?(::SCRIPT_LINES__[file]) && lines = ::SCRIPT_LINES__[file]
|
152
|
+
code = ::SCRIPT_LINES__[file].join('')
|
153
|
+
else
|
122
154
|
begin
|
123
|
-
|
155
|
+
code = File.read(file)
|
124
156
|
rescue SystemCallError
|
125
157
|
return
|
126
158
|
end
|
127
159
|
end
|
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
|
128
168
|
pos -= 1
|
129
169
|
|
130
170
|
start_pos = [pos - 5, 0].max
|
131
171
|
end_pos = [pos + 5, lines.size - 1].min
|
132
172
|
|
133
|
-
|
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
|
134
178
|
body = (start_pos..end_pos).map do |current_pos|
|
135
179
|
sprintf(fmt, pos == current_pos ? '=>' : '', current_pos + 1, lines[current_pos])
|
136
180
|
end.join("")
|
137
|
-
"\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}\n"
|
181
|
+
"\nFrom: #{file} @ line #{pos + 1} :\n\n#{body}#{Color.clear if use_colorize}\n"
|
138
182
|
end
|
139
183
|
|
140
184
|
def IRB.delete_caller
|