vx-builder 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29a989a45cc6de02e30b31a40ff4830a758cef76
|
4
|
+
data.tar.gz: 9e794895ca986bca941ea83dec6d98e1b6e99a7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84f47ae325d33445053b92788020eb3986fa3d943805dd9b6eab08fac1349a77558678b58523269f543d764f39420569ac2afe4e925196eed3fe80eaa55269a5
|
7
|
+
data.tar.gz: 7bf0c3159ffd3e3b5aa344fc4a16c861b98f0e46be8bf9b03d18b40dca9458f8cf6b206843480a825e11aea26d3a03053ef5caca50c95658dfe7c3ed28589071
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Vx
|
2
|
+
module Builder
|
3
|
+
class BuildConfiguration
|
4
|
+
class Deploy
|
5
|
+
|
6
|
+
attr_reader :attributes
|
7
|
+
|
8
|
+
def initialize(new_env)
|
9
|
+
normalize_attributes(new_env)
|
10
|
+
end
|
11
|
+
|
12
|
+
def providers
|
13
|
+
@providers
|
14
|
+
end
|
15
|
+
alias :attributes :providers
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def normalize_attributes(new_env)
|
20
|
+
attrs =
|
21
|
+
case new_env
|
22
|
+
when Array
|
23
|
+
new_env
|
24
|
+
when Hash
|
25
|
+
[new_env]
|
26
|
+
when String
|
27
|
+
[{"command" => new_env}]
|
28
|
+
else
|
29
|
+
[]
|
30
|
+
end
|
31
|
+
|
32
|
+
extract_options_and_normalize_items(attrs)
|
33
|
+
end
|
34
|
+
|
35
|
+
def extract_options_and_normalize_items(new_env)
|
36
|
+
@providers = []
|
37
|
+
new_env.each do |env|
|
38
|
+
case
|
39
|
+
when env["provider"]
|
40
|
+
@providers.push env
|
41
|
+
when env["command"]
|
42
|
+
@providers.push env.merge("provider" => "shell")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
@@ -37,7 +37,7 @@ module Vx
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
attr_reader :env, :cache, :artifacts
|
40
|
+
attr_reader :env, :cache, :artifacts, :deploy
|
41
41
|
|
42
42
|
def initialize(new_attributes = {}, matrix_attributes = {})
|
43
43
|
new_attributes = {} unless new_attributes.is_a?(Hash)
|
@@ -45,6 +45,7 @@ module Vx
|
|
45
45
|
@env = Env.new(new_attributes["env"])
|
46
46
|
@cache = Cache.new(new_attributes["cache"])
|
47
47
|
@artifacts = Artifacts.new(new_attributes["artifacts"])
|
48
|
+
@deploy = Deploy.new(new_attributes["deploy"])
|
48
49
|
|
49
50
|
@matrix_attributes = matrix_attributes
|
50
51
|
|
@@ -64,6 +65,10 @@ module Vx
|
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
68
|
+
def deploy?
|
69
|
+
!deploy.attributes.empty?
|
70
|
+
end
|
71
|
+
|
67
72
|
# for tests
|
68
73
|
def matrix_id
|
69
74
|
matrix_attributes.to_a.map{|i| i.join(":") }.sort.join(", ")
|
@@ -73,6 +78,7 @@ module Vx
|
|
73
78
|
attributes.merge("env" => env.attributes)
|
74
79
|
.merge("cache" => cache.attributes)
|
75
80
|
.merge("artifacts" => artifacts.attributes)
|
81
|
+
.merge("deploy" => deploy.attributes)
|
76
82
|
end
|
77
83
|
|
78
84
|
def to_yaml
|
data/lib/vx/builder/version.rb
CHANGED
data/spec/fixtures/travis.yml
CHANGED
@@ -43,7 +43,8 @@ describe Vx::Builder::BuildConfiguration do
|
|
43
43
|
"scala" => ['2.10.3'],
|
44
44
|
"script" => ["RAILS_ENV=test ls -1 && echo DONE!"],
|
45
45
|
"services" => ['rabbitmq'],
|
46
|
-
"artifacts" => ["app/foo.txt", "app/*.txt", "app/", {"prefix"=>"$CI_JOB_ID/"}]
|
46
|
+
"artifacts" => ["app/foo.txt", "app/*.txt", "app/", {"prefix"=>"$CI_JOB_ID/"}],
|
47
|
+
"deploy" => [{"command"=>"cap deploy production", "provider"=>"shell"}],
|
47
48
|
}
|
48
49
|
) }
|
49
50
|
end
|
@@ -111,4 +112,45 @@ describe Vx::Builder::BuildConfiguration do
|
|
111
112
|
end
|
112
113
|
end
|
113
114
|
|
115
|
+
context "deploy" do
|
116
|
+
subject { config.deploy }
|
117
|
+
|
118
|
+
context "when is empty" do
|
119
|
+
let(:content) { {} }
|
120
|
+
its(:attributes) { should eq [] }
|
121
|
+
|
122
|
+
it "build_configuration#deploy? should be false" do
|
123
|
+
expect(config).to_not be_deploy
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context "when is array" do
|
128
|
+
let(:content) { {
|
129
|
+
"deploy" => [
|
130
|
+
{
|
131
|
+
"provider" => "some"
|
132
|
+
}
|
133
|
+
]
|
134
|
+
} }
|
135
|
+
its(:attributes){ should eq [{"provider" => "some"}] }
|
136
|
+
|
137
|
+
it "build_configuration#deploy? should be true" do
|
138
|
+
expect(config).to be_deploy
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "when is hash" do
|
143
|
+
let(:content) { {
|
144
|
+
"deploy" => {
|
145
|
+
"provider" => "some"
|
146
|
+
}
|
147
|
+
} }
|
148
|
+
its(:attributes){ should eq [{"provider" => "some"}] }
|
149
|
+
|
150
|
+
it "build_configuration#deploy? should be true" do
|
151
|
+
expect(config).to be_deploy
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
114
156
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vx-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Galinsky
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/vx/builder/build_configuration.rb
|
127
127
|
- lib/vx/builder/build_configuration/artifacts.rb
|
128
128
|
- lib/vx/builder/build_configuration/cache.rb
|
129
|
+
- lib/vx/builder/build_configuration/deploy.rb
|
129
130
|
- lib/vx/builder/build_configuration/env.rb
|
130
131
|
- lib/vx/builder/configuration.rb
|
131
132
|
- lib/vx/builder/helper/config.rb
|