Class: Mooncell::Environment Private
- Inherits:
-
Object
- Object
- Mooncell::Environment
- Defined in:
- lib/mooncell/environment.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Mooncell environment
Constant Summary collapse
- LOCK =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Global lock
Mutex.new
- MOONCELL_ENV =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Standard Mooncell ENV Key
'MOONCELL_ENV'
- DEFAULT_ENV =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default Mooncell environment
'development'
- TEST_ENV =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Mooncell test environment
'test'
- PRODUCTION_ENV =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Mooncell production environment
'production'
- APPS_PATH =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'apps'
- DOTENV_LOCAL_FILE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'.env.local'
- DOTENV_FILES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default ‘.env` files will be loaded
[ '.env.%<environment>s.local', DOTENV_LOCAL_FILE, '.env.%<environment>s', '.env' ].freeze
- CODE_RELOADING =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 'development' => true }.freeze
Instance Method Summary collapse
- #apps_path ⇒ Object private
-
#code_reloading? ⇒ TrueClass, FalseClass
private
Determine if activate code reloading for current environment.
-
#config ⇒ Pathname
(also: #project_config)
private
Project environment configuration path.
-
#environment ⇒ String
private
The current environment.
-
#initialize(options = {}) ⇒ Environment
constructor
private
Initialize a Mooncell Environment.
-
#require_project_environment ⇒ Object
private
Load project environment configuration.
-
#root ⇒ Pathname
private
Application’s root.
Constructor Details
#initialize(options = {}) ⇒ Environment
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a Mooncell Environment
69 70 71 72 73 |
# File 'lib/mooncell/environment.rb', line 69 def initialize( = {}) opts = .to_h.dup @env = Mooncell::Env.new(env: opts.delete(:env) || ENV) LOCK.synchronize { load_env_vars! } end |
Instance Method Details
#apps_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
101 102 103 |
# File 'lib/mooncell/environment.rb', line 101 def apps_path root.join(APPS_PATH) end |
#code_reloading? ⇒ TrueClass, FalseClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determine if activate code reloading for current environment
132 133 134 |
# File 'lib/mooncell/environment.rb', line 132 def code_reloading? !!CODE_RELOADING[environment] # rubocop:disable Style/DoubleNegation end |
#config ⇒ Pathname Also known as: project_config
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Project environment configuration path
111 112 113 |
# File 'lib/mooncell/environment.rb', line 111 def config root.join('config', 'environment.rb') end |
#environment ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The current environment
95 96 97 |
# File 'lib/mooncell/environment.rb', line 95 def environment @environment ||= env[MOONCELL_ENV] || DEFAULT_ENV end |
#require_project_environment ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Load project environment configuration
122 123 124 |
# File 'lib/mooncell/environment.rb', line 122 def require_project_environment require project_config.to_s end |
#root ⇒ Pathname
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Application’s root
81 82 83 84 85 |
# File 'lib/mooncell/environment.rb', line 81 def root @root ||= Bundler.root rescue Bundler::GemfileNotFound @root = Pathname.new(Dir.pwd) end |