Class: Vx::Builder::ScriptBuilderV2

Inherits:
Object
  • Object
show all
Includes:
Common::Helper::Middlewares
Defined in:
lib/vx/builder/script_builder_v2.rb,
lib/vx/builder/script_builder_v2/go.rb,
lib/vx/builder/script_builder_v2/env.rb,
lib/vx/builder/script_builder_v2/base.rb,
lib/vx/builder/script_builder_v2/java.rb,
lib/vx/builder/script_builder_v2/ruby.rb,
lib/vx/builder/script_builder_v2/rust.rb,
lib/vx/builder/script_builder_v2/cache.rb,
lib/vx/builder/script_builder_v2/clone.rb,
lib/vx/builder/script_builder_v2/scala.rb,
lib/vx/builder/script_builder_v2/deploy.rb,
lib/vx/builder/script_builder_v2/nodejs.rb,
lib/vx/builder/script_builder_v2/python.rb,
lib/vx/builder/script_builder_v2/clojure.rb,
lib/vx/builder/script_builder_v2/defaults.rb,
lib/vx/builder/script_builder_v2/services.rb

Defined Under Namespace

Classes: Base, Cache, Clojure, Clone, Defaults, Deploy, Env, Go, Java, Nodejs, Python, Ruby, Rust, Scala, Services, Stage

Constant Summary collapse

TEMPLATE_SOURCE =
File.expand_path("../templates/script_builder_v2/to_script.erb", __FILE__)
TEMPLATE =
::ERB.new(File.read(TEMPLATE_SOURCE))

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task, source) ⇒ ScriptBuilderV2

Returns a new instance of ScriptBuilderV2.



97
98
99
100
101
102
# File 'lib/vx/builder/script_builder_v2.rb', line 97

def initialize(task, source)
  @source    = source
  @task      = task
  @stages    = []
  @cache_key = []
end

Instance Attribute Details

#cache_keyObject (readonly)

Returns the value of attribute cache_key.



95
96
97
# File 'lib/vx/builder/script_builder_v2.rb', line 95

def cache_key
  @cache_key
end

#sourceObject (readonly)

Returns the value of attribute source.



95
96
97
# File 'lib/vx/builder/script_builder_v2.rb', line 95

def source
  @source
end

#stagesObject (readonly)

Returns the value of attribute stages.



95
96
97
# File 'lib/vx/builder/script_builder_v2.rb', line 95

def stages
  @stages
end

#taskObject (readonly)

Returns the value of attribute task.



95
96
97
# File 'lib/vx/builder/script_builder_v2.rb', line 95

def task
  @task
end

Instance Method Details

#find_stage(name) ⇒ Object



113
114
115
# File 'lib/vx/builder/script_builder_v2.rb', line 113

def find_stage(name)
  @stages.find{|i| i.name == name }
end

#stage(name) ⇒ Object



104
105
106
107
108
109
110
111
# 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_hashObject



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# 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_scriptObject



117
118
119
120
121
122
# File 'lib/vx/builder/script_builder_v2.rb', line 117

def to_script
  @script ||=
    begin
      TEMPLATE.result(binding)
    end
end

#to_yamlObject



142
143
144
# File 'lib/vx/builder/script_builder_v2.rb', line 142

def to_yaml
  to_hash.to_yaml
end

#vexorObject



146
147
148
# File 'lib/vx/builder/script_builder_v2.rb', line 146

def vexor
  source.vexor
end