Sha256: cf47be0b3233835462b98e8782ab01f4a2871b7776737fba56662b4f372c9174

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'

require 'optparse'

options = { :irb => irb }
OptionParser.new do |opt|
  opt.banner = "Usage: console [environment] [options]"
  opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v }
  opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v }
  opt.parse!(ARGV)
end

libs =  " -r irb/completion"
libs << " -r readline"

if options[:debugger]
  begin
    require 'rubygems'
    require 'ruby-debug'
    libs << " -r ruby-debug"
    puts "=> Debugger enabled"
  rescue Exception
    puts "You need to install ruby-debug to run the console in debugging mode. With gems, use 'gem install ruby-debug'"
    exit
  end
end

ADAPTOR_ENV = case ARGV.first
  when "d"; "development"
  when "t"; "test"
  else
    ARGV.first || 'development'
end

# set console environment
libs << " -r #{ADAPTOR_ROOT}/config/environments/#{ADAPTOR_ENV}.rb"

libs << " -r #{ADAPTOR_ROOT}/config/boot"

puts "Loading #{ADAPTOR_ENV} environment (Adaptation #{Adaptation::VERSION::STRING})"

exec "#{irb} #{libs} --simple-prompt"

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
adaptation-1.0.1 lib/commands/console.rb
adaptation-0.1.10 lib/commands/console.rb
adaptation-0.1.7 lib/commands/console.rb
adaptation-0.1.8 lib/commands/console.rb
adaptation-0.1.9 lib/commands/console.rb