lib/rib/shell.rb in rib-1.5.1 vs lib/rib/shell.rb in rib-1.5.2
- old
+ new
@@ -1,11 +1,11 @@
require 'rib/plugin'
require 'rib/api'
-class Rib::Shell
- include Rib::API
+module Rib; class Shell
+ include API
trap('INT'){ raise Interrupt }
def self.use mod
include mod
end
@@ -39,31 +39,44 @@
config[:binding] ||= new_private_binding
self.config = {:result_prompt => '=> ',
:prompt => '>> ',
:exit => [nil],
:line => 1 }.merge(config)
- @running = false
+ stop
end
# Loops shell until user exits
def loop
before_loop
- @running = true
+ start
in_loop
+ stop
self
rescue Exception => e
Rib.warn("Error while running loop:\n #{format_error(e)}")
raise
ensure
- @running = false
+
after_loop
end
+ def start
+ @running = true
+ end
+
+ def stop
+ @running = false
+ end
+
def running?
!!@running
end
+ def warnings
+ @warnings ||= []
+ end
+
protected
attr_writer :config
private
# Avoid namespace pollution from rubygems bin stub.
@@ -77,6 +90,6 @@
ret = main
singleton_class.send(:remove_method, 'main') # never pollute anything
ret
RUBY
end
-end
+end; end