Class: Devup::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/devup/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#loggerObject (readonly)

Returns the value of attribute logger.



12
13
14
# File 'lib/devup/environment.rb', line 12

def logger
  @logger
end

#pwdObject (readonly)

Returns the value of attribute pwd.



12
13
14
# File 'lib/devup/environment.rb', line 12

def pwd
  @pwd
end

#shellObject (readonly)

Returns the value of attribute shell.



12
13
14
# File 'lib/devup/environment.rb', line 12

def shell
  @shell
end

Instance Method Details

#downObject



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

#envObject



25
26
27
# File 'lib/devup/environment.rb', line 25

def env
  services.map { |s| service_env(s) }.join("\n\n")
end

#projectObject



21
22
23
# File 'lib/devup/environment.rb', line 21

def project
  pwd.split("/")[-1].strip
end

#rootObject



53
54
55
# File 'lib/devup/environment.rb', line 53

def root
  Pathname.new pwd
end

#upObject



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