Sha256: d7482a73a2d817cf203dfa64f45e624a3cc2663cdab575598f617a83be13d7e1

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 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?
  end

  # 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

3 entries across 3 versions & 1 rubygems

Version Path
goliath-1.0.1 lib/goliath/goliath.rb
goliath-1.0.0 lib/goliath/goliath.rb
goliath-1.0.0.beta.1 lib/goliath/goliath.rb