puppet-lint-fileserver-check 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 722b51fc3ed0c18a55430a47c7fde2e6fa629517
4
- data.tar.gz: c40f988cb66cda5c83c829b2ccb175abf30c0954
3
+ metadata.gz: 645b0edd4d64a696a598dd3253adb1d8cc160f31
4
+ data.tar.gz: bb3a09d4048b9fae10d55c5da7e7072176e14490
5
5
  SHA512:
6
- metadata.gz: 62e4400749b9f814c77242c525fdc92a5c2be7179dffdfd73583193582dc320d04b74f2a50bacb3d368c6c4a05e8c5011ae64b2183287df117e670f77992956b
7
- data.tar.gz: ff5e9562e3e317b255ee8c8541f0cfed458baeb16f1cc0d75ec7ed99e9d978a33b58357d210bd2f543eaa8e31b599c9b51699e94490b7ac23720d2ec93ffea71
6
+ metadata.gz: 8f6063629cb0b4964bbee81779f501381a462c82eb17c08083a0f86bd264a33e982297f8938f637645c11aa6d5edf058f290787e81a9e984adb0c6a95d5cb9b5
7
+ data.tar.gz: c8467b9f3a604dafe999277c88fb4655577c6576b315e3e4d76269165f38c6ca03acf54481840be0338738b8c71cc43c626e956d260db908e6bbd53999ba6471
@@ -20,6 +20,28 @@ PuppetLint.new_check(:fileserver) do
20
20
  problem[:token].prev_code_token.prev_code_token.value = 'content'
21
21
  problem[:token].value.sub!(%r{^puppet:///modules/(.*)}, "file('\\1')")
22
22
  problem[:token].type = :NAME
23
+ elsif problem[:token].type == :DQPRE
24
+ problem[:token].prev_code_token.prev_code_token.value = 'content'
25
+ file = PuppetLint::Lexer::Token.new(
26
+ :NAME, 'file',
27
+ problem[:token].line, problem[:token].column+1
28
+ )
29
+ lparen = PuppetLint::Lexer::Token.new(
30
+ :LPAREN, '(',
31
+ problem[:token].line, problem[:token].column+1
32
+ )
33
+ rparen = PuppetLint::Lexer::Token.new(
34
+ :RPAREN, ')',
35
+ problem[:token].line, problem[:token].column+1
36
+ )
37
+ tokens.insert(tokens.index(problem[:token]), file)
38
+ tokens.insert(tokens.index(problem[:token]), lparen)
39
+ problem[:token].value.sub!(%r{^puppet:///modules/}, '')
40
+ t = problem[:token].next_code_token
41
+ while t.type != :DQPOST
42
+ t = t.next_code_token
43
+ end
44
+ tokens.insert(tokens.index(t)+1, rparen)
23
45
  else
24
46
  raise PuppetLint::NoFix, "Not fixing"
25
47
  end
@@ -182,12 +182,79 @@ describe 'fileserver' do
182
182
  expect(problems).to have(1).problem
183
183
  end
184
184
 
185
- it 'should create a warning' do
186
- expect(problems).to contain_warning(msg).on_line(3).in_column(21)
185
+ it 'should fix the problem' do
186
+ expect(problems).to contain_fixed(msg).on_line(3).in_column(21)
187
187
  end
188
188
 
189
- it 'should not modify the manifest' do
190
- expect(manifest).to eq(code)
189
+ it 'should add a newline to the end of the manifest' do
190
+ expect(manifest).to eq(
191
+ <<-EOS
192
+ file { 'foo':
193
+ ensure => file,
194
+ content => file("${module_name}/bar"),
195
+ }
196
+ EOS
197
+ )
198
+ end
199
+ end
200
+
201
+ context 'code using a variable' do
202
+ let(:code) {
203
+ <<-EOS
204
+ file { 'foo':
205
+ ensure => file,
206
+ source => "puppet:///modules/foo/${bar}",
207
+ }
208
+ EOS
209
+ }
210
+
211
+ it 'should detect a single problem' do
212
+ expect(problems).to have(1).problem
213
+ end
214
+
215
+ it 'should fix the problem' do
216
+ expect(problems).to contain_fixed(msg).on_line(3).in_column(21)
217
+ end
218
+
219
+ it 'should add a newline to the end of the manifest' do
220
+ expect(manifest).to eq(
221
+ <<-EOS
222
+ file { 'foo':
223
+ ensure => file,
224
+ content => file("foo/${bar}"),
225
+ }
226
+ EOS
227
+ )
228
+ end
229
+ end
230
+
231
+ context 'code using two variables' do
232
+ let(:code) {
233
+ <<-EOS
234
+ file { 'foo':
235
+ ensure => file,
236
+ source => "puppet:///modules/${module_name}/${bar}",
237
+ }
238
+ EOS
239
+ }
240
+
241
+ it 'should detect a single problem' do
242
+ expect(problems).to have(1).problem
243
+ end
244
+
245
+ it 'should fix the problem' do
246
+ expect(problems).to contain_fixed(msg).on_line(3).in_column(21)
247
+ end
248
+
249
+ it 'should add a newline to the end of the manifest' do
250
+ expect(manifest).to eq(
251
+ <<-EOS
252
+ file { 'foo':
253
+ ensure => file,
254
+ content => file("${module_name}/${bar}"),
255
+ }
256
+ EOS
257
+ )
191
258
  end
192
259
  end
193
260
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-fileserver-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mickaël Canévet