dockerfilemerge 0.3.1 → 0.4.0
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 +4 -4
- checksums.yaml.gz.sig +3 -1
- data.tar.gz.sig +0 -0
- data/lib/dockerfilemerge.rb +41 -4
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5365dc62f83f81f017c85c69e6d8b60f6a97e581
|
4
|
+
data.tar.gz: 6ea1a86e7ac4934c927554d0f64af48d6ba9a510
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7601ee6c67d4494c5ed3482b5dc7b0bf2e056c056c1593b49f59777ddb2bb96ee2231bedc7deb4702b14e99449747eca1a128288d97812dc3507b376b424b672
|
7
|
+
data.tar.gz: f6e5c3c29a625675bbd39204d73a1c658d012ca32fb7e88f7f9607a4aa79d93e725927747a240a25274a8e59356dd9b2488e89e82ec326bc2f8acedce80a946a
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,3 @@
|
|
1
|
-
|
1
|
+
YM4�P"����qk
|
2
|
+
'<3T=�I�4�r|�D!<�e�
|
3
|
+
/�����d��A6NU���a �����c麽7%@H.⸭B^�m�"���Nt�&E.6k4�)[ǟB�������$czI��?՛6�cRӳ����,W�vxv���T�9�Y����[��&��Q���B��7p2��U���>��{�R�;�B$:���SN�E�4� _ȗ� �md�6JMa��V�b1eQ�-3�\�� �
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dockerfilemerge.rb
CHANGED
@@ -19,6 +19,7 @@ class DockerfileMerge
|
|
19
19
|
[:include, /(?<path>.*)/, :dockerfile],
|
20
20
|
[:root, /MAINTAINER (?<name>.*)/, :maintainer],
|
21
21
|
[:root, /RUN (?<command>.*)/, :run],
|
22
|
+
[:root, /-\/[^\/]+\/(?:\[[^\]]+\])?/, :del],
|
22
23
|
[:all, /#/, :comment]
|
23
24
|
]
|
24
25
|
|
@@ -69,18 +70,42 @@ class DockerfileMerge
|
|
69
70
|
lines.insert(i+1, line)
|
70
71
|
lines.insert(i+2, ' ' + r[1..-1].join("\n ").rstrip) if r.length > 1
|
71
72
|
|
72
|
-
|
73
|
+
when :del
|
74
|
+
|
75
|
+
exp, filter = line.match(/-\/([^\/]+)\/(\[[^\]]+\])?/).captures
|
76
|
+
|
77
|
+
name = if filter then
|
78
|
+
|
79
|
+
case filter[1..-2]
|
80
|
+
when'0..-2'
|
81
|
+
:singlify_last
|
82
|
+
when '1..-1'
|
83
|
+
:singlify_first
|
84
|
+
else
|
85
|
+
puts 'unrecognised selector'
|
86
|
+
end
|
87
|
+
else
|
88
|
+
:delete_all
|
89
|
+
end
|
90
|
+
|
91
|
+
method(name).call(lines, exp) if name.is_a? Symbol
|
92
|
+
|
93
|
+
end
|
73
94
|
|
74
95
|
end
|
75
96
|
|
76
|
-
|
77
|
-
lines
|
97
|
+
singlify_first lines, /^\s*FROM /
|
98
|
+
singlify_last lines, /^\s*CMD /
|
78
99
|
|
79
100
|
@to_s = lines.join("\n")
|
80
101
|
end
|
81
102
|
|
82
103
|
private
|
83
104
|
|
105
|
+
def delete_all(lines, regex)
|
106
|
+
lines.reject! {|x| x[regex]}
|
107
|
+
end
|
108
|
+
|
84
109
|
def merge_file(lines, path)
|
85
110
|
|
86
111
|
raw_buffer, type = RXFHelper.read(path)
|
@@ -94,8 +119,20 @@ class DockerfileMerge
|
|
94
119
|
lines.concat rows
|
95
120
|
end
|
96
121
|
|
97
|
-
|
122
|
+
# removes any matching lines after the 1st matching line
|
123
|
+
#
|
124
|
+
def singlify_first(lines, raw_regex)
|
125
|
+
|
126
|
+
regex = raw_regex.is_a?(Regexp) ? raw_regex : Regexp.new(raw_regex)
|
98
127
|
i = 0
|
99
128
|
lines.reject! {|x| found = x[regex]; i += 1 if found; i > 1 and found }
|
100
129
|
end
|
130
|
+
|
131
|
+
# removes any matching lines before the last matching line
|
132
|
+
#
|
133
|
+
def singlify_last(lines, raw_regex)
|
134
|
+
|
135
|
+
regex = raw_regex.is_a?(Regexp) ? raw_regex : Regexp.new(raw_regex)
|
136
|
+
lines.grep(regex)[0..-2].each {|x| lines.delete x}
|
137
|
+
end
|
101
138
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockerfilemerge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
WHpJ21HYl4KWG8TISerrdwpQAZ5dhV2Yy/4q0MWSnDcMRSYdRAixOcdYW+U+R8cz
|
32
32
|
pf2JrQZNdYZXIg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-07-
|
34
|
+
date: 2015-07-26 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: lineparser
|
metadata.gz.sig
CHANGED
Binary file
|