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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a473168ffb22459fec1a66528f549bf62e40fc12
4
- data.tar.gz: 1cabcdd721e4ceaf4eea43d9562fdd83eb077552
3
+ metadata.gz: 5365dc62f83f81f017c85c69e6d8b60f6a97e581
4
+ data.tar.gz: 6ea1a86e7ac4934c927554d0f64af48d6ba9a510
5
5
  SHA512:
6
- metadata.gz: e54453818d8eac55c4a22ddc147a81cab71414eca7799624f3b94fc61a9b80d95e9f958c5e3d8c1673c61b31172dcc0dbd9caeeaa37d83fc891e75464bd46e6b
7
- data.tar.gz: ff46cf37d4cae95e0c4cd18709c2f7c7230d36425a4f2e291459d76d6127d1232a25402f2e6b800a0da7a3e8783d7a1f27d57a096e03b47a4129629f63619bd6
6
+ metadata.gz: 7601ee6c67d4494c5ed3482b5dc7b0bf2e056c056c1593b49f59777ddb2bb96ee2231bedc7deb4702b14e99449747eca1a128288d97812dc3507b376b424b672
7
+ data.tar.gz: f6e5c3c29a625675bbd39204d73a1c658d012ca32fb7e88f7f9607a4aa79d93e725927747a240a25274a8e59356dd9b2488e89e82ec326bc2f8acedce80a946a
@@ -1 +1,3 @@
1
- ��È�Q��;;\��+|�������K��GUc��j�a.����Ўy}$�3��H`r�'����`� ���m^�⁑�#��v ���n=��lEw�t@�~����oV���jq���a�z�e����'4Yv�G�S�潄�s�F�������^��"hoSENYZ�1���ʖ��2�̘�Qi�{��n30�A�C}:<��$-����<����U�^<�=��Sֳ��l�Vj�2㖈�W�&�2���LY�c�O
1
+ YM4P"����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
@@ -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
- end
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
- singlify lines, /^\s*FROM /
77
- lines.grep(/^\s*CMD /)[0..-2].each {|x| lines.delete x}
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
- def singlify(lines, regex)
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.3.1
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-12 00:00:00.000000000 Z
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