egg 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/egg/dockerfile/base.rb +30 -7
- data/lib/egg/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6537dd12342b2469b062c681875a6048849584d0
|
4
|
+
data.tar.gz: 7cdb22c0856264963f77894ac850101f3d687dbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 193ec0da7471c0dcadc163a3649ceb841037f0f3d757f73b48b3cae65d16f1cffbb37850a8b9f59d7016b94e118f28de97f8ea977e1da6c25d9e18e0d0ee90a1
|
7
|
+
data.tar.gz: b54dbf63a476199020b8f33e27a41df25ef3a8dfeb849e42a12779a284a28f82c5d3702cdb677e6e241853c0bf4478529b184f6898c767f15dacbb36d704a5ef
|
data/Gemfile.lock
CHANGED
data/lib/egg/dockerfile/base.rb
CHANGED
@@ -2,6 +2,13 @@ module Egg
|
|
2
2
|
module Dockerfile
|
3
3
|
# Provides shared behavior for dockerfile template classes.
|
4
4
|
class Base
|
5
|
+
# Raise when before and after are both used at the same time.
|
6
|
+
class QuantumStateError < RuntimeError
|
7
|
+
def message
|
8
|
+
"Directives cannot happen both before and after a given directive"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
5
12
|
attr_reader :template
|
6
13
|
attr_accessor :command
|
7
14
|
|
@@ -23,22 +30,38 @@ module Egg
|
|
23
30
|
ERB.new(unrendered_output).result(binding)
|
24
31
|
end
|
25
32
|
|
26
|
-
def run(command, before: [:cmd])
|
27
|
-
|
33
|
+
def run(command, before: [:cmd], after: nil)
|
34
|
+
insert_with_before_after([:run, command], before: before, after: after)
|
28
35
|
end
|
29
36
|
|
30
|
-
def env(env_hash)
|
37
|
+
def env(env_hash, **before_after)
|
31
38
|
env_string = env_hash.reduce("") do |out, (key, value)|
|
32
39
|
out << key.to_s.upcase << '="' << value.to_s << '" '
|
33
40
|
end
|
34
|
-
|
41
|
+
insert_with_before_after([:env, env_string], before_after)
|
42
|
+
end
|
43
|
+
|
44
|
+
def add(localpath, containerpath, **before_after)
|
45
|
+
directive = [:add, localpath + " " + containerpath]
|
46
|
+
insert_with_before_after(directive, before_after)
|
35
47
|
end
|
36
48
|
|
37
49
|
private
|
38
50
|
|
39
|
-
def
|
40
|
-
|
41
|
-
|
51
|
+
def insert_with_before_after(directive, before: nil, after: nil)
|
52
|
+
raise(QuantumStateError) if before && after
|
53
|
+
if before
|
54
|
+
template.insert(find_directive_in_template(before), directive)
|
55
|
+
elsif after
|
56
|
+
template.insert(find_directive_in_template(after) + 1, directive)
|
57
|
+
else
|
58
|
+
template << directive
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def find_directive_in_template(directive)
|
63
|
+
template.index(directive) ||
|
64
|
+
template.index { |tc| tc[0] == directive[0] } ||
|
42
65
|
-1
|
43
66
|
end
|
44
67
|
|
data/lib/egg/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carl Thuringer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-09-
|
12
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|