Sha256: 6083d64be80fed7885f500f39e37af68bbe83d26dd3c893d11ebd566c6cd9d08

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env ruby
#
# This is an interactive Ruby shell (IRB) for Rumai.
#
#
# Usage:
#
#   rumai [Options] [STUFF_FOR_IRB]
#
#   STUFF_FOR_IRB : Arguments and options for `irb`.
#
#
# Options:
#
#   -h, --help    : Show this message and exit.
#
#   -v, --version : Show version number and exit.
#

$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'rumai'

# parse command line
if ARGV.delete('-h') or ARGV.delete('--help')
  puts
  puts Rumai.inspect
  puts Rumai::TAGLINE
  puts
  puts
  puts File.read(__FILE__)[/^#(\r?\n)(.*?)\1\1/m, 2].gsub(/^# ?/, '')
  puts
  puts
  puts 'Read the user manual for more information:'
  puts
  puts "  #{Rumai::INSTDIR}/doc/index.html"
  puts
  puts "  #{Rumai::WEBSITE}"
  puts
  exit
elsif ARGV.delete('-v') or ARGV.delete('--version')
  puts Rumai::VERSION
  exit
end

# start IRB session
require 'irb'
require 'irb/completion' # enable TAB-completion

module IRB
  ##
  # Starts an IRB session *inside* the given object.
  #
  # This code was adapted from a snippet on Massimiliano Mirra's website:
  # http://www.therubymine.com/articles/2007/01/29/programmare-dallinterno
  #
  def self.start_session context
    IRB.setup nil

    env = IRB::WorkSpace.new(context)
    irb = IRB::Irb.new(env)
    IRB.conf[:MAIN_CONTEXT] = irb.context

    catch :IRB_EXIT do
      irb.eval_input
    end
  end
end

IRB.start_session Rumai

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rumai-3.2.2 bin/rumai