Class: Vx::Builder::ScriptBuilderV2::Stage

Inherits:
Object
  • Object
show all
Defined in:
lib/vx/builder/script_builder_v2.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {})
  @name        = options[:name]
  @environment = options[:environment] || {}
  @tasks       = []
  @vars        = {}
  @chdir       = nil
end

Instance Attribute Details

#chdirObject (readonly)

Returns the value of attribute chdir.



30
31
32
# File 'lib/vx/builder/script_builder_v2.rb', line 30

def chdir
  @chdir
end

#environmentObject (readonly)

Returns the value of attribute environment.



30
31
32
# File 'lib/vx/builder/script_builder_v2.rb', line 30

def environment
  @environment
end

#nameObject (readonly)

Returns the value of attribute name.



30
31
32
# File 'lib/vx/builder/script_builder_v2.rb', line 30

def name
  @name
end

#tasksObject (readonly)

Returns the value of attribute tasks.



30
31
32
# File 'lib/vx/builder/script_builder_v2.rb', line 30

def tasks
  @tasks
end

#varsObject (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, options = {})
  if options[: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

Returns:

  • (Boolean)


43
44
45
# File 'lib/vx/builder/script_builder_v2.rb', line 43

def tasks?
  @tasks.any?
end

#to_hashObject



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