Sha256: 11b76b293b56d0787fb76e9723ce5b5c3cd4e11d0515a402e7d330da80e52c12

Contents?: true

Size: 813 Bytes

Versions: 5

Compression:

Stored size: 813 Bytes

Contents

require 'sinatra/base'

module Sinatra
  class Default < Base

    # we assume that the first file that requires 'sinatra' 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, val.to_i }
        op.on('-h addr')   { |val| set :host, val }
      }.parse!(ARGV.dup)
    end
  end

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

include Sinatra::Delegator

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
sinatra-bundles-0.1.2 vendor/gems/sinatra-0.10.1/lib/sinatra/main.rb
sinatra-bundles-0.1.1 vendor/gems/sinatra-0.10.1/lib/sinatra/main.rb
sinatra-bundles-0.1.0 vendor/gems/sinatra-0.10.1/lib/sinatra/main.rb
sinatra-bundles-0.0.2 vendor/gems/sinatra-0.10.1/lib/sinatra/main.rb
darkhelmet-sinatra-0.10.1 lib/sinatra/main.rb