aboutsummaryrefslogtreecommitdiffstats
path: root/lib/irb/ext
diff options
context:
space:
mode:
Diffstat (limited to 'lib/irb/ext')
-rw-r--r--lib/irb/ext/change-ws.rb10
-rw-r--r--lib/irb/ext/history.rb56
-rw-r--r--lib/irb/ext/loader.rb118
-rw-r--r--lib/irb/ext/math-mode.rb8
-rw-r--r--lib/irb/ext/multi-irb.rb16
-rw-r--r--lib/irb/ext/save-history.rb50
-rw-r--r--lib/irb/ext/tracer.rb26
-rw-r--r--lib/irb/ext/use-loader.rb28
-rw-r--r--lib/irb/ext/workspaces.rb26
9 files changed, 169 insertions, 169 deletions
diff --git a/lib/irb/ext/change-ws.rb b/lib/irb/ext/change-ws.rb
index ce921eb5e3..a5c243aaf3 100644
--- a/lib/irb/ext/change-ws.rb
+++ b/lib/irb/ext/change-ws.rb
@@ -15,9 +15,9 @@ module IRB # :nodoc:
# Inherited from +TOPLEVEL_BINDING+.
def home_workspace
if defined? @home_workspace
- @home_workspace
+ @home_workspace
else
- @home_workspace = @workspace
+ @home_workspace = @workspace
end
end
@@ -30,14 +30,14 @@ module IRB # :nodoc:
# See IRB::WorkSpace.new for more information.
def change_workspace(*_main)
if _main.empty?
- @workspace = home_workspace
- return main
+ @workspace = home_workspace
+ return main
end
@workspace = WorkSpace.new(_main[0])
if !(class<<main;ancestors;end).include?(ExtendCommandBundle)
- main.extend ExtendCommandBundle
+ main.extend ExtendCommandBundle
end
end
diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb
index 3239c57a6c..d991f4d33b 100644
--- a/lib/irb/ext/history.rb
+++ b/lib/irb/ext/history.rb
@@ -21,10 +21,10 @@ module IRB # :nodoc:
def set_last_value(value)
_set_last_value(value)
-# @workspace.evaluate self, "_ = IRB.CurrentContext.last_value"
+ # @workspace.evaluate self, "_ = IRB.CurrentContext.last_value"
if @eval_history #and !@eval_history_values.equal?(llv)
- @eval_history_values.push @line_no, @last_value
- @workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}"
+ @eval_history_values.push @line_no, @last_value
+ @workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}"
end
@last_value
@@ -43,16 +43,16 @@ module IRB # :nodoc:
# If +no+ is +nil+, execution result history isn't used (default).
def eval_history=(no)
if no
- if defined?(@eval_history) && @eval_history
- @eval_history_values.size(no)
- else
- @eval_history_values = History.new(no)
- IRB.conf[:__TMP__EHV__] = @eval_history_values
- @workspace.evaluate(self, "__ = IRB.conf[:__TMP__EHV__]")
- IRB.conf.delete(:__TMP_EHV__)
- end
+ if defined?(@eval_history) && @eval_history
+ @eval_history_values.size(no)
+ else
+ @eval_history_values = History.new(no)
+ IRB.conf[:__TMP__EHV__] = @eval_history_values
+ @workspace.evaluate(self, "__ = IRB.conf[:__TMP__EHV__]")
+ IRB.conf.delete(:__TMP_EHV__)
+ end
else
- @eval_history_values = nil
+ @eval_history_values = nil
end
@eval_history = no
end
@@ -68,20 +68,20 @@ module IRB # :nodoc:
def size(size)
if size != 0 && size < @size
- @contents = @contents[@size - size .. @size]
+ @contents = @contents[@size - size .. @size]
end
@size = size
end
def [](idx)
begin
- if idx >= 0
- @contents.find{|no, val| no == idx}[1]
- else
- @contents[idx][1]
- end
+ if idx >= 0
+ @contents.find{|no, val| no == idx}[1]
+ else
+ @contents[idx][1]
+ end
rescue NameError
- nil
+ nil
end
end
@@ -94,22 +94,22 @@ module IRB # :nodoc:
def inspect
if @contents.empty?
- return real_inspect
+ return real_inspect
end
unless (last = @contents.pop)[1].equal?(self)
- @contents.push last
- last = nil
+ @contents.push last
+ last = nil
end
str = @contents.collect{|no, val|
- if val.equal?(self)
- "#{no} ...self-history..."
- else
- "#{no} #{val.inspect}"
- end
+ if val.equal?(self)
+ "#{no} ...self-history..."
+ else
+ "#{no} #{val.inspect}"
+ end
}.join("\n")
if str == ""
- str = "Empty."
+ str = "Empty."
end
@contents.push last if last
str
diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb
index 6cdc8ec898..9edf02b1d0 100644
--- a/lib/irb/ext/loader.rb
+++ b/lib/irb/ext/loader.rb
@@ -33,14 +33,14 @@ module IRB # :nodoc:
def search_file_from_ruby_path(fn) # :nodoc:
if /^#{Regexp.quote(File::Separator)}/ =~ fn
- return fn if File.exist?(fn)
- return nil
+ return fn if File.exist?(fn)
+ return nil
end
for path in $:
- if File.exist?(f = File.join(path, fn))
- return f
- end
+ if File.exist?(f = File.join(path, fn))
+ return f
+ end
end
return nil
end
@@ -50,20 +50,20 @@ module IRB # :nodoc:
# See Irb#suspend_input_method for more information.
def source_file(path)
irb.suspend_name(path, File.basename(path)) do
- irb.suspend_input_method(FileInputMethod.new(path)) do
- |back_io|
- irb.signal_status(:IN_LOAD) do
- if back_io.kind_of?(FileInputMethod)
- irb.eval_input
- else
- begin
- irb.eval_input
- rescue LoadAbort
- print "load abort!!\n"
- end
- end
- end
- end
+ irb.suspend_input_method(FileInputMethod.new(path)) do
+ |back_io|
+ irb.signal_status(:IN_LOAD) do
+ if back_io.kind_of?(FileInputMethod)
+ irb.eval_input
+ else
+ begin
+ irb.eval_input
+ rescue LoadAbort
+ print "load abort!!\n"
+ end
+ end
+ end
+ end
end
end
@@ -73,28 +73,28 @@ module IRB # :nodoc:
def load_file(path, priv = nil)
irb.suspend_name(path, File.basename(path)) do
- if priv
- ws = WorkSpace.new(Module.new)
- else
- ws = WorkSpace.new
- end
- irb.suspend_workspace(ws) do
- irb.suspend_input_method(FileInputMethod.new(path)) do
- |back_io|
- irb.signal_status(:IN_LOAD) do
-# p irb.conf
- if back_io.kind_of?(FileInputMethod)
- irb.eval_input
- else
- begin
- irb.eval_input
- rescue LoadAbort
- print "load abort!!\n"
- end
- end
- end
- end
- end
+ if priv
+ ws = WorkSpace.new(Module.new)
+ else
+ ws = WorkSpace.new
+ end
+ irb.suspend_workspace(ws) do
+ irb.suspend_input_method(FileInputMethod.new(path)) do
+ |back_io|
+ irb.signal_status(:IN_LOAD) do
+ # p irb.conf
+ if back_io.kind_of?(FileInputMethod)
+ irb.eval_input
+ else
+ begin
+ irb.eval_input
+ rescue LoadAbort
+ print "load abort!!\n"
+ end
+ end
+ end
+ end
+ end
end
end
@@ -104,25 +104,25 @@ module IRB # :nodoc:
back_name = @irb_name
back_scanner = @irb.scanner
begin
- @io = FileInputMethod.new(path)
- @irb_name = File.basename(path)
- @irb_path = path
- @irb.signal_status(:IN_LOAD) do
- if back_io.kind_of?(FileInputMethod)
- @irb.eval_input
- else
- begin
- @irb.eval_input
- rescue LoadAbort
- print "load abort!!\n"
- end
- end
- end
+ @io = FileInputMethod.new(path)
+ @irb_name = File.basename(path)
+ @irb_path = path
+ @irb.signal_status(:IN_LOAD) do
+ if back_io.kind_of?(FileInputMethod)
+ @irb.eval_input
+ else
+ begin
+ @irb.eval_input
+ rescue LoadAbort
+ print "load abort!!\n"
+ end
+ end
+ end
ensure
- @io = back_io
- @irb_name = back_name
- @irb_path = back_path
- @irb.scanner = back_scanner
+ @io = back_io
+ @irb_name = back_name
+ @irb_path = back_path
+ @irb.scanner = back_scanner
end
end
end
diff --git a/lib/irb/ext/math-mode.rb b/lib/irb/ext/math-mode.rb
index 067eb1e7fa..01bd24a157 100644
--- a/lib/irb/ext/math-mode.rb
+++ b/lib/irb/ext/math-mode.rb
@@ -28,14 +28,14 @@ module IRB
# more information.
def math_mode=(opt)
if @math_mode == true && !opt
- IRB.fail CantReturnToNormalMode
- return
+ IRB.fail CantReturnToNormalMode
+ return
end
@math_mode = opt
if math_mode
- main.extend Math
- print "start math mode\n" if verbose?
+ main.extend Math
+ print "start math mode\n" if verbose?
end
end
diff --git a/lib/irb/ext/multi-irb.rb b/lib/irb/ext/multi-irb.rb
index e49a158fa3..b46aa5a1d8 100644
--- a/lib/irb/ext/multi-irb.rb
+++ b/lib/irb/ext/multi-irb.rb
@@ -258,22 +258,22 @@ module IRB
class Irb
def signal_handle
unless @context.ignore_sigint?
- print "\nabort!!\n" if @context.verbose?
- exit
+ print "\nabort!!\n" if @context.verbose?
+ exit
end
case @signal_status
when :IN_INPUT
- print "^C\n"
- IRB.JobManager.thread(self).raise RubyLex::TerminateLineInput
+ print "^C\n"
+ IRB.JobManager.thread(self).raise RubyLex::TerminateLineInput
when :IN_EVAL
- IRB.irb_abort(self)
+ IRB.irb_abort(self)
when :IN_LOAD
- IRB.irb_abort(self, LoadAbort)
+ IRB.irb_abort(self, LoadAbort)
when :IN_IRB
- # ignore
+ # ignore
else
- # ignore other cases as well
+ # ignore other cases as well
end
end
end
diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb
index 7b3fcbbeec..d2ea37f950 100644
--- a/lib/irb/ext/save-history.rb
+++ b/lib/irb/ext/save-history.rb
@@ -18,7 +18,7 @@ module IRB
class Context
def init_save_history# :nodoc:
unless (class<<@io;self;end).include?(HistorySavingAbility)
- @io.extend(HistorySavingAbility)
+ @io.extend(HistorySavingAbility)
end
end
@@ -39,9 +39,9 @@ module IRB
def save_history=(val)
IRB.conf[:SAVE_HISTORY] = val
if val
- main_context = IRB.conf[:MAIN_CONTEXT]
- main_context = self unless main_context
- main_context.init_save_history
+ main_context = IRB.conf[:MAIN_CONTEXT]
+ main_context = self unless main_context
+ main_context.init_save_history
end
end
@@ -83,37 +83,37 @@ module IRB
def load_history
if history_file = IRB.conf[:HISTORY_FILE]
- history_file = File.expand_path(history_file)
+ history_file = File.expand_path(history_file)
end
history_file = IRB.rc_file("_history") unless history_file
if File.exist?(history_file)
- open(history_file) do |f|
- f.each {|l| HISTORY << l.chomp}
- end
+ open(history_file) do |f|
+ f.each {|l| HISTORY << l.chomp}
+ end
end
end
def save_history
if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
- if history_file = IRB.conf[:HISTORY_FILE]
- history_file = File.expand_path(history_file)
- end
- history_file = IRB.rc_file("_history") unless history_file
+ if history_file = IRB.conf[:HISTORY_FILE]
+ history_file = File.expand_path(history_file)
+ end
+ history_file = IRB.rc_file("_history") unless history_file
- # Change the permission of a file that already exists[BUG #7694]
- begin
- if File.stat(history_file).mode & 066 != 0
- File.chmod(0600, history_file)
- end
- rescue Errno::ENOENT
- rescue
- raise
- end
+ # Change the permission of a file that already exists[BUG #7694]
+ begin
+ if File.stat(history_file).mode & 066 != 0
+ File.chmod(0600, history_file)
+ end
+ rescue Errno::ENOENT
+ rescue
+ raise
+ end
- open(history_file, 'w', 0600 ) do |f|
- hist = HISTORY.to_a
- f.puts(hist[-num..-1] || hist)
- end
+ open(history_file, 'w', 0600 ) do |f|
+ hist = HISTORY.to_a
+ f.puts(hist[-num..-1] || hist)
+ end
end
end
end
diff --git a/lib/irb/ext/tracer.rb b/lib/irb/ext/tracer.rb
index 8c9083dbad..c145cf5b4f 100644
--- a/lib/irb/ext/tracer.rb
+++ b/lib/irb/ext/tracer.rb
@@ -18,7 +18,7 @@ module IRB
Tracer.add_filter {
|event, file, line, id, binding, *rests|
/^#{Regexp.quote(@CONF[:IRB_LIB_PATH])}/ !~ file and
- File::basename(file) != "irb.rb"
+ File::basename(file) != "irb.rb"
}
end
@@ -35,12 +35,12 @@ module IRB
# See +lib/tracer.rb+ for more information.
def use_tracer=(opt)
if opt
- Tracer.set_get_line_procs(@irb_path) {
- |line_no, *rests|
- @io.line(line_no)
- }
+ Tracer.set_get_line_procs(@irb_path) {
+ |line_no, *rests|
+ @io.line(line_no)
+ }
elsif !opt && @use_tracer
- Tracer.off
+ Tracer.off
end
@use_tracer=opt
end
@@ -54,14 +54,14 @@ module IRB
# See +lib/tracer.rb+ for more information.
def evaluate(context, statements, file = nil, line = nil)
if context.use_tracer? && file != nil && line != nil
- Tracer.on
- begin
- __evaluate__(context, statements, file, line)
- ensure
- Tracer.off
- end
+ Tracer.on
+ begin
+ __evaluate__(context, statements, file, line)
+ ensure
+ Tracer.off
+ end
else
- __evaluate__(context, statements, file || __FILE__, line || __LINE__)
+ __evaluate__(context, statements, file || __FILE__, line || __LINE__)
end
end
end
diff --git a/lib/irb/ext/use-loader.rb b/lib/irb/ext/use-loader.rb
index 4e98f5b7a2..99e76b722f 100644
--- a/lib/irb/ext/use-loader.rb
+++ b/lib/irb/ext/use-loader.rb
@@ -49,20 +49,20 @@ module IRB
def use_loader=(opt)
if IRB.conf[:USE_LOADER] != opt
- IRB.conf[:USE_LOADER] = opt
- if opt
- if !$".include?("irb/cmd/load")
- end
- (class<<@workspace.main;self;end).instance_eval {
- alias_method :load, :irb_load
- alias_method :require, :irb_require
- }
- else
- (class<<@workspace.main;self;end).instance_eval {
- alias_method :load, :__original__load__IRB_use_loader__
- alias_method :require, :__original__require__IRB_use_loader__
- }
- end
+ IRB.conf[:USE_LOADER] = opt
+ if opt
+ if !$".include?("irb/cmd/load")
+ end
+ (class<<@workspace.main;self;end).instance_eval {
+ alias_method :load, :irb_load
+ alias_method :require, :irb_require
+ }
+ else
+ (class<<@workspace.main;self;end).instance_eval {
+ alias_method :load, :__original__load__IRB_use_loader__
+ alias_method :require, :__original__require__IRB_use_loader__
+ }
+ end
end
print "Switch to load/require#{unless use_loader; ' non';end} trace mode.\n" if verbose?
opt
diff --git a/lib/irb/ext/workspaces.rb b/lib/irb/ext/workspaces.rb
index 641befbdf3..4237037271 100644
--- a/lib/irb/ext/workspaces.rb
+++ b/lib/irb/ext/workspaces.rb
@@ -20,9 +20,9 @@ module IRB # :nodoc:
# WorkSpaces in the current stack
def workspaces
if defined? @workspaces
- @workspaces
+ @workspaces
else
- @workspaces = []
+ @workspaces = []
end
end
@@ -33,20 +33,20 @@ module IRB # :nodoc:
# information.
def push_workspace(*_main)
if _main.empty?
- if workspaces.empty?
- print "No other workspace\n"
- return nil
- end
- ws = workspaces.pop
- workspaces.push @workspace
- @workspace = ws
- return workspaces
+ if workspaces.empty?
+ print "No other workspace\n"
+ return nil
+ end
+ ws = workspaces.pop
+ workspaces.push @workspace
+ @workspace = ws
+ return workspaces
end
workspaces.push @workspace
@workspace = WorkSpace.new(@workspace.binding, _main[0])
if !(class<<main;ancestors;end).include?(ExtendCommandBundle)
- main.extend ExtendCommandBundle
+ main.extend ExtendCommandBundle
end
end
@@ -56,8 +56,8 @@ module IRB # :nodoc:
# Also, see #push_workspace.
def pop_workspace
if workspaces.empty?
- print "workspace stack empty\n"
- return
+ print "workspace stack empty\n"
+ return
end
@workspace = workspaces.pop
end