Class: Rascal::Environment
- Inherits:
-
Object
- Object
- Rascal::Environment
- Defined in:
- lib/rascal/environment.rb
Instance Attribute Summary collapse
-
#before_shell ⇒ Object
readonly
Returns the value of attribute before_shell.
-
#container ⇒ Object
readonly
Returns the value of attribute container.
-
#env_variables ⇒ Object
readonly
Returns the value of attribute env_variables.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#services ⇒ Object
readonly
Returns the value of attribute services.
-
#volumes ⇒ Object
readonly
Returns the value of attribute volumes.
-
#working_dir ⇒ Object
readonly
Returns the value of attribute working_dir.
Instance Method Summary collapse
- #clean(clean_volumes: false) ⇒ Object
-
#initialize(full_name, name:, image:, env_variables: {}, services: [], volumes: [], before_shell: [], after_shell: [], working_dir: nil) ⇒ Environment
constructor
A new instance of Environment.
- #run_shell ⇒ Object
- #update(skip: []) ⇒ Object
Constructor Details
#initialize(full_name, name:, image:, env_variables: {}, services: [], volumes: [], before_shell: [], after_shell: [], working_dir: nil) ⇒ Environment
Returns a new instance of Environment.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rascal/environment.rb', line 5 def initialize(full_name, name:, image:, env_variables: {}, services: [], volumes: [], before_shell: [], after_shell: [], working_dir: nil) @name = name @network = Docker::Network.new(full_name) @container = Docker::Container.new(full_name, image) @env_variables = env_variables @services = services @volumes = volumes @working_dir = working_dir @before_shell = before_shell @after_shell = after_shell end |
Instance Attribute Details
#before_shell ⇒ Object (readonly)
Returns the value of attribute before_shell.
3 4 5 |
# File 'lib/rascal/environment.rb', line 3 def before_shell @before_shell end |
#container ⇒ Object (readonly)
Returns the value of attribute container.
3 4 5 |
# File 'lib/rascal/environment.rb', line 3 def container @container end |
#env_variables ⇒ Object (readonly)
Returns the value of attribute env_variables.
3 4 5 |
# File 'lib/rascal/environment.rb', line 3 def env_variables @env_variables end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rascal/environment.rb', line 3 def name @name end |
#network ⇒ Object (readonly)
Returns the value of attribute network.
3 4 5 |
# File 'lib/rascal/environment.rb', line 3 def network @network end |
#services ⇒ Object (readonly)
Returns the value of attribute services.
3 4 5 |
# File 'lib/rascal/environment.rb', line 3 def services @services end |
#volumes ⇒ Object (readonly)
Returns the value of attribute volumes.
3 4 5 |
# File 'lib/rascal/environment.rb', line 3 def volumes @volumes end |
#working_dir ⇒ Object (readonly)
Returns the value of attribute working_dir.
3 4 5 |
# File 'lib/rascal/environment.rb', line 3 def working_dir @working_dir end |
Instance Method Details
#clean(clean_volumes: false) ⇒ Object
30 31 32 33 34 |
# File 'lib/rascal/environment.rb', line 30 def clean(clean_volumes: false) @services.each(&:clean) @network.clean @volumes.each(&:clean) if clean_volumes end |
#run_shell ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rascal/environment.rb', line 17 def run_shell download_missing start_services command = [*@before_shell, 'bash', *@after_shell].join(';') @container.run_and_attach('bash', '-c', command, env: @env_variables, network: @network, volumes: @volumes, working_dir: @working_dir, allow_failure: true ) end |
#update(skip: []) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rascal/environment.rb', line 36 def update(skip: []) [ *@services.collect { |s| s.update(skip: skip) }, *@container.update(skip: skip), ] end |