Parent

PuppetLint

Public Class Methods

configuration() click to toggle source
# File lib/puppet-lint.rb, line 79
def self.configuration
  @configuration ||= PuppetLint::Configuration.new
end
new() click to toggle source
# File lib/puppet-lint.rb, line 73
def initialize
  @data = nil
  @statistics = {:error => 0, :warning => 0}
  @fileinfo = {:path => ''}
end

Public Instance Methods

code=(value) click to toggle source
# File lib/puppet-lint.rb, line 96
def code=(value)
  @data = value
end
configuration() click to toggle source
# File lib/puppet-lint.rb, line 83
def configuration
  self.class.configuration
end
errors?() click to toggle source
# File lib/puppet-lint.rb, line 141
def errors?
  @statistics[:error] != 0
end
file=(path) click to toggle source
# File lib/puppet-lint.rb, line 87
def file=(path)
  if File.exist? path
    @fileinfo[:path] = path
    @fileinfo[:fullpath] = File.expand_path(path)
    @fileinfo[:filename] = File.basename(path)
    @data = File.read(path)
  end
end
format_message(message) click to toggle source
# File lib/puppet-lint.rb, line 112
def format_message(message)
  format = log_format
  puts format % message
end
log_format() click to toggle source
# File lib/puppet-lint.rb, line 100
def log_format
  if configuration.log_format == ''
    ## recreate previous old log format as far as thats possible.
    format = '%{KIND}: %{message} on line %{linenumber}'
    if configuration.with_filename
      format.prepend '%{path} - '
    end
    configuration.log_format = format
  end
  return configuration.log_format
end
report(problems, linter) click to toggle source
# File lib/puppet-lint.rb, line 127
def report(problems, linter)
  problems.each do |message|
    @statistics[message[:kind]] += 1
    ## Add some default attributes.
    message.merge!(@fileinfo) {|key, v1, v2| v1 }
    message[:KIND] = message[:kind].to_s.upcase

    if configuration.error_level == message[:kind] or configuration.error_level == :all
      format_message message
      print_context(message, linter) if configuration.with_context
    end
  end
end
run() click to toggle source
# File lib/puppet-lint.rb, line 149
def run
  if @data.nil?
    raise PuppetLint::NoCodeError
  end

  linter = PuppetLint::Checks.new
  problems = linter.run(@fileinfo, @data)
  report problems, linter
end
warnings?() click to toggle source
# File lib/puppet-lint.rb, line 145
def warnings?
  @statistics[:warning] != 0
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.