Sha256: 2a76ce135fada54972ba5380cba3831b5b9054b698000c2fc672702e45bc2065

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

module Jubilee
  class Configuration
    def initialize(options, &block)
      @options = options
      @block = block
    end

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

    def app
      if !@options[:quiet] and @options[:environment] == "development"
        logger = @options[:logger] || STDOUT
        Rack::CommonLogger.new(@app, logger)
      else
        @app
      end
    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
        app = Rack::Builder.new(&block).to_app
      else
        if options[:rackup]
          Kernel.load(options[:rackup])
          app = Object.const_get(File.basename(options[:rackup], '.rb').capitalize.to_sym).new
        else
          Dir.chdir options[:chdir] if options[:chdir]
          app, opts = Rack::Builder.parse_file "config.ru"
        end
      end
      app
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jubilee-0.4.0 lib/jubilee/configuration.rb
jubilee-0.2.2 lib/jubilee/configuration.rb
jubilee-0.2.1 lib/jubilee/configuration.rb