Class: Devup::Environment
- Inherits:
-
Object
- Object
- Devup::Environment
- Defined in:
- lib/devup/environment.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#pwd ⇒ Object
readonly
Returns the value of attribute pwd.
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
Instance Method Summary collapse
- #down ⇒ Object
- #env ⇒ Object
-
#initialize(pwd:, compose: nil, logger:, shell: Shell.new(pwd: pwd, logger: logger)) ⇒ Environment
constructor
A new instance of Environment.
- #project ⇒ Object
- #root ⇒ Object
- #up ⇒ Object
Constructor Details
#initialize(pwd:, compose: nil, logger:, shell: Shell.new(pwd: pwd, logger: logger)) ⇒ Environment
Returns a new instance of Environment.
14 15 16 17 18 19 |
# File 'lib/devup/environment.rb', line 14 def initialize(pwd:, compose: nil, logger:, shell: Shell.new(pwd: pwd, logger: logger)) @pwd = pwd.to_s.strip @compose = compose @logger = logger @shell = shell end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/devup/environment.rb', line 12 def logger @logger end |
#pwd ⇒ Object (readonly)
Returns the value of attribute pwd.
12 13 14 |
# File 'lib/devup/environment.rb', line 12 def pwd @pwd end |
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
12 13 14 |
# File 'lib/devup/environment.rb', line 12 def shell @shell end |
Instance Method Details
#down ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/devup/environment.rb', line 42 def down logger.info "shutting down..." compose.stop compose.rm clear_dotenv logger.info "down" rescue => ex logger.debug ex logger.info "halted" end |
#env ⇒ Object
25 26 27 |
# File 'lib/devup/environment.rb', line 25 def env services.map { |s| service_env(s) }.join("\n\n") end |
#project ⇒ Object
21 22 23 |
# File 'lib/devup/environment.rb', line 21 def project pwd.split("/")[-1].strip end |
#root ⇒ Object
53 54 55 |
# File 'lib/devup/environment.rb', line 53 def root Pathname.new pwd end |
#up ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/devup/environment.rb', line 29 def up logger.info "starting up..." check compose.up write_dotenv logger.info "up" rescue => ex clear_dotenv logger.debug ex logger.error "halted" raise ex end |