Sha256: 165d2997c90a01e02ce40627455c87680977cbf87456379388de2736c2b61d55

Contents?: true

Size: 1006 Bytes

Versions: 1

Compression:

Stored size: 1006 Bytes

Contents

require 'puppet-strings/markdown/base'

module PuppetStrings::Markdown
  class ResourceType < Base
    def initialize(registry)
      @template = 'resource_type.erb'
      super(registry, 'type')
    end

    def render
      super(@template)
    end

    def properties
      return nil unless @registry[:properties]

      @registry[:properties].sort_by { |p| p[:name] }
    end

    def checks
      return nil unless @registry[:checks]

      @registry[:checks].sort_by { |p| p[:name] }
    end

    # "checks" (such as "onlyif" or "creates") are another type of property
    def properties_and_checks
      return nil if properties.nil? && checks.nil?

      ((properties || []) + (checks || [])).sort_by { |p| p[:name] }
    end

    def parameters
      return nil unless @registry[:parameters]

      @registry[:parameters].sort_by { |p| p[:name] }
    end

    def regex_in_data_type?(data_type)
      m = data_type.match(/\w+\[\/.*\/\]/)
      m unless m.nil? || m.length.zero?
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puppet-strings-2.5.0 lib/puppet-strings/markdown/resource_type.rb