class Vx::Builder::ScriptBuilderV2

Constants

Base
Clone
TEMPLATE
TEMPLATE_SOURCE

Attributes

cache_key[R]
source[R]
stages[R]
task[R]

Public Class Methods

new(task, source) click to toggle source
# File lib/vx/builder/script_builder_v2.rb, line 97
def initialize(task, source)
  @source    = source
  @task      = task
  @stages    = []
  @cache_key = []
end

Public Instance Methods

find_stage(name) click to toggle source
# File lib/vx/builder/script_builder_v2.rb, line 113
def find_stage(name)
  @stages.find{|i| i.name == name }
end
stage(name) click to toggle source
# File lib/vx/builder/script_builder_v2.rb, line 104
def stage(name)
  found = find_stage(name)
  unless found
    found = Stage.new(name: name)
    @stages.push found
  end
  found
end
to_hash() click to toggle source
# File lib/vx/builder/script_builder_v2.rb, line 124
def to_hash
  @hash ||=
    begin
      call_env
      ordered = %w{
        clone init before_install install database
        before_script script after_success teardown
      }.inject([]) do |a, name|
        if found = find_stage(name)
          a << found
        end
        a
      end

      ordered.map(&:to_hash)
    end
end
to_script() click to toggle source
# File lib/vx/builder/script_builder_v2.rb, line 117
def to_script
  @script ||=
    begin
      TEMPLATE.result(binding)
    end
end
to_yaml() click to toggle source
# File lib/vx/builder/script_builder_v2.rb, line 142
def to_yaml
  to_hash.to_yaml
end
vexor() click to toggle source
# File lib/vx/builder/script_builder_v2.rb, line 146
def vexor
  source.vexor
end

Private Instance Methods

call_env() click to toggle source
# File lib/vx/builder/script_builder_v2.rb, line 152
def call_env
  @env ||= run_middlewares(self) {|_| _ }
end