Sha256: 058ea5a72b83397500acabf4e2123cf2d190bbb129e30eac83bb614779e12242

Contents?: true

Size: 829 Bytes

Versions: 4

Compression:

Stored size: 829 Bytes

Contents

require_relative 'puppet_module'
require_relative 'variable_store'
require 'retrospec/exceptions'

class TypeCode
  attr_reader :type, :variables, :scope_name, :parent, :name

  #TODO figure out how to store vardef statements that are contained inside conditional blocks
  def initialize(type)
    raise TypeNotFoundException unless type
    @scope_name = type.namespace
    @name = type.name
    @type = type
    @parent = type.parent
  end
  # need to figure out a way to load the parent or dependent manfifests
  def has_parent?
    @parent.nil?
  end

  # returns a list of variables found in the main code block
  def variables
    if @type.code.respond_to?(:find_all)
      @variables ||= @type.code.find_all {|i| i.instance_of?(Puppet::Parser::AST::VarDef) }
    else
      @variables = []
    end
    @variables
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-retrospec-0.11.0 lib/retrospec/plugins/v1/plugin/type_code.rb
puppet-retrospec-0.10.0 lib/retrospec/plugins/v1/plugin/type_code.rb
puppet-retrospec-0.9.1 lib/retrospec/plugins/v1/plugin/type_code.rb
puppet-retrospec-0.9.0 lib/retrospec/plugins/v1/plugin/type_code.rb