Sha256: e8e07470f763617d8312f779a8aefc29bfc13270dd084b2d9d9030d153825240

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require 'virtus'

class Numeric
  def percent_of(n)
    self.to_f / n.to_f * 100.0
  end
end

class PuppetDocLint
  class Result
    include Virtus.model
    attribute :class_name, String
    attribute :file_name, String
    attribute :parameters, String
    attribute :no_documentation, Boolean, :default => false
    attribute :documented_parameters,   String, :default => []
    attribute :undocumented_parameters, String, :default => []
    attribute :documented_parameter_no_assignment, String, :default => []
    attribute :authors, String, :default => []

    def result_report
      puts "===================================="
      puts "Class #{class_name} ( #{file_name} )".bg_blue
      puts "Parameters found #{parameters}"
      if no_documentation
        puts "No documentation found."
        puts "If there is documentation, this may be a bug with the Puppet parser"
        puts "Puppet files with newer features such as the use of hashes can cause this\n\n"
      else
        puts "Documented parameters found: #{documented_parameters}".green
        puts "Undocumented parameters found: #{undocumented_parameters}".red
        puts "Parameters with Documentation but no defintion: #{documented_parameter_no_assignment}".red unless documented_parameter_no_assignment.empty?
        puts "Documentation Coverage: #{percent_documented}%"
        puts "Authors: #{authors}" unless authors.empty?
      end
    end

    def percent_documented
      if documented_parameters.size == 0
        100
      else
        documented_parameters.size.percent_of(parameters.size).round(2)
      end
    end

  end #class Result
end #module PuppetDocLint

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puppet-doc-lint-0.2.0 lib/puppet-doc-lint/result.rb
puppet-doc-lint-0.1.1 lib/puppet-doc-lint/result.rb
puppet-doc-lint-0.1.0 lib/puppet-doc-lint/result.rb