Module: HostOS::Env

Defined in:
lib/host-os.rb

Overview

Note:

When no environment is configured ‘prod

This module allows to identify the current environment by checking the ‘ENV` for the following variables in order:

  • RAILS_ENV

  • RACK_ENV

  • ENVIRONMENT

  • ENV

You can check for any boolean attribute:

Examples:

Query if the environment is configured as “staging”

HostOS.env.staging?

Test if the environment is configured as “production”

HostOS.env.is? :production

Constant Summary collapse

ID =

Returns environment identifier.

Returns:

  • (Symbol)

    environment identifier

identify

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.development?true, false (readonly)

Returns whether the environment is configured as “development”.

Returns:

  • (true, false)

    whether the environment is configured as “development”



# File 'lib/host-os.rb', line 61

.idSymbol (readonly)

Returns environment identifier.

Returns:

  • (Symbol)

    environment identifier



67
68
69
# File 'lib/host-os.rb', line 67

def id
  ID
end

.production?true, false (readonly)

Note:

This will return true if the environment is not configured.

Returns whether the environment is configured as “production”.

Returns:

  • (true, false)

    whether the environment is configured as “production”



# File 'lib/host-os.rb', line 54

.test?true, false (readonly)

Returns whether the environment is configured as “test”.

Returns:

  • (true, false)

    whether the environment is configured as “test”



# File 'lib/host-os.rb', line 58

Class Method Details

.is?(what) ⇒ true, false

Returns whether the environment is the given identifier.

Parameters:

  • what (Symbol, String)

    the identifier to check

Returns:

  • (true, false)

    whether the environment is the given identifier



# File 'lib/host-os.rb', line 71