Sha256: 516809f82606fc0c36cadd7d12f39fda8864cd475823f0867c1b3bf6dd5db5d2

Contents?: true

Size: 1.37 KB

Versions: 6

Compression:

Stored size: 1.37 KB

Contents

require 'eventmachine'
require 'http/parser'
require 'async_rack'
require 'goliath/constants'
require 'goliath/version'

# The Goliath Framework
module Goliath
  module_function

  ENVIRONMENTS = [:development, :production, :test, :staging]

  # for example:
  #
  #   def development?
  #     env? :development
  #   end
  class << self
    ENVIRONMENTS.each do |e|
      define_method "#{e}?" do
        warn "[DEPRECATION] `Goliath.#{e}?` is deprecated.  Please use `Goliath.env?(#{e})` instead."
        env? e
      end
    end

    alias :prod? :production?
    alias :dev? :development?

    # Controls whether or not the application will be run using an at_exit block.
    attr_accessor :run_app_on_exit
    alias_method :run_app_on_exit?, :run_app_on_exit
  end
  # By default, we do run the application using the at_exit block.
  self.run_app_on_exit = true

  # Retrieves the current goliath environment
  #
  # @return [String] the current environment
  def env
    @env
  end

  # Sets the current goliath environment
  #
  # @param [String|Symbol] env the environment symbol
  def env=(e)
    @env = case(e.to_sym)
    when :dev  then :development
    when :prod then :production
    else e.to_sym
    end
  end

  # Determines if we are in a particular environment
  #
  # @return [Boolean] true if current environment matches, false otherwise
  def env?(e)
    env == e.to_sym
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
goliath-1.0.7 lib/goliath/goliath.rb
goliath-1.0.6 lib/goliath/goliath.rb
goliath-1.0.5 lib/goliath/goliath.rb
goliath-1.0.4 lib/goliath/goliath.rb
goliath-1.0.3 lib/goliath/goliath.rb
goliath-1.0.2 lib/goliath/goliath.rb