Sha256: 265410b80702ed20e51001bd5d85d531fa9fb23120322d10e7c6afe56177e0d2

Contents?: true

Size: 829 Bytes

Versions: 1

Compression:

Stored size: 829 Bytes

Contents

require 'aldebaran/base'

module Aldebaran
  class Application < Base

    # we assume that the first file that requires 'aldebaran' is the
    # app_file. all other path related options are calculated based
    # on this path by default.
    set :app_file, caller_files.first || $0

    set :run, Proc.new { $0 == app_file }

    if run? && ARGV.any?
      require 'optparse'
      OptionParser.new { |op|
        op.on('-x')        {       set :lock, true }
        op.on('-e env')    { |val| set :environment, val.to_sym }
        op.on('-s server') { |val| set :server, val }
        op.on('-p port')   { |val| set :port, Integer(val) }
        op.on('-o addr')   { |val| set :bind, val }
      }.parse!(ARGV.dup)
    end
  end

  at_exit { Application.run! if $!.nil? && Application.run? }
end

include Aldebaran::Delegator

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aldebaran-1.0.1 lib/aldebaran/main.rb