~lynxman/ubuntu/oneiric/puppet/lp_854899

« back to all changes in this revision

Viewing changes to lib/puppet/resource/type.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-25 01:00:37 UTC
  • mfrom: (1.1.24 upstream) (3.1.25 sid)
  • Revision ID: james.westby@ubuntu.com-20110725010037-875vuxs10eboqgw3
Tags: 2.7.1-1ubuntu1
* Merge from debian unstable.  Remaining changes:
  - debian/puppetmaster-passenger.postinst: Use cacrl instead of hostcrl to
    set the location of the CRL in apache2 configuration. Fix apache2
    configuration on upgrade as well (LP: #641001)
  - move all puppet dependencies to puppet-common since all the code
    actually located in puppet-common.
  - move libagueas from a recommend to a dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
 
14
14
  RESOURCE_SUPERTYPES = [:hostclass, :node, :definition]
15
15
 
16
 
  attr_accessor :file, :line, :doc, :code, :ruby_code, :parent, :resource_type_collection, :module_name
17
 
  attr_reader :type, :namespace, :arguments, :behaves_like
 
16
  attr_accessor :file, :line, :doc, :code, :ruby_code, :parent, :resource_type_collection
 
17
  attr_reader :type, :namespace, :arguments, :behaves_like, :module_name
18
18
 
19
19
  RESOURCE_SUPERTYPES.each do |t|
20
20
    define_method("#{t}?") { self.type == t }
34
34
  end
35
35
 
36
36
  def to_pson_data_hash
37
 
    data = [:code, :doc, :line, :file, :parent].inject({}) do |hash, param|
38
 
      next hash unless value = self.send(param)
 
37
    data = [:doc, :line, :file, :parent].inject({}) do |hash, param|
 
38
      next hash unless (value = self.send(param)) and (value != "")
39
39
      hash[param.to_s] = value
40
40
      hash
41
41
    end
42
42
 
43
 
    data['arguments'] = arguments.dup
 
43
    data['arguments'] = arguments.dup unless arguments.empty?
44
44
 
45
45
    data['name'] = name
46
46
    data['type'] = type
62
62
 
63
63
  # Now evaluate the code associated with this class or definition.
64
64
  def evaluate_code(resource)
65
 
    scope = resource.scope
66
 
 
67
 
    if tmp = evaluate_parent_type(resource)
68
 
      scope = tmp
69
 
    end
70
 
 
71
 
    scope = subscope(scope, resource) unless resource.title == :main
 
65
 
 
66
    static_parent = evaluate_parent_type(resource)
 
67
    scope = static_parent || resource.scope
 
68
 
 
69
    scope = scope.newscope(:namespace => namespace, :source => self, :resource => resource, :dynamic => !static_parent) unless resource.title == :main
72
70
    scope.compiler.add_class(name) unless definition?
73
71
 
74
72
    set_resource_parameters(resource, scope)
92
90
    end
93
91
 
94
92
    set_arguments(options[:arguments])
 
93
 
 
94
    @module_name = options[:module_name]
95
95
  end
96
96
 
97
97
  # This is only used for node names, and really only when the node name
261
261
 
262
262
  end
263
263
 
264
 
  # Create a new subscope in which to evaluate our code.
265
 
  def subscope(scope, resource)
266
 
    scope.newscope :resource => resource, :namespace => self.namespace, :source => self
267
 
  end
268
 
 
269
264
  # Check whether a given argument is valid.
270
265
  def valid_parameter?(param)
271
266
    param = param.to_s