vx-builder 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27ce162a3982b2cbce95a68d6b1829cc346c851e
4
- data.tar.gz: 08c7e3704304f0e14ed59632209089bc1b468e26
3
+ metadata.gz: 2d33b75d7dad8e9a9fd0e959b939b7d72c41fc92
4
+ data.tar.gz: 5666100d3833bc64c8991ac1eb17455d82a9511e
5
5
  SHA512:
6
- metadata.gz: 3d6e1ae7836096a14dec61d2a7b028a3cdaea69e9a01a4f88a34836a49888aea05f67aaa05a3ad0857a2f57fcc5fffeeb91a9e699252321b386b536c4371dd4c
7
- data.tar.gz: c89dff17cae258e6c463e8d6b1866395d257d37efb0594ee9ec669b4dc10ca51be862dbb05b0a3877b8fa97a8cf262ccea2186193b6c14b685435fe856eda857
6
+ metadata.gz: 2a7054d5bcb3d3898565c25c217afc445b5b02a4afb9886f2542507373e61e885a6b5ce23f6c2f5044afc91ba487fe94178c44979011f56a9415a2b301d9c02d
7
+ data.tar.gz: 43e5caa852f72420cd4dc8fb2a5322c48d9cdbbbd1ff7c0d5cecbb983d6d5fc71fd6b34523ef0671a48055f84392166caf0074336c7f7471f9f45339a4c62183
@@ -9,26 +9,56 @@ module Vx
9
9
  normalize_attributes(new_env)
10
10
  end
11
11
 
12
- def artifacts
12
+ def attributes
13
13
  @attributes
14
14
  end
15
15
 
16
+ def files
17
+ @files
18
+ end
19
+
20
+ def prefix
21
+ @options[:prefix]
22
+ end
23
+
16
24
  private
17
25
 
18
26
  def normalize_attributes(new_env)
19
-
20
- @attributes =
27
+ attrs =
21
28
  case new_env
22
29
  when Array
23
- new_env.map(&:to_s)
30
+ new_env
31
+ else
32
+ Array(new_env)
33
+ end
34
+
35
+ extract_options_and_normalize_items(attrs)
36
+ end
37
+
38
+ def extract_options_and_normalize_items(new_env)
39
+ opts = {}
40
+ @attributes = []
41
+ @files = []
42
+ env = new_env.inject([]) do |a, e|
43
+ if e.is_a?(Hash)
44
+ opts = e
45
+ @attributes.push e
24
46
  else
25
- Array(new_env).map(&:to_s)
47
+ a.push e.to_s.gsub(/^\.*(\/)/, '')
48
+ @attributes.push a.last
49
+ @files.push a.last
26
50
  end
51
+ a
52
+ end
27
53
 
28
- @attributes.map! do |attr|
29
- attr.gsub(/^\.*(\/)/, '')
54
+ if opts && opts["prefix"]
55
+ @options = { prefix: opts["prefix"] }
56
+ else
57
+ @options = {}
30
58
  end
31
59
 
60
+ [opts, env]
61
+
32
62
  end
33
63
 
34
64
  end
@@ -13,13 +13,15 @@ module Vx
13
13
 
14
14
  if enabled?(env)
15
15
  env.after_script << "echo"
16
- env.source.artifacts.attributes.map{|a| compile(a) }.each do |artifact|
16
+ env.source.artifacts.files.map{|a| compile(a) }.each do |artifact|
17
17
  find = FIND % artifact
18
- prefix = env.task.artifacts_url_prefix
18
+ url = env.task.artifacts_url_prefix
19
+ prefix = env.source.artifacts.prefix
20
+ name = prefix ? "#{prefix}$i" : "$i"
19
21
  cmd = %{
20
22
  for i in $(#{find}) ; do
21
- echo "upload artifact $i"
22
- curl -s -S -X PUT -T $i #{prefix}/$i > /dev/null
23
+ echo "upload artifact #{name}"
24
+ curl -s -S -X PUT -T $i #{url}/#{name} > /dev/null
23
25
  done
24
26
  }
25
27
  env.after_script << cmd
@@ -42,7 +44,7 @@ module Vx
42
44
  end
43
45
 
44
46
  def enabled?(env)
45
- !env.source.artifacts.attributes.empty? &&
47
+ !env.source.artifacts.files.empty? &&
46
48
  env.task.artifacts_url_prefix
47
49
  end
48
50
 
@@ -1,5 +1,5 @@
1
1
  module Vx
2
2
  module Builder
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -34,3 +34,4 @@ artifacts:
34
34
  - ../app/foo.txt
35
35
  - /app/*.txt
36
36
  - app/
37
+ - prefix: $CI_JOB_ID/
@@ -43,7 +43,7 @@ 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/"]
46
+ "artifacts" => ["app/foo.txt", "app/*.txt", "app/", {"prefix"=>"$CI_JOB_ID/"}]
47
47
  }
48
48
  ) }
49
49
  end
@@ -100,8 +100,13 @@ describe Vx::Builder::BuildConfiguration do
100
100
  context "artifacts" do
101
101
  subject { config.artifacts }
102
102
 
103
+ its(:prefix) { should eq "$CI_JOB_ID/" }
104
+ its(:files) { should eq ["app/foo.txt", "app/*.txt", "app/"] }
105
+
103
106
  context "when is empty" do
104
107
  let(:content) { {} }
108
+ its(:files) { should eq [] }
109
+ its(:prefix) { should be_nil }
105
110
  its(:attributes) { should eq [] }
106
111
  end
107
112
  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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Galinsky