dockerfilemerge 0.1.0 → 0.2.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 +0 -0
- data.tar.gz.sig +0 -0
- data/lib/dockerfilemerge.rb +36 -35
- metadata +3 -3
- 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: 6a99f814ecfdd55129c8b94c428f248151a66bc1
|
4
|
+
data.tar.gz: 1e528f38b25380403559dddc2d4e5cbcc8179aad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44ac5460fe56b56a8b3eb87b2e9e790bcfc703763ff14cf619031f2fdb4925c875e60549107702cb8e200121478768dada5381e8296f1f8a0301f18c3d2ab256
|
7
|
+
data.tar.gz: 29b0d1dc7d5da86a58c3a6807e64779d54dfe0c446e234b18b3283e6213d20362b88c5a85881d84c5bce1ff2822b4bba9cb7b5f34849a5d9d5d551b7f5dabb50
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dockerfilemerge.rb
CHANGED
@@ -19,63 +19,64 @@ class DockerfileMerge
|
|
19
19
|
[:all, /#/, :comment]
|
20
20
|
]
|
21
21
|
|
22
|
-
|
23
|
-
a = lp.parse s
|
22
|
+
a = LineParser.new(patterns, ignore_blank_lines: false).parse s
|
24
23
|
|
25
24
|
lines = []
|
26
25
|
|
27
|
-
a.each do |
|
26
|
+
a.each do |label, h, r, c| # h=hash, r=remaining, c=children
|
28
27
|
|
29
|
-
case
|
28
|
+
case label
|
30
29
|
when :comment
|
31
|
-
|
32
|
-
lines <<
|
30
|
+
|
31
|
+
lines << r.first
|
32
|
+
lines << '' if r.length > 1
|
33
33
|
|
34
34
|
when :include
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
buffer, type = RXFHelper.read(path)
|
41
|
-
rows = buffer.lines.map(&:chomp)
|
42
|
-
lines << "\n\n# copied from " + path if type == :url
|
43
|
-
rows.grep(/^# Pull /).each {|x| rows.delete x}
|
44
|
-
lines.concat rows
|
45
|
-
|
46
|
-
else
|
47
|
-
|
48
|
-
x[3].each do |source|
|
49
|
-
path = source[1][:path]
|
50
|
-
buffer, type = RXFHelper.read(path)
|
51
|
-
rows = buffer.lines.map(&:chomp)
|
52
|
-
lines << "\n\n# copied from " + path if type == :url
|
53
|
-
rows.grep(/^# Pull /).each {|x| rows.delete x}
|
54
|
-
lines.concat rows
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
lines << '' if x[2].length > 1
|
36
|
+
h[:path].length > 0 ? merge_file(lines, h[:path]) :
|
37
|
+
c.each {|source| merge_file lines, source[1][:path] }
|
38
|
+
lines << '' if r.length > 1
|
60
39
|
|
61
40
|
when :maintainer
|
62
41
|
|
63
42
|
maintainers = lines.grep(/MAINTAINER/)
|
64
43
|
i = lines.index maintainers.shift
|
65
|
-
lines[i] =
|
44
|
+
lines[i] = r.first
|
45
|
+
|
66
46
|
maintainers.each {|x| lines.delete x}
|
67
47
|
|
68
48
|
when :run
|
49
|
+
|
69
50
|
i = lines.index lines.grep(/RUN/).last
|
70
|
-
lines.insert(i+1,
|
71
|
-
|
51
|
+
lines.insert(i+1, r.first)
|
52
|
+
|
53
|
+
if r.length > 1 then
|
54
|
+
lines.insert(i+2, ' ' + r[1..-1].join("\n ").rstrip)
|
55
|
+
end
|
72
56
|
end
|
73
57
|
|
74
58
|
end
|
75
59
|
|
76
|
-
lines
|
77
|
-
lines
|
60
|
+
singlify lines, /^FROM /
|
61
|
+
singlify lines, /^CMD /
|
78
62
|
|
79
63
|
@to_s = lines.join("\n")
|
80
64
|
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def merge_file(lines, path)
|
69
|
+
|
70
|
+
buffer, type = RXFHelper.read(path)
|
71
|
+
rows = buffer.lines.map(&:chomp)
|
72
|
+
lines << "\n\n# copied from " + path if type == :url
|
73
|
+
rows.grep(/^# Pull /).each {|x| rows.delete x}
|
74
|
+
|
75
|
+
lines.concat rows
|
76
|
+
end
|
77
|
+
|
78
|
+
def singlify(lines, regex)
|
79
|
+
i = 0
|
80
|
+
lines.reject! {|x| found = x[regex]; i += 1 if found; i > 1 and found }
|
81
|
+
end
|
81
82
|
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.2.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-10 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: lineparser
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.4.
|
103
|
+
rubygems_version: 2.4.8
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Merge 2 or more Dockerfiles into 1 Dockerfile
|
metadata.gz.sig
CHANGED
Binary file
|