Sha256: 1503ef7eb47103cc3a1f64d25f6517e6e8e809063de11ee7b08383a89db05cdf

Contents?: true

Size: 831 Bytes

Versions: 7

Compression:

Stored size: 831 Bytes

Contents

require 'retrospec/puppet_module'
require 'retrospec/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

7 entries across 7 versions & 1 rubygems

Version Path
puppet-retrospec-0.8.1 lib/retrospec/type_code.rb
puppet-retrospec-0.8.0 lib/retrospec/type_code.rb
puppet-retrospec-0.7.3 lib/retrospec/type_code.rb
puppet-retrospec-0.7.2 lib/retrospec/type_code.rb
puppet-retrospec-0.7.0 lib/retrospec/type_code.rb
puppet-retrospec-0.6.1 lib/retrospec/type_code.rb
puppet-retrospec-0.6.0 lib/retrospec/type_code.rb