Class: Vx::Builder::ScriptBuilderV2::Stage
- Inherits:
-
Object
- Object
- Vx::Builder::ScriptBuilderV2::Stage
- Defined in:
- lib/vx/builder/script_builder_v2.rb
Instance Attribute Summary collapse
-
#chdir ⇒ Object
readonly
Returns the value of attribute chdir.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#tasks ⇒ Object
readonly
Returns the value of attribute tasks.
-
#vars ⇒ Object
readonly
Returns the value of attribute vars.
Instance Method Summary collapse
- #add_env(name, value, options = {}) ⇒ Object
- #add_task(name, value) ⇒ Object
- #add_var(name, value) ⇒ Object
- #chdir!(dir) ⇒ Object
-
#initialize(options = {}) ⇒ Stage
constructor
A new instance of Stage.
- #tasks? ⇒ Boolean
- #to_hash ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Stage
Returns a new instance of Stage.
31 32 33 34 35 36 37 |
# File 'lib/vx/builder/script_builder_v2.rb', line 31 def initialize( = {}) @name = [:name] @environment = [:environment] || {} @tasks = [] @vars = {} @chdir = nil end |
Instance Attribute Details
#chdir ⇒ Object (readonly)
Returns the value of attribute chdir.
30 31 32 |
# File 'lib/vx/builder/script_builder_v2.rb', line 30 def chdir @chdir end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
30 31 32 |
# File 'lib/vx/builder/script_builder_v2.rb', line 30 def environment @environment end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
30 31 32 |
# File 'lib/vx/builder/script_builder_v2.rb', line 30 def name @name end |
#tasks ⇒ Object (readonly)
Returns the value of attribute tasks.
30 31 32 |
# File 'lib/vx/builder/script_builder_v2.rb', line 30 def tasks @tasks end |
#vars ⇒ Object (readonly)
Returns the value of attribute vars.
30 31 32 |
# File 'lib/vx/builder/script_builder_v2.rb', line 30 def vars @vars end |
Instance Method Details
#add_env(name, value, options = {}) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/vx/builder/script_builder_v2.rb', line 47 def add_env(name, value, = {}) if [:hidden] @environment[name] = "!#{value}" else @environment[name] = value end end |
#add_task(name, value) ⇒ Object
39 40 41 |
# File 'lib/vx/builder/script_builder_v2.rb', line 39 def add_task(name, value) @tasks.push(name => value) end |
#add_var(name, value) ⇒ Object
59 60 61 |
# File 'lib/vx/builder/script_builder_v2.rb', line 59 def add_var(name, value) @vars[name] = value end |
#chdir!(dir) ⇒ Object
55 56 57 |
# File 'lib/vx/builder/script_builder_v2.rb', line 55 def chdir!(dir) @chdir = dir end |
#tasks? ⇒ Boolean
43 44 45 |
# File 'lib/vx/builder/script_builder_v2.rb', line 43 def tasks? @tasks.any? end |
#to_hash ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/vx/builder/script_builder_v2.rb', line 63 def to_hash h = { "name" => name } h.merge!("chdir" => chdir) if chdir h.merge!("vars" => vars) if vars.any? h.merge!( "environment" => environment ) if environment.any? h.merge!("tasks" => tasks) if tasks? h end |