Class: RubyYacht::Hook::EnvironmentVariableBehavior
- Defined in:
- lib/ruby_yacht/dsl/hook.rb
Overview
This class provides a behavior for setting an environment variable in the image.
Instance Attribute Summary
Attributes inherited from Behavior
Instance Method Summary collapse
-
#dockerfile_command ⇒ Object
The command that should be run in a Dockerfile for this behavior.
-
#initialize(name, proc) ⇒ EnvironmentVariableBehavior
constructor
This initializer creates the behavior.
-
#shell_command ⇒ Object
The command that should be run in a shell script for this behavior.
-
#value ⇒ Object
The value for the environment variable.
Constructor Details
#initialize(name, proc) ⇒ EnvironmentVariableBehavior
This initializer creates the behavior.
Parameters
- name: String The name of the environment variable to create.
- proc: Proc The proc for generating the value for the environment variable.
238 239 240 241 242 |
# File 'lib/ruby_yacht/dsl/hook.rb', line 238 def initialize(name, proc) @name = name @proc = proc @context = self end |
Instance Method Details
#dockerfile_command ⇒ Object
The command that should be run in a Dockerfile for this behavior.
250 251 252 253 254 |
# File 'lib/ruby_yacht/dsl/hook.rb', line 250 def dockerfile_command value = self.value return nil unless value "ENV #{@name} #{value}" end |
#shell_command ⇒ Object
The command that should be run in a shell script for this behavior.
257 258 259 260 261 |
# File 'lib/ruby_yacht/dsl/hook.rb', line 257 def shell_command value = self.value return nil unless value "export #{@name}=\"#{value}\"" end |
#value ⇒ Object
The value for the environment variable.
245 246 247 |
# File 'lib/ruby_yacht/dsl/hook.rb', line 245 def value context.instance_eval(&@proc) end |