puppet-lint 5.0.0 → 5.1.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
- data/lib/puppet-lint/checkplugin.rb +3 -1
- data/lib/puppet-lint/data.rb +3 -26
- data/lib/puppet-lint/version.rb +1 -1
- data/spec/unit/puppet-lint/checkplugin_spec.rb +36 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 200023e7df4e5c5ad823fba0f940ee2ad73ae5d05eb04796e83dbcc118e2a47e
|
4
|
+
data.tar.gz: 3a14e87f1f69fdc2495068d246609af04c81e6610e4e878a669ab9b8262f1265
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bad4d387c8695aa0bc3fca805a819c5af1e0c410953f61093ec77a1139848c1b284a53aa238bed450ba5195d9af8736a2ba6a9dfec97ceca09bdaca08da80bf
|
7
|
+
data.tar.gz: 4d26e6093580630b0b838562efdc2d2e9492d8185652a469aaca3fdb48cec0f88b9d02367cacc595b46d10d08745d4b76874d304a891e1e265c35ffb01625752
|
@@ -55,7 +55,9 @@ class PuppetLint::CheckPlugin
|
|
55
55
|
#
|
56
56
|
# Returns an Array of PuppetLint::Lexer::Token objects.
|
57
57
|
def tokens
|
58
|
-
|
58
|
+
# When called from a plugins `check` method, the tokens array returned should be a (shallow) copy
|
59
|
+
called_from_check = (caller_locations(1..1).first.base_label == 'check')
|
60
|
+
PuppetLint::Data.tokens(duplicate: called_from_check)
|
59
61
|
end
|
60
62
|
|
61
63
|
def add_token(index, token)
|
data/lib/puppet-lint/data.rb
CHANGED
@@ -38,37 +38,14 @@ class PuppetLint::Data
|
|
38
38
|
@defaults_indexes = nil
|
39
39
|
end
|
40
40
|
|
41
|
-
# @api private
|
42
|
-
def ruby1?
|
43
|
-
@ruby1 = RbConfig::CONFIG['MAJOR'] == '1' if @ruby1.nil?
|
44
|
-
@ruby1
|
45
|
-
end
|
46
|
-
|
47
41
|
# Get the tokenised manifest.
|
48
42
|
#
|
43
|
+
# @param duplicate [Boolean] if true, returns a duplicate of the token array.
|
49
44
|
# @return [Array[PuppetLint::Lexer::Token]]
|
50
45
|
#
|
51
46
|
# @api public
|
52
|
-
def tokens
|
53
|
-
|
54
|
-
begin
|
55
|
-
caller[0][%r{`.*'}][1..-2] # rubocop:disable Performance/Caller
|
56
|
-
rescue NoMethodError
|
57
|
-
caller[1][%r{`.*'}][1..-2] # rubocop:disable Performance/Caller
|
58
|
-
end
|
59
|
-
else
|
60
|
-
begin
|
61
|
-
caller(0..0).first[%r{`.*'}][1..-2]
|
62
|
-
rescue NoMethodError
|
63
|
-
caller(1..1).first[%r{`.*'}][1..-2]
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
if calling_method == 'check'
|
68
|
-
@tokens.dup
|
69
|
-
else
|
70
|
-
@tokens
|
71
|
-
end
|
47
|
+
def tokens(duplicate: false)
|
48
|
+
duplicate ? @tokens.dup : @tokens
|
72
49
|
end
|
73
50
|
|
74
51
|
# Add new token.
|
data/lib/puppet-lint/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class DummyCheckPlugin < PuppetLint::CheckPlugin
|
4
|
+
def check
|
5
|
+
# Since we're calling `tokens` from a `check` method, we should get our own Array object.
|
6
|
+
# If we add an extra token to it, PuppetLint::Data.tokens should remain unchanged.
|
7
|
+
tokens << :extra_token
|
8
|
+
end
|
9
|
+
|
10
|
+
def fix
|
11
|
+
tokens << :fix_token
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe PuppetLint::CheckPlugin do
|
16
|
+
before(:each) do
|
17
|
+
PuppetLint::Data.tokens = [:token1, :token2, :token3]
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'returns a duplicate of the token array when called from check' do
|
21
|
+
plugin = DummyCheckPlugin.new
|
22
|
+
|
23
|
+
plugin.check
|
24
|
+
|
25
|
+
# Verify that the global token array remains unchanged.
|
26
|
+
expect(PuppetLint::Data.tokens).to eq([:token1, :token2, :token3])
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'other methods can modify the tokens array' do
|
30
|
+
plugin = DummyCheckPlugin.new
|
31
|
+
|
32
|
+
plugin.fix
|
33
|
+
|
34
|
+
expect(PuppetLint::Data.tokens).to eq([:token1, :token2, :token3, :fix_token])
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Sharpe
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2025-09-
|
13
|
+
date: 2025-09-25 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description: " Checks your Puppet manifests against the Puppetlabs style guide
|
16
16
|
and alerts you to any discrepancies.\n"
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- spec/spec_helper_acceptance.rb
|
106
106
|
- spec/spec_helper_acceptance_local.rb
|
107
107
|
- spec/unit/puppet-lint/bin_spec.rb
|
108
|
+
- spec/unit/puppet-lint/checkplugin_spec.rb
|
108
109
|
- spec/unit/puppet-lint/checks_spec.rb
|
109
110
|
- spec/unit/puppet-lint/configuration_spec.rb
|
110
111
|
- spec/unit/puppet-lint/data_spec.rb
|