Class: PuppetCheck
- Inherits:
-
Object
- Object
- PuppetCheck
- Defined in:
- lib/puppet-check.rb
Overview
interfaces from CLI/tasks and to individual parsers
Defined Under Namespace
Class Attribute Summary collapse
-
.clean_files ⇒ Object
Returns the value of attribute clean_files.
-
.error_files ⇒ Object
Returns the value of attribute error_files.
-
.future_parser ⇒ Object
Returns the value of attribute future_parser.
-
.ignored_files ⇒ Object
Returns the value of attribute ignored_files.
-
.output_format ⇒ Object
Returns the value of attribute output_format.
-
.puppetlint_args ⇒ Object
Returns the value of attribute puppetlint_args.
-
.rubocop_args ⇒ Object
Returns the value of attribute rubocop_args.
-
.style_check ⇒ Object
Returns the value of attribute style_check.
-
.warning_files ⇒ Object
Returns the value of attribute warning_files.
Class Method Summary collapse
-
.parse_paths(paths) ⇒ Object
parse the paths and return the array of files.
Instance Method Summary collapse
-
#execute_parsers(files, future, style, pl_args, rc_args) ⇒ Object
categorize and pass the files out to the parsers to determine their status.
-
#run(paths) ⇒ Object
main runner for PuppetCheck.
Class Attribute Details
.clean_files ⇒ Object
Returns the value of attribute clean_files.
27 28 29 |
# File 'lib/puppet-check.rb', line 27 def clean_files @clean_files end |
.error_files ⇒ Object
Returns the value of attribute error_files.
27 28 29 |
# File 'lib/puppet-check.rb', line 27 def error_files @error_files end |
.future_parser ⇒ Object
Returns the value of attribute future_parser.
27 28 29 |
# File 'lib/puppet-check.rb', line 27 def future_parser @future_parser end |
.ignored_files ⇒ Object
Returns the value of attribute ignored_files.
27 28 29 |
# File 'lib/puppet-check.rb', line 27 def ignored_files @ignored_files end |
.output_format ⇒ Object
Returns the value of attribute output_format.
27 28 29 |
# File 'lib/puppet-check.rb', line 27 def output_format @output_format end |
.puppetlint_args ⇒ Object
Returns the value of attribute puppetlint_args.
27 28 29 |
# File 'lib/puppet-check.rb', line 27 def puppetlint_args @puppetlint_args end |
.rubocop_args ⇒ Object
Returns the value of attribute rubocop_args.
27 28 29 |
# File 'lib/puppet-check.rb', line 27 def rubocop_args @rubocop_args end |
.style_check ⇒ Object
Returns the value of attribute style_check.
27 28 29 |
# File 'lib/puppet-check.rb', line 27 def style_check @style_check end |
.warning_files ⇒ Object
Returns the value of attribute warning_files.
27 28 29 |
# File 'lib/puppet-check.rb', line 27 def warning_files @warning_files end |
Class Method Details
.parse_paths(paths) ⇒ Object
parse the paths and return the array of files
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/puppet-check.rb', line 46 def self.parse_paths(paths) files = [] # traverse the unique paths and return all files paths.uniq.each do |path| if File.directory?(path) files.concat(Dir.glob("#{path}/**/*").select { |subpath| File.file? subpath }) elsif File.file?(path) files.push(path) end end # do not process fixtures, check that at least one file was found, and remove double slashes files.reject! { |file| file =~ /fixtures/ } raise "puppet-check: no files found in supplied paths #{paths.join(', ')}." if files.empty? files.map! { |file| file.gsub('//', '/') } files.uniq end |
Instance Method Details
#execute_parsers(files, future, style, pl_args, rc_args) ⇒ Object
categorize and pass the files out to the parsers to determine their status
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/puppet-check.rb', line 67 def execute_parsers(files, future, style, pl_args, rc_args) PuppetParser.manifest(files.select { |file| File.extname(file) == '.pp' }, future, style, pl_args) files.reject! { |file| File.extname(file) == '.pp' } PuppetParser.template(files.select { |file| File.extname(file) == '.epp' }) files.reject! { |file| File.extname(file) == '.epp' } RubyParser.ruby(files.select { |file| File.extname(file) == '.rb' }, style, rc_args) files.reject! { |file| File.extname(file) == '.rb' } RubyParser.template(files.select { |file| File.extname(file) == '.erb' }) files.reject! { |file| File.extname(file) == '.erb' } DataParser.yaml(files.select { |file| File.extname(file) =~ /\.ya?ml$/ }) files.reject! { |file| File.extname(file) =~ /\.ya?ml$/ } DataParser.json(files.select { |file| File.extname(file) == '.json' }) files.reject! { |file| File.extname(file) == '.json' } RubyParser.librarian(files.select { |file| File.basename(file) =~ /(?:Puppet|Module|Rake|Gem)file$/ }, style, rc_args) files.reject! { |file| File.basename(file) =~ /(?:Puppet|Module|Rake|Gem)file$/ } files.each { |file| self.class.ignored_files.push(file.to_s) } end |
#run(paths) ⇒ Object
main runner for PuppetCheck
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/puppet-check.rb', line 31 def run(paths) # grab all of the files to be processed files = self.class.parse_paths(paths) # parse the files execute_parsers(files, self.class.future_parser, self.class.style_check, self.class.puppetlint_args, self.class.rubocop_args) # output the diagnostic results PuppetCheck.output_format == 'text' ? OutputResults.text : OutputResults.markup # exit code self.class.error_files.empty? ? 0 : 2 end |