Sha256: 993630925f7e524665100f0d716a0376473ff0dd7cb457af4568bb687a9bfdf3

Contents?: true

Size: 827 Bytes

Versions: 7

Compression:

Stored size: 827 Bytes

Contents

require 'rib/plugin'
require 'rib/api'

class Rib::Shell
  include Rib::API
  trap('INT'){ raise Interrupt }

  def self.use mod
    include mod
  end

  attr_reader :config
  def initialize(config={})
    self.config = {
      :result_prompt => '=> '                    ,
      :prompt        => '>> '                    ,
      :binding       => TOPLEVEL_BINDING         ,
      :exit          => [nil, 'exit', 'quit']    ,
      :line          => 1
    }.merge(config)
    @running = false
  end

  # Loops shell until user exits
  def loop
    before_loop
    @running = true
    in_loop
    self
  rescue Exception => e
    Rib.warn("Error while running loop:\n  #{format_error(e)}")
    raise
  ensure
    @running = false
    after_loop
  end

  def running?
    !!@running
  end

  protected
  attr_writer :config
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rib-0.9.5.pre.1 lib/rib/shell.rb
rib-0.9.5.pre.0 lib/rib/shell.rb
rib-0.9.4 lib/rib/shell.rb
rib-0.9.3 lib/rib/shell.rb
rib-0.9.2 lib/rib/shell.rb
rib-0.9.1 lib/rib/shell.rb
rib-0.9.0 lib/rib/shell.rb