puppet-check 1.0.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 +7 -0
- data/.rubocop.yml +11 -0
- data/.travis.yml +21 -0
- data/CHANGELOG.md +14 -0
- data/Dockerfile +22 -0
- data/Gemfile +5 -0
- data/LICENSE.md +20 -0
- data/README.md +148 -0
- data/Rakefile +24 -0
- data/Vagrantfile +77 -0
- data/bin/puppet-check +5 -0
- data/config.reek +3 -0
- data/images/puppetcheck_new.png +0 -0
- data/images/puppetcheck_old.odp +0 -0
- data/images/puppetcheck_old.png +0 -0
- data/lib/puppet-check.rb +86 -0
- data/lib/puppet-check/cli.rb +33 -0
- data/lib/puppet-check/data_parser.rb +95 -0
- data/lib/puppet-check/puppet_parser.rb +77 -0
- data/lib/puppet-check/ruby_parser.rb +93 -0
- data/lib/puppet-check/tasks.rb +15 -0
- data/lib/puppet-check/utils.rb +22 -0
- data/puppet-check.gemspec +25 -0
- data/spec/fixtures/foobarbaz +1 -0
- data/spec/fixtures/hieradata/good.json +7 -0
- data/spec/fixtures/hieradata/good.yaml +7 -0
- data/spec/fixtures/hieradata/style.yaml +15 -0
- data/spec/fixtures/hieradata/syntax.json +8 -0
- data/spec/fixtures/hieradata/syntax.yaml +8 -0
- data/spec/fixtures/lib/good.rb +1 -0
- data/spec/fixtures/lib/rubocop_style.rb +3 -0
- data/spec/fixtures/lib/style.rb +12 -0
- data/spec/fixtures/lib/syntax.rb +1 -0
- data/spec/fixtures/librarian_good/Puppetfile +5 -0
- data/spec/fixtures/librarian_style/Puppetfile +5 -0
- data/spec/fixtures/librarian_syntax/Puppetfile +7 -0
- data/spec/fixtures/manifests/good.pp +1 -0
- data/spec/fixtures/manifests/style_lint.pp +4 -0
- data/spec/fixtures/manifests/style_parser.pp +2 -0
- data/spec/fixtures/manifests/syntax.pp +1 -0
- data/spec/fixtures/metadata_good/metadata.json +35 -0
- data/spec/fixtures/metadata_style/metadata.json +35 -0
- data/spec/fixtures/metadata_syntax/metadata.json +15 -0
- data/spec/fixtures/templates/good.epp +3 -0
- data/spec/fixtures/templates/good.erb +1 -0
- data/spec/fixtures/templates/no_method_error.erb +3 -0
- data/spec/fixtures/templates/style.erb +3 -0
- data/spec/fixtures/templates/syntax.epp +3 -0
- data/spec/fixtures/templates/syntax.erb +1 -0
- data/spec/integration/integration_spec.rb +41 -0
- data/spec/puppet-check/cli_spec.rb +48 -0
- data/spec/puppet-check/data_parser_spec.rb +64 -0
- data/spec/puppet-check/puppet_parser_spec.rb +67 -0
- data/spec/puppet-check/ruby_parser_spec.rb +111 -0
- data/spec/puppet-check/utils_spec.rb +20 -0
- data/spec/puppet-check_spec.rb +82 -0
- data/spec/spec_helper.rb +13 -0
- metadata +233 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require_relative '../../lib/puppet-check/utils'
|
3
|
+
|
4
|
+
describe Utils do
|
5
|
+
context '.capture_stdout' do
|
6
|
+
let(:stdout_test) { Utils.capture_stdout { puts 'hello world' } }
|
7
|
+
|
8
|
+
it 'captures the stdout from a block of code' do
|
9
|
+
expect(stdout_test.chomp).to eql('hello world')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
context '.capture_stderr' do
|
14
|
+
let(:stderr_test) { Utils.capture_stderr { warn 'hello world' } }
|
15
|
+
|
16
|
+
it 'captures the stderr from a block of code' do
|
17
|
+
expect(stderr_test.chomp).to eql('hello world')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
require_relative '../lib/puppet-check'
|
3
|
+
|
4
|
+
describe PuppetCheck do
|
5
|
+
let(:puppetcheck) { PuppetCheck.new }
|
6
|
+
|
7
|
+
context 'initializes and' do
|
8
|
+
it 'future parser can be altered' do
|
9
|
+
PuppetCheck.future_parser = true
|
10
|
+
expect(PuppetCheck.future_parser).to eql(true)
|
11
|
+
end
|
12
|
+
it 'style check can be altered' do
|
13
|
+
PuppetCheck.style_check = true
|
14
|
+
expect(PuppetCheck.style_check).to eql(true)
|
15
|
+
end
|
16
|
+
it 'puppet lint arguments can be altered' do
|
17
|
+
PuppetCheck.puppetlint_args = ['--puppetlint-arg-one', '--puppetlint-arg-two']
|
18
|
+
expect(PuppetCheck.puppetlint_args).to eql(['--puppetlint-arg-one', '--puppetlint-arg-two'])
|
19
|
+
end
|
20
|
+
it 'rubocop arguments can be altered' do
|
21
|
+
PuppetCheck.rubocop_args = ['--rubocop-arg-one', '--rubocop-arg-two']
|
22
|
+
expect(PuppetCheck.rubocop_args).to eql(['--rubocop-arg-one', '--rubocop-arg-two'])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context '.parse_paths' do
|
27
|
+
let(:no_files) { puppetcheck.parse_paths(%w(foo bar baz)) }
|
28
|
+
let(:file) { puppetcheck.parse_paths([fixtures_dir + 'lib/good.rb']) }
|
29
|
+
let(:dir) { puppetcheck.parse_paths([fixtures_dir]) }
|
30
|
+
let(:multi_dir) { puppetcheck.parse_paths([fixtures_dir + 'hieradata', fixtures_dir + 'lib', fixtures_dir + 'manifests']) }
|
31
|
+
let(:repeats) { puppetcheck.parse_paths([fixtures_dir + 'hieradata', fixtures_dir + 'hieradata', fixtures_dir + 'lib', fixtures_dir + 'hieradata/good.json', fixtures_dir + 'manifests/good.pp', fixtures_dir + 'manifests/good.pp']) }
|
32
|
+
|
33
|
+
it 'raises an error if no files were found' do
|
34
|
+
expect { no_files }.to raise_error(RuntimeError, 'No files found in supplied paths foo, bar, baz.')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'correctly parses one file and returns it' do
|
38
|
+
expect(file[0]).to match(%r{spec/fixtures/lib/good.rb})
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'correctly parses one directory and returns all of its files' do
|
42
|
+
dir.each { |file| expect(File.file?(file)).to be true }
|
43
|
+
expect(dir.length).to eql(26)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'correctly parses multiple directories and returns all of their files' do
|
47
|
+
multi_dir.each { |file| expect(File.file?(file)).to be true }
|
48
|
+
expect(multi_dir.length).to eql(13)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'correctly parses three directories (one repeated) and three files (one repeated from directories and another repeated from files) and returns the unique files' do
|
52
|
+
repeats.each { |file| expect(File.file?(file)).to be true }
|
53
|
+
expect(repeats.length).to eql(10)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context '.output_results' do
|
58
|
+
before(:each) do
|
59
|
+
PuppetCheck.error_files = []
|
60
|
+
PuppetCheck.warning_files = []
|
61
|
+
PuppetCheck.clean_files = []
|
62
|
+
PuppetCheck.ignored_files = []
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'outputs files with errors' do
|
66
|
+
PuppetCheck.error_files = ['-- foo: i had an error']
|
67
|
+
expect { PuppetCheck.output_results }.to output("\033[31mThe following files have errors:\033[0m\n-- foo: i had an error\n").to_stdout
|
68
|
+
end
|
69
|
+
it 'outputs files with warnings' do
|
70
|
+
PuppetCheck.warning_files = ['-- foo: i had a warning']
|
71
|
+
expect { PuppetCheck.output_results }.to output("\n\033[33mThe following files have warnings:\033[0m\n-- foo: i had a warning\n").to_stdout
|
72
|
+
end
|
73
|
+
it 'outputs files with no errors or warnings' do
|
74
|
+
PuppetCheck.clean_files = ['-- foo: i was totally good to go']
|
75
|
+
expect { PuppetCheck.output_results }.to output("\n\033[32mThe following files have no errors or warnings:\033[0m\n-- foo: i was totally good to go\n").to_stdout
|
76
|
+
end
|
77
|
+
it 'outputs files that were not processed' do
|
78
|
+
PuppetCheck.ignored_files = ['-- foo: who knows what i am']
|
79
|
+
expect { PuppetCheck.output_results }.to output("\n\033[34mThe following files have unrecognized formats and therefore were not processed:\033[0m\n-- foo: who knows what i am\n").to_stdout
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,233 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puppet-check
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Schuchard
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: puppet
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '9'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '13'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '9'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '13'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rubocop
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :runtime
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: puppet-lint
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '1.1'
|
74
|
+
type: :runtime
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - "~>"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '1.1'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: spdx-licenses
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1.0'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '1.0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rspec
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '3.0'
|
109
|
+
description: Puppet Check is a gem that provides a comprehensive, streamlined, and
|
110
|
+
efficient analysis of the syntax, style, and validity of your entire Puppet code
|
111
|
+
and data.
|
112
|
+
email:
|
113
|
+
executables:
|
114
|
+
- puppet-check
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".rubocop.yml"
|
119
|
+
- ".travis.yml"
|
120
|
+
- CHANGELOG.md
|
121
|
+
- Dockerfile
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.md
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- Vagrantfile
|
127
|
+
- bin/puppet-check
|
128
|
+
- config.reek
|
129
|
+
- images/puppetcheck_new.png
|
130
|
+
- images/puppetcheck_old.odp
|
131
|
+
- images/puppetcheck_old.png
|
132
|
+
- lib/puppet-check.rb
|
133
|
+
- lib/puppet-check/cli.rb
|
134
|
+
- lib/puppet-check/data_parser.rb
|
135
|
+
- lib/puppet-check/puppet_parser.rb
|
136
|
+
- lib/puppet-check/ruby_parser.rb
|
137
|
+
- lib/puppet-check/tasks.rb
|
138
|
+
- lib/puppet-check/utils.rb
|
139
|
+
- puppet-check.gemspec
|
140
|
+
- spec/fixtures/foobarbaz
|
141
|
+
- spec/fixtures/hieradata/good.json
|
142
|
+
- spec/fixtures/hieradata/good.yaml
|
143
|
+
- spec/fixtures/hieradata/style.yaml
|
144
|
+
- spec/fixtures/hieradata/syntax.json
|
145
|
+
- spec/fixtures/hieradata/syntax.yaml
|
146
|
+
- spec/fixtures/lib/good.rb
|
147
|
+
- spec/fixtures/lib/rubocop_style.rb
|
148
|
+
- spec/fixtures/lib/style.rb
|
149
|
+
- spec/fixtures/lib/syntax.rb
|
150
|
+
- spec/fixtures/librarian_good/Puppetfile
|
151
|
+
- spec/fixtures/librarian_style/Puppetfile
|
152
|
+
- spec/fixtures/librarian_syntax/Puppetfile
|
153
|
+
- spec/fixtures/manifests/good.pp
|
154
|
+
- spec/fixtures/manifests/style_lint.pp
|
155
|
+
- spec/fixtures/manifests/style_parser.pp
|
156
|
+
- spec/fixtures/manifests/syntax.pp
|
157
|
+
- spec/fixtures/metadata_good/metadata.json
|
158
|
+
- spec/fixtures/metadata_style/metadata.json
|
159
|
+
- spec/fixtures/metadata_syntax/metadata.json
|
160
|
+
- spec/fixtures/templates/good.epp
|
161
|
+
- spec/fixtures/templates/good.erb
|
162
|
+
- spec/fixtures/templates/no_method_error.erb
|
163
|
+
- spec/fixtures/templates/style.erb
|
164
|
+
- spec/fixtures/templates/syntax.epp
|
165
|
+
- spec/fixtures/templates/syntax.erb
|
166
|
+
- spec/integration/integration_spec.rb
|
167
|
+
- spec/puppet-check/cli_spec.rb
|
168
|
+
- spec/puppet-check/data_parser_spec.rb
|
169
|
+
- spec/puppet-check/puppet_parser_spec.rb
|
170
|
+
- spec/puppet-check/ruby_parser_spec.rb
|
171
|
+
- spec/puppet-check/utils_spec.rb
|
172
|
+
- spec/puppet-check_spec.rb
|
173
|
+
- spec/spec_helper.rb
|
174
|
+
homepage: https://www.github.com/mschuchard/puppet-check
|
175
|
+
licenses:
|
176
|
+
- MIT
|
177
|
+
metadata: {}
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: 1.9.3
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
requirements: []
|
193
|
+
rubyforge_project:
|
194
|
+
rubygems_version: 2.2.2
|
195
|
+
signing_key:
|
196
|
+
specification_version: 4
|
197
|
+
summary: A streamlined comprehensive set of checks for your entire Puppet code and
|
198
|
+
data
|
199
|
+
test_files:
|
200
|
+
- spec/fixtures/foobarbaz
|
201
|
+
- spec/fixtures/hieradata/good.json
|
202
|
+
- spec/fixtures/hieradata/good.yaml
|
203
|
+
- spec/fixtures/hieradata/style.yaml
|
204
|
+
- spec/fixtures/hieradata/syntax.json
|
205
|
+
- spec/fixtures/hieradata/syntax.yaml
|
206
|
+
- spec/fixtures/lib/good.rb
|
207
|
+
- spec/fixtures/lib/rubocop_style.rb
|
208
|
+
- spec/fixtures/lib/style.rb
|
209
|
+
- spec/fixtures/lib/syntax.rb
|
210
|
+
- spec/fixtures/librarian_good/Puppetfile
|
211
|
+
- spec/fixtures/librarian_style/Puppetfile
|
212
|
+
- spec/fixtures/librarian_syntax/Puppetfile
|
213
|
+
- spec/fixtures/manifests/good.pp
|
214
|
+
- spec/fixtures/manifests/style_lint.pp
|
215
|
+
- spec/fixtures/manifests/style_parser.pp
|
216
|
+
- spec/fixtures/manifests/syntax.pp
|
217
|
+
- spec/fixtures/metadata_good/metadata.json
|
218
|
+
- spec/fixtures/metadata_style/metadata.json
|
219
|
+
- spec/fixtures/metadata_syntax/metadata.json
|
220
|
+
- spec/fixtures/templates/good.epp
|
221
|
+
- spec/fixtures/templates/good.erb
|
222
|
+
- spec/fixtures/templates/no_method_error.erb
|
223
|
+
- spec/fixtures/templates/style.erb
|
224
|
+
- spec/fixtures/templates/syntax.epp
|
225
|
+
- spec/fixtures/templates/syntax.erb
|
226
|
+
- spec/integration/integration_spec.rb
|
227
|
+
- spec/puppet-check/cli_spec.rb
|
228
|
+
- spec/puppet-check/data_parser_spec.rb
|
229
|
+
- spec/puppet-check/puppet_parser_spec.rb
|
230
|
+
- spec/puppet-check/ruby_parser_spec.rb
|
231
|
+
- spec/puppet-check/utils_spec.rb
|
232
|
+
- spec/puppet-check_spec.rb
|
233
|
+
- spec/spec_helper.rb
|