puppet 3.1.0.rc1 → 3.1.0.rc2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (127) hide show
  1. data/COMMITTERS.md +185 -0
  2. data/ext/debian/changelog.erb +6 -0
  3. data/ext/debian/puppet-common.manpages +1 -0
  4. data/ext/debian/puppet.default +3 -1
  5. data/ext/debian/puppetmaster.default +6 -3
  6. data/ext/redhat/puppet.spec.erb +16 -5
  7. data/lib/puppet.rb +3 -5
  8. data/lib/puppet/defaults.rb +6 -5
  9. data/lib/puppet/dsl.rb +3 -7
  10. data/lib/puppet/dsl/resource_api.rb +120 -0
  11. data/lib/puppet/dsl/resource_type_api.rb +34 -0
  12. data/lib/puppet/module_tool.rb +23 -11
  13. data/lib/puppet/network/formats.rb +1 -1
  14. data/lib/puppet/node/environment.rb +1 -3
  15. data/lib/puppet/parser/ast/definition.rb +5 -2
  16. data/lib/puppet/parser/ast/hostclass.rb +3 -2
  17. data/lib/puppet/parser/ast/node.rb +5 -2
  18. data/lib/puppet/parser/ast/resourceparam.rb +1 -1
  19. data/lib/puppet/parser/compiler.rb +0 -10
  20. data/lib/puppet/parser/lexer.rb +50 -39
  21. data/lib/puppet/parser/parser_support.rb +29 -11
  22. data/lib/puppet/parser/scope.rb +2 -2
  23. data/lib/puppet/parser/type_loader.rb +7 -31
  24. data/lib/puppet/provider/package/openbsd.rb +16 -2
  25. data/lib/puppet/provider/package/pip.rb +11 -2
  26. data/lib/puppet/provider/package/portage.rb +29 -12
  27. data/lib/puppet/provider/service/launchd.rb +19 -14
  28. data/lib/puppet/provider/service/upstart.rb +1 -1
  29. data/lib/puppet/provider/user/hpux.rb +37 -2
  30. data/lib/puppet/resource.rb +25 -38
  31. data/lib/puppet/resource/type.rb +6 -14
  32. data/lib/puppet/settings.rb +1 -1
  33. data/lib/puppet/ssl/certificate_authority.rb +4 -1
  34. data/lib/puppet/ssl/certificate_request.rb +3 -1
  35. data/lib/puppet/ssl/certificate_signer.rb +22 -0
  36. data/lib/puppet/type.rb +4 -4
  37. data/lib/puppet/util/methodhelper.rb +0 -19
  38. data/lib/puppet/util/rubygems.rb +3 -1
  39. data/lib/puppet/util/selinux.rb +1 -6
  40. data/lib/puppet/version.rb +1 -1
  41. data/man/man5/puppet.conf.5 +81 -95
  42. data/man/man8/extlookup2hiera.8 +23 -0
  43. data/man/man8/puppet-agent.8 +3 -3
  44. data/man/man8/puppet-apply.8 +2 -6
  45. data/man/man8/puppet-ca.8 +6 -7
  46. data/man/man8/puppet-catalog.8 +6 -7
  47. data/man/man8/puppet-cert.8 +4 -4
  48. data/man/man8/puppet-certificate.8 +6 -7
  49. data/man/man8/puppet-certificate_request.8 +6 -7
  50. data/man/man8/puppet-certificate_revocation_list.8 +6 -7
  51. data/man/man8/puppet-config.8 +4 -8
  52. data/man/man8/puppet-describe.8 +1 -1
  53. data/man/man8/puppet-device.8 +1 -1
  54. data/man/man8/puppet-doc.8 +3 -3
  55. data/man/man8/puppet-facts.8 +4 -8
  56. data/man/man8/puppet-file.8 +6 -7
  57. data/man/man8/puppet-filebucket.8 +1 -1
  58. data/man/man8/puppet-help.8 +2 -6
  59. data/man/man8/puppet-inspect.8 +1 -1
  60. data/man/man8/puppet-instrumentation_data.8 +3 -7
  61. data/man/man8/puppet-instrumentation_listener.8 +3 -7
  62. data/man/man8/puppet-instrumentation_probe.8 +3 -7
  63. data/man/man8/puppet-key.8 +6 -7
  64. data/man/man8/puppet-kick.8 +5 -1
  65. data/man/man8/puppet-man.8 +2 -6
  66. data/man/man8/puppet-master.8 +2 -2
  67. data/man/man8/puppet-module.8 +11 -9
  68. data/man/man8/puppet-node.8 +38 -37
  69. data/man/man8/puppet-parser.8 +2 -6
  70. data/man/man8/puppet-plugin.8 +2 -6
  71. data/man/man8/puppet-queue.8 +1 -1
  72. data/man/man8/puppet-report.8 +3 -7
  73. data/man/man8/puppet-resource.8 +1 -1
  74. data/man/man8/puppet-resource_type.8 +3 -7
  75. data/man/man8/puppet-secret_agent.8 +2 -6
  76. data/man/man8/puppet-status.8 +3 -7
  77. data/man/man8/puppet.8 +1 -1
  78. data/spec/integration/parser/ruby_manifest_spec.rb +128 -0
  79. data/spec/lib/puppet_spec/compiler.rb +0 -11
  80. data/spec/spec_helper.rb +3 -4
  81. data/spec/unit/dsl/resource_api_spec.rb +180 -0
  82. data/spec/unit/dsl/resource_type_api_spec.rb +53 -0
  83. data/spec/unit/module_tool_spec.rb +79 -46
  84. data/spec/unit/network/formats_spec.rb +4 -0
  85. data/spec/unit/node/environment_spec.rb +0 -13
  86. data/spec/unit/parser/compiler_spec.rb +0 -26
  87. data/spec/unit/parser/parser_spec.rb +14 -0
  88. data/spec/unit/parser/type_loader_spec.rb +4 -15
  89. data/spec/unit/provider/package/openbsd_spec.rb +148 -35
  90. data/spec/unit/provider/package/pip_spec.rb +49 -25
  91. data/spec/unit/provider/package/portage_spec.rb +65 -0
  92. data/spec/unit/provider/service/launchd_spec.rb +6 -5
  93. data/spec/unit/provider/user/hpux_spec.rb +39 -11
  94. data/spec/unit/provider/user/useradd_spec.rb +14 -14
  95. data/spec/unit/resource/type_spec.rb +7 -49
  96. data/spec/unit/resource_spec.rb +0 -32
  97. data/spec/unit/ssl/certificate_request_spec.rb +18 -0
  98. data/spec/unit/util/rubygems_spec.rb +1 -1
  99. data/spec/unit/util/selinux_spec.rb +0 -2
  100. metadata +17 -50
  101. data/lib/puppet/dsl/actions.rb +0 -283
  102. data/lib/puppet/dsl/blank_slate.rb +0 -55
  103. data/lib/puppet/dsl/context.rb +0 -393
  104. data/lib/puppet/dsl/parser.rb +0 -57
  105. data/lib/puppet/dsl/resource_decorator.rb +0 -56
  106. data/lib/puppet/dsl/resource_reference.rb +0 -95
  107. data/lib/puppet/dsl/type_reference.rb +0 -102
  108. data/lib/puppet/util/manifest_filetype_helper.rb +0 -22
  109. data/spec/integration/dsl/classes_spec.rb +0 -191
  110. data/spec/integration/dsl/defaults_spec.rb +0 -38
  111. data/spec/integration/dsl/definitions_spec.rb +0 -73
  112. data/spec/integration/dsl/functions_spec.rb +0 -95
  113. data/spec/integration/dsl/nodes_spec.rb +0 -96
  114. data/spec/integration/dsl/params_spec.rb +0 -146
  115. data/spec/integration/dsl/relationships_spec.rb +0 -46
  116. data/spec/integration/dsl/resources_spec.rb +0 -202
  117. data/spec/integration/dsl/type_loading_spec.rb +0 -64
  118. data/spec/lib/matchers/catalog.rb +0 -50
  119. data/spec/lib/puppet_spec/dsl.rb +0 -29
  120. data/spec/unit/dsl/actions_spec.rb +0 -402
  121. data/spec/unit/dsl/blank_slate_spec.rb +0 -27
  122. data/spec/unit/dsl/context_spec.rb +0 -678
  123. data/spec/unit/dsl/parser_spec.rb +0 -56
  124. data/spec/unit/dsl/resource_decorator_spec.rb +0 -94
  125. data/spec/unit/dsl/resource_reference_spec.rb +0 -150
  126. data/spec/unit/dsl/type_reference_spec.rb +0 -164
  127. data/spec/unit/util/manifest_filetype_helper_spec.rb +0 -29
@@ -1,55 +0,0 @@
1
- module Puppet
2
- # @since 3.1
3
- # @status EXPERIMENTAL
4
- module DSL
5
-
6
- # See documentation below where the class is reopened
7
- if RUBY_VERSION < "1.9"
8
- ##
9
- # Ruby 1.8 version - see reopened class below for documentation
10
- # Undefine all methods except those defined in BasicObject.
11
- ##
12
- class BlankSlate
13
- instance_methods.each do |m|
14
- unless ['==', 'equal?', 'instance_eval', 'instance_exec', '__send__', '__id__'].include? m
15
- undef_method m
16
- end
17
- end
18
- end
19
- else
20
- ##
21
- # Ruby 1.9 version - see reopened class below for documentation
22
- ##
23
- class BlankSlate < BasicObject; end
24
- end
25
-
26
- # BlankSlate is a class intended for use with `method_missing`.
27
- #
28
- # * Ruby 1.9 version is based on BasicObject.
29
- # * Ruby 1.8 version has almost all methods undefined.
30
- #
31
- # Ruby 1.9 version doesn't include Kernel module.
32
- # To reference a constant in that version `::` has to be prepended to
33
- # the constant name.
34
- #
35
- class BlankSlate
36
- # Reopening class to add methods.
37
- # The class is conditionally created above with different superclass depending on ruby version
38
-
39
- private
40
-
41
- # Adds method normally found in {Object}, but needs to be added as {BasicObject} in Ruby 1.9
42
- # does not include it.
43
- # This method is used to define a {Context} singleton method as a cached version of a method
44
- # generated by a `method_missing` call.
45
- # @return [void]
46
- #
47
- def define_singleton_method(name, &block)
48
- class << self; self; end.instance_eval do
49
- define_method name, &block
50
- end
51
- end
52
- end
53
-
54
- end
55
- end
@@ -1,393 +0,0 @@
1
- require 'puppet/dsl/actions'
2
- require 'puppet/dsl/blank_slate'
3
-
4
- module Puppet
5
- # @since 3.1
6
- # @status
7
- # EXPERIMENTAL
8
- module DSL
9
-
10
- ##
11
- # The Puppet::DSL::Context class is used to evaluate all Puppet Ruby DSL manifest code.
12
- # (i.e. .rb files containing ruby logic in the Puppet Ruby internal DSL language).
13
- #
14
- # The Context class is based on the BlankSlate class and the number of available method
15
- # is reduced to the bare minimum.
16
- #
17
- # Available methods are:
18
- #
19
- # * {Object}.raise,
20
- # * {Object}.require,
21
- # * all methods in this file,
22
- # * all methods defined by {#method_missing}.
23
- #
24
- # Context is evaluated when the corresponding resource is evaluated during
25
- # compilation.
26
- #
27
- class Context < BlankSlate
28
-
29
- # Provides syntactic sugar for resource references.
30
- # Returns a reference to a resource type having the given name.
31
- # A cached version of TypeReference is created on the first call.
32
- #
33
- # @param name [String] the name of the resource type
34
- # @return [TypeReference]
35
- # @raise [NameError] if the referenced type does not exist.
36
- # @see TypeReference TypeReference for further information
37
- ##
38
- def self.const_missing(name)
39
- @proxy ||= ::Puppet::DSL::Actions.new "dsl_main"
40
- ref = @proxy.type_reference name
41
- const_set name, ref unless @proxy.is_resource_type? name
42
- ref
43
- end
44
-
45
- # Returns whether the given _name_ is defined (i.e. if the type exists).
46
- # The algorithm is identical to the one used in {#respond_to?}.
47
- #
48
- def self.const_defined?(name)
49
- @proxy ||= ::Puppet::DSL::Actions.new "dsl_main"
50
- @proxy.is_resource_type? name
51
- end
52
-
53
- # A fallback method for obtaining type references for Ruby 1.8 users.
54
- # @return [TypeReference] reference to the type
55
- #
56
- def type(name)
57
- @proxy.type_reference name
58
- end
59
-
60
- # Initializes new context.
61
- # @todo Improve the explanation of the :nesting option
62
- # @param code [Proc] the code to evaluate during evaluation of a resource.
63
- # @option options [Fixnum] :nesting The context nesting. Defaults to 0
64
- # @option options [String] :filename The file name where the code originates. Default to "dsl_main"
65
- #
66
- def initialize(code, options = {})
67
- @nesting = options.fetch :nesting, 0
68
- @filename = options.fetch :filename, "dsl_main"
69
- @proxy = ::Puppet::DSL::Actions.new @filename
70
- @code = code
71
- end
72
-
73
- # Executes ruby code in the context of the given scope.
74
- # (Called when evaluating resource types).
75
- # @param scope [Puppet::Parser::Scope] the scope to use when evaluating
76
- # @param type_collection [Puppet::Resource::TypeCollection] the set of known types
77
- # @return [Object] what the evaluated code returns.
78
- #
79
- def evaluate(scope, type_collection)
80
- ::Puppet::DSL::Parser.add_scope scope
81
- ::Puppet::DSL::Parser.known_resource_types = type_collection
82
- instance_eval &@code
83
- ensure
84
- ::Puppet::DSL::Parser.known_resource_types = nil
85
- ::Puppet::DSL::Parser.remove_scope
86
- end
87
-
88
- # Proxy method for {Object}.raise
89
- # @return [!] this method does not return
90
- # @raise [args[0]] with args[1..-1] as arguments
91
- # @note This method does not return
92
- def raise(*args)
93
- ::Object.send :raise, *args
94
- end
95
-
96
- # The contents of the block passed to this method will be evaluated in the
97
- # context of {Object} instead of {BlankSlate}
98
- # This adds access to methods defined in global scope (like `require`).
99
- # @param block [{|| block}] the block to evaluate.
100
- # @return [Object] what the given block returns when evaluated
101
- def ruby_eval(&block)
102
- @object ||= ::Object.new
103
- @object.instance_eval &block
104
- end
105
-
106
- # Creates a new node in top scope. A node with the same name-match must not
107
- # already have been created. Nodes can be created only in top scope.
108
- #
109
- # The block is called when node is evaluated.
110
- #
111
- # @example
112
- # node "default", :inherits => "foobar" do
113
- # use :foo
114
- # end
115
- #
116
- # @overload node(name, options={}, {|| block})
117
- # @param name [String, Regexp] host-name match
118
- # @option options [String] :inherits name of super/parent node
119
- # @param block [{|| block}] the block containing Ruby DSL statements
120
- # @raise [ArgumentError] when called without a block
121
- # @raise [NoMethodError] when called in a scope other than top scope
122
- # @return [void]
123
- def node(name, options = {}, &block)
124
- @proxy.create_node(name, options, @nesting, &block)
125
- end
126
-
127
- # Creates a new hostclass. It is an error to create a new hostclass with
128
- # the same name as an existing hostclass.
129
- # Hostclasses can only be created in the top level scope.
130
- #
131
- # The given _block_ is called when the hostclass is evaluated.
132
- #
133
- # @example
134
- # hostclass :foo, :arguments => {:message => nil} do
135
- # notice params[:message]
136
- # end
137
- #
138
- # @overload hostclass(name, options={}, {|| block})
139
- # @param name [Symbol] the name of the class
140
- # @option options [String] :inherits name of super/parent class
141
- # @option options [Hash] :arguments mapping of hostclass parameter name to value
142
- # @param block [{|| block}] the block containing Ruby DSL statements
143
- # @raise [ArgumentError] when called without block
144
- # @raise [NoMethodError] when called in a scope other than top scope
145
- # @return [void]
146
- #
147
- def hostclass(name, options = {}, &block)
148
- @proxy.create_hostclass(name, options, @nesting, &block)
149
- end
150
-
151
- # Creates a new definition. It is an error to create a new definition with
152
- # the same name as an existing definition.
153
- # Definitions can only be created in the top level scope.
154
- #
155
- # The given _block_ is called when the definition is evaluated.
156
- #
157
- #
158
- # @example
159
- # define :foobar, :arguments => {:myparam => "myvalue"} do
160
- # notice params[:myparam]
161
- # end
162
- #
163
- # @overload define(name, options={}, {|| block})
164
- # @param name [Symbol] the name of the class
165
- # @option options [Hash] :arguments mapping of definition parameter name to value
166
- # @param block [{|| block}] the block containing Ruby DSL statements
167
- # @raise [ArgumentError] when called without block
168
- # @raise [NoMethodError] when called in a scope other than top scope
169
- # @return [void]
170
- ##
171
- def define(name, options = {}, &block)
172
- @proxy.create_definition(name, options, @nesting, &block)
173
- end
174
-
175
- # Syntax sugar for creating hostclass resources.
176
- # This is the same as calling `create_resource(:class, *args)`
177
- # @see #create_resource
178
- # @return (see #create_resource)
179
- #
180
- def use(*args)
181
- create_resource :class, *args
182
- end
183
-
184
- # Checks whether Puppet type exists in the following order:
185
- #
186
- # 1. is it a hostclass or node?
187
- # 2. is it a builtin type?
188
- # 3. is it a defined type?
189
- #
190
- # @return [Boolean] true if the name represents a type, false otherwise
191
- def valid_type?(name)
192
- @proxy.is_resource_type? name
193
- end
194
-
195
- ##
196
- # Checks whether Puppet function exists.
197
- ##
198
- def valid_function?(name)
199
- @proxy.is_function? name
200
- end
201
-
202
- ##
203
- # Method will return true when a function or type exists.
204
- ##
205
- def respond_to?(name)
206
- valid_type? name or valid_function? name
207
- end
208
-
209
- # Provides syntax sugar for creating resources and calling functions.
210
- # A cached version of the generated method is created on first use.
211
- #
212
- # First it will check if the name is the name of an existing resource type, if so,
213
- # a resource is created.
214
- # If the name was not a type, a check is made if the name is the name of an existing
215
- # function, and if so, this function is called.
216
- # If the function doesn't exist, the super version is called, which will raise an exception.
217
- #
218
- # @example Examples of logic handled by #method_missing
219
- # notice "foo"
220
- #
221
- # file "/tmp/test", :ensure => :present
222
- #
223
- # @return [Object, void] depends on what was called
224
- #
225
- def method_missing(name, *args, &block)
226
- if @proxy.is_resource_type? name
227
- # Creating cached version of a method for future use
228
- define_singleton_method name do |*a, &b|
229
- options = a.last.is_a?(::Hash) ? a.pop : {}
230
- @proxy.create_resource(name, a, options, b)
231
- end
232
-
233
- __send__ name, *args, &block
234
- elsif @proxy.is_function? name
235
- # Creating cached version of a method for future use
236
- define_singleton_method name do |*a|
237
- @proxy.call_function name, *a
238
- end
239
-
240
- __send__ name, *args
241
- else
242
- super
243
- end
244
- end
245
-
246
- ##
247
- # Returns string description of context
248
- ##
249
- def inspect
250
- @filename.inspect
251
- end
252
-
253
- ##
254
- # Returns current scope for access for variables
255
- ##
256
- def params
257
- @proxy.params
258
- end
259
-
260
- # Creates one or several resources of a given type.
261
- # The last argument can be a hash with parameters for the resources.
262
- # Parameters can be also set by passing a block. (See the example below).
263
- # For further information on block syntax please look at {ResourceDecorator}
264
- #
265
- # @example
266
- # create_resource :file, "/foo/bar", "/tmp/test", :owner => "root" do |f|
267
- # f.mode = "0600"
268
- # f.ensure = :present
269
- # end
270
- #
271
- # @overload create_resource(type, title)
272
- # @overload create_resource(type, title, {|r| block})
273
- # @overload create_resource(type, title, parameters, {|r| block})
274
- # @overload create_resource(type, title, ..., parameters)
275
- # @overload create_resource(type, title, ..., parameters, {|r| block})
276
- # @param type [Symbol] the name of the resource type
277
- # @param title [String] one or more titles (one per resource to create)
278
- # @param parameters [Hash] mapping of parameter name to value for all created resources
279
- # @param r [ResourceDecorator] access to the created resource for further manipulation in the given block
280
- # @param block [ruby] the Ruby DSL statements to execute
281
- # @return [Array<Puppet::Parser::Resource>] created resources
282
- # @raise [NoMethodError] when the resource type is not found
283
- #
284
- def create_resource(type, *args, &block)
285
- __send__ type, *args, &block
286
- end
287
-
288
- # Calls a puppet function.
289
- # It does not validate arguments to the function.
290
- #
291
- # @example
292
- # call_function :notice, "foo"
293
- #
294
- # @param name [Symbol] the name of the function
295
- # @param *args arguments passed to the called function
296
- # @return [Object, void] what the function returns, or void if function does not produce a r-value.
297
- #
298
- # @raise [NoMethodError] if function is not found
299
- #
300
- def call_function(name, *args)
301
- __send__ name, *args
302
- end
303
-
304
- # Returns the current value of the _exporting_ flag
305
- # @return [Boolean] if the resource is marked as _exporting_
306
- def exporting?
307
- @proxy.exporting?
308
- end
309
-
310
- # Returns the current value of the _virtualizing_ flag
311
- # @return [Boolean] if the resource is marked as _virtual_
312
- def virtualizing?
313
- @proxy.virtualizing?
314
- end
315
-
316
- # Sets the _exporting_ flag for one or several resources.
317
- # @see #exporting?
318
- # When called with block, sets exporting flag for all resources created in the block
319
- # Otherwise it sets exported flag for each resource passed as as an argument
320
- # Resource references (e.g. `File['name']`) can be used as arguments.
321
- #
322
- # @example Like this...
323
- # export do
324
- # file "foobar", :ensure => :present
325
- # end
326
- #
327
- # @example Or like this...
328
- # file "foobar", :ensure => :present
329
- # export File["foobar"]
330
- #
331
- # @example Or, this way...
332
- # export file("foobar", :ensure => :present)
333
- #
334
- # @overload export({|| block})
335
- # @overload export(reference, ...)
336
- # @param block [ruby] Ruby DSL statements to execute
337
- # @param reference [ResourceReference] one or more resource references
338
- # @return [void]
339
- #
340
- def export(*args, &block)
341
- if block
342
- begin
343
- @proxy.exporting = true
344
- instance_eval &block
345
- ensure
346
- @proxy.exporting = false
347
- end
348
- else
349
- @proxy.export_resources(args)
350
- end
351
- end
352
-
353
- # Sets the _virtualizing_ flag for one or several resources.
354
- # @see #virtualizing?
355
- # When called with block, sets virtualizing flag for all resources created in the block
356
- # Otherwise it sets virtualizing flag for each resource passed as as an argument
357
- # Resource references (e.g. `File['name']`) can be used as arguments.
358
- #
359
- # @example Like this...
360
- # virtual do
361
- # file "foobar", :ensure => :present
362
- # end
363
- #
364
- # @example Or like this...
365
- # file "foobar", :ensure => :present
366
- # virtual File["foobar"]
367
- #
368
- # @example Or, this way...
369
- # virtual file("foobar", :ensure => :present)
370
- #
371
- # @overload virtual({|| block})
372
- # @overload virtual(reference, ...)
373
- # @param block [ruby] Ruby DSL statements to execute
374
- # @param reference [ResourceReference] one or more resource references
375
- # @return [void]
376
- #
377
- def virtual(*args, &block)
378
- if block
379
- begin
380
- @proxy.virtualizing = true
381
- instance_eval &block
382
- ensure
383
- @proxy.virtualizing = false
384
- end
385
- else
386
- @proxy.virtualize_resources(args)
387
- end
388
- end
389
- end
390
-
391
- end
392
- end
393
-
@@ -1,57 +0,0 @@
1
- module Puppet
2
- # @since 3.1
3
- # @status EXPERIMENTAL
4
- module DSL
5
- # Initializes evaluation of Ruby based manifests.
6
- module Parser
7
-
8
- # @return [Array<Puppet::Parser::Scope>] for access by Puppet::DSL::Context
9
- #
10
- def self.frames
11
- @frames ||= []
12
- end
13
-
14
- class << self
15
- # @return [Puppet::Resource::TypeCollection] Shared known_resource_types object for DSL
16
- #
17
- attr_accessor :known_resource_types
18
- end
19
-
20
- # Creates a new Puppet::DSL::Context and assings it as _ruby_code_ to the
21
- # main object.
22
- # @param main [#ruby_code] where the ruby _code_ is set
23
- # @param code [{|| block}] the ruby code to prepare for evaluation
24
- # @param filename [String] name of file where code originates from
25
- # @return [void]
26
- #
27
- def self.prepare_for_evaluation(main, code, filename = "dsl_main")
28
- block = proc { instance_eval code, filename, 0 }
29
- main.ruby_code << Context.new(block, :filename => filename)
30
- end
31
-
32
- # @return [Puppet::Parser::Scope] the current scope
33
- #
34
- def self.current_scope
35
- frames.last
36
- end
37
-
38
-
39
- # Pushes a new scope on a stack.
40
- # @return [Puppet::Parser::Scope] the given scope
41
- #
42
- def self.add_scope(scope)
43
- frames.push scope
44
- end
45
-
46
- # Pops a scope from the stack.
47
- # @raise [RuntimeError] unless stack has at least one item
48
- #
49
- def self.remove_scope
50
- raise RuntimeError, "scope stack already empty" if @frames.empty?
51
- @frames.pop
52
- end
53
-
54
- end
55
- end
56
- end
57
-