Class: Vx::Builder::BuildConfiguration
- Inherits:
-
Object
- Object
- Vx::Builder::BuildConfiguration
- Defined in:
- lib/vx/builder/build_configuration.rb,
lib/vx/builder/build_configuration/env.rb,
lib/vx/builder/build_configuration/cache.rb,
lib/vx/builder/build_configuration/vexor.rb,
lib/vx/builder/build_configuration/deploy.rb,
lib/vx/builder/build_configuration/matrix.rb,
lib/vx/builder/build_configuration/deploy/base.rb,
lib/vx/builder/build_configuration/deploy/shell.rb
Defined Under Namespace
Classes: Cache, Deploy, Env, Matrix, Vexor
Constant Summary collapse
- REQUIRED_KEYS =
%w{ rvm scala jdk go node_js rust language script }
- ATTRIBUTES =
%w{ rvm scala jdk go node_js rust language gemfile services image bundler_args before_install install before_script script after_success before_deploy after_deploy }
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#deploy ⇒ Object
readonly
Returns the value of attribute deploy.
-
#deploy_modules ⇒ Object
readonly
Returns the value of attribute deploy_modules.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#matrix ⇒ Object
readonly
Returns the value of attribute matrix.
-
#vexor ⇒ Object
readonly
Returns the value of attribute vexor.
Class Method Summary collapse
Instance Method Summary collapse
- #any? ⇒ Boolean
- #cached_directories ⇒ Object
- #deploy? ⇒ Boolean
- #deploy_modules? ⇒ Boolean
- #env_matrix ⇒ Object
-
#flat_matrix_attributes ⇒ Object
for deploy builder.
-
#initialize(new_attributes = {}, matrix_attributes = {}) ⇒ BuildConfiguration
constructor
A new instance of BuildConfiguration.
- #language ⇒ Object
- #matrix_attributes ⇒ Object
-
#matrix_id ⇒ Object
for tests.
- #to_hash ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(new_attributes = {}, matrix_attributes = {}) ⇒ BuildConfiguration
Returns a new instance of BuildConfiguration.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/vx/builder/build_configuration.rb', line 63 def initialize(new_attributes = {}, matrix_attributes = {}) new_attributes = {} unless new_attributes.is_a?(Hash) @env = Env.new new_attributes.delete("env") @cache = Cache.new new_attributes.delete("cache") @vexor = Vexor.new new_attributes.delete("vexor") @matrix = Matrix.new new_attributes.delete("matrix") @deploy = Deploy.new new_attributes.delete("deploy") @deploy_modules = new_attributes.delete("deploy_modules") || [] @deploy_modules = Deploy.restore_modules(@deploy_modules) @matrix_attributes = matrix_attributes build_attributes new_attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
60 61 62 |
# File 'lib/vx/builder/build_configuration.rb', line 60 def attributes @attributes end |
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
60 61 62 |
# File 'lib/vx/builder/build_configuration.rb', line 60 def cache @cache end |
#deploy ⇒ Object (readonly)
Returns the value of attribute deploy.
60 61 62 |
# File 'lib/vx/builder/build_configuration.rb', line 60 def deploy @deploy end |
#deploy_modules ⇒ Object (readonly)
Returns the value of attribute deploy_modules.
60 61 62 |
# File 'lib/vx/builder/build_configuration.rb', line 60 def deploy_modules @deploy_modules end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
60 61 62 |
# File 'lib/vx/builder/build_configuration.rb', line 60 def env @env end |
#matrix ⇒ Object (readonly)
Returns the value of attribute matrix.
60 61 62 |
# File 'lib/vx/builder/build_configuration.rb', line 60 def matrix @matrix end |
#vexor ⇒ Object (readonly)
Returns the value of attribute vexor.
60 61 62 |
# File 'lib/vx/builder/build_configuration.rb', line 60 def vexor @vexor end |
Class Method Details
.from_file(file) ⇒ Object
53 54 55 56 57 |
# File 'lib/vx/builder/build_configuration.rb', line 53 def from_file(file) if File.readable? file from_yaml File.read(file) end end |
.from_yaml(yaml) ⇒ Object
48 49 50 51 |
# File 'lib/vx/builder/build_configuration.rb', line 48 def from_yaml(yaml) hash = YAML.load(yaml) new hash end |
Instance Method Details
#any? ⇒ Boolean
80 81 82 83 84 |
# File 'lib/vx/builder/build_configuration.rb', line 80 def any? REQUIRED_KEYS.any? do |key| attributes[key].any? end end |
#cached_directories ⇒ Object
140 141 142 |
# File 'lib/vx/builder/build_configuration.rb', line 140 def cached_directories cache.enabled? and cache.directories end |
#deploy? ⇒ Boolean
104 105 106 |
# File 'lib/vx/builder/build_configuration.rb', line 104 def deploy? deploy.attributes.any? end |
#deploy_modules? ⇒ Boolean
108 109 110 |
# File 'lib/vx/builder/build_configuration.rb', line 108 def deploy_modules? deploy_modules.any? end |
#env_matrix ⇒ Object
132 133 134 |
# File 'lib/vx/builder/build_configuration.rb', line 132 def env_matrix env.matrix end |
#flat_matrix_attributes ⇒ Object
for deploy builder
87 88 89 |
# File 'lib/vx/builder/build_configuration.rb', line 87 def flat_matrix_attributes @matrix_attributes end |
#language ⇒ Object
136 137 138 |
# File 'lib/vx/builder/build_configuration.rb', line 136 def language @attributes["language"].first end |
#matrix_attributes ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/vx/builder/build_configuration.rb', line 91 def matrix_attributes @matrix_attributes.inject({}) do |a,pair| k,v = pair if k == 'env' v = v["matrix"].first end if v a[k] = v end a end end |
#matrix_id ⇒ Object
for tests
113 114 115 |
# File 'lib/vx/builder/build_configuration.rb', line 113 def matrix_id matrix_attributes.to_a.map{|i| i.join(":") }.sort.join(", ") end |
#to_hash ⇒ Object
117 118 119 120 121 122 123 124 125 126 |
# File 'lib/vx/builder/build_configuration.rb', line 117 def to_hash attributes.merge( "env" => env.attributes, "cache" => cache.attributes, "vexor" => vexor.attributes, "matrix" => matrix.attributes, "deploy" => deploy.attributes, "deploy_modules" => deploy_modules.map(&:to_hash) ) end |
#to_yaml ⇒ Object
128 129 130 |
# File 'lib/vx/builder/build_configuration.rb', line 128 def to_yaml to_hash.to_yaml end |