Sha256: 4634da8b33c89e27edc623782e1967eb5ca31d60845fbfe33889dd0f5648fc8f

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

module Jubilee
  class Configuration
    attr_reader :app

    def initialize(options, &block)
      @options = options
      @block = block
    end

    def load
      @app = load_rack_adapter(@options, &@block)
    end

    def port
      @options[:Port]
    end

    def host
      @options[:Host]
    end

    def ssl
      @options[:ssl]
    end
    
    def keystore_path
      @options[:keystore_path]
    end

    def keystore_password
      @options[:keystore_password]
    end

    private
    def load_rack_adapter(options, &block)
      if block
        inner_app = Rack::Builder.new(&block).to_app
      else
        if options[:rackup]
          Kernel.load(options[:rackup])
          inner_app = Object.const_get(File.basename(options[:rackup], '.rb').capitalize.to_sym).new
        else
          Dir.chdir options[:chdir] if options[:chdir]
          inner_app, opts = Rack::Builder.parse_file "config.ru"
        end
      end
      case ENV["RACK_ENV"]
      when "development"
        Rack::Builder.new do
          use Rack::ContentLength
          use Rack::Chunked
          use Rack::CommonLogger, $stderr
          use Rack::ShowExceptions
          use Rack::Lint
          run inner_app
        end.to_app
      when "deployment"
        Rack::Builder.new do
          use Rack::ContentLength
          use Rack::Chunked
          use Rack::CommonLogger, $stderr
          run inner_app
        end.to_app
      else
        inner_app
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jubilee-0.4.1 lib/jubilee/configuration.rb