[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Jesse Wolfe jes5199 at gmail.com
Tue May 10 07:59:20 UTC 2011


The following commit has been merged in the experimental branch:
commit e6c829617ccc120e04f945e8714f792ce29c284d
Merge: 7bdbd132634f61d91aeee401de15248d936ce71e 6b278503021c4404904f56ced6995d0fbfa5b8fe
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Tue Oct 5 11:43:32 2010 -0700

    Merge remote branch 'paul/ticket/next/4657' into next
    
    This patch conflicts with a backport of itself. This merge resolution
    favors the original patch for the code changes, and the 2.6.2 patch for
    the specs.
    
    Manually Resolved Conflicts:
    	lib/puppet/dsl/resource_type_api.rb
    	lib/puppet/parser/ast/definition.rb
    	lib/puppet/parser/parser_support.rb
    	spec/integration/parser/ruby_manifest_spec.rb
    	spec/unit/dsl/resource_type_api_spec.rb

diff --combined lib/puppet/parser/ast/definition.rb
index 287845a,985f8f2..c43422f
--- a/lib/puppet/parser/ast/definition.rb
+++ b/lib/puppet/parser/ast/definition.rb
@@@ -1,14 -1,15 +1,17 @@@
  require 'puppet/parser/ast/top_level_construct'
  
  class Puppet::Parser::AST::Definition < Puppet::Parser::AST::TopLevelConstruct
 +  attr_accessor :context
 +
-   def initialize(name, context = {})
+   def initialize(name, context = {}, &ruby_code)
      @name = name
      @context = context
+     @ruby_code = ruby_code
    end
  
    def instantiate(modname)
-     return [Puppet::Resource::Type.new(:definition, @name, @context.merge(:module_name => modname))]
+     new_definition = Puppet::Resource::Type.new(:definition, @name, @context.merge(:module_name => modname))
+     new_definition.ruby_code = @ruby_code if @ruby_code
+     [new_definition]
    end
  end
diff --combined lib/puppet/parser/ast/node.rb
index 4951a63,9767399..b69a5c4
--- a/lib/puppet/parser/ast/node.rb
+++ b/lib/puppet/parser/ast/node.rb
@@@ -1,17 -1,20 +1,20 @@@
  require 'puppet/parser/ast/top_level_construct'
  
  class Puppet::Parser::AST::Node < Puppet::Parser::AST::TopLevelConstruct
 -  attr_accessor :names
 +  attr_accessor :names, :context
  
-   def initialize(names, context = {})
+   def initialize(names, context = {}, &ruby_code)
      raise ArgumentError, "names should be an array" unless names.is_a? Array
      @names = names
      @context = context
+     @ruby_code = ruby_code
    end
  
    def instantiate(modname)
      @names.collect do |name|
-       Puppet::Resource::Type.new(:node, name, @context.merge(:module_name => modname))
+       new_node = Puppet::Resource::Type.new(:node, name, @context.merge(:module_name => modname))
+       new_node.ruby_code = @ruby_code if @ruby_code
+       new_node
      end
    end
  end
diff --combined lib/puppet/parser/parser_support.rb
index 288abb5,a9df33f..16cd0ee
--- a/lib/puppet/parser/parser_support.rb
+++ b/lib/puppet/parser/parser_support.rb
@@@ -29,9 -29,18 +29,9 @@@ class Puppet::Parser::Parse
      message
    end
  
 -  # Create an AST array out of all of the args
 -  def aryfy(*args)
 -    if args[0].instance_of?(AST::ASTArray)
 -      result = args.shift
 -      args.each { |arg|
 -        result.push arg
 -      }
 -    else
 -      result = ast AST::ASTArray, :children => args
 -    end
 -
 -    result
 +  # Create an AST array containing a single element
 +  def aryfy(arg)
 +    ast AST::ASTArray, :children => [arg]
    end
  
    # Create an AST object, and automatically add the file and line information if
@@@ -59,13 -68,13 +59,13 @@@
    end
  
    # Raise a Parse error.
 -  def error(message)
 +  def error(message, options = {})
      if brace = @lexer.expected
        message += "; expected '%s'"
      end
      except = Puppet::ParseError.new(message)
 -    except.line = @lexer.line
 -    except.file = @lexer.file if @lexer.file
 +    except.line = options[:line] || @lexer.line
 +    except.file = options[:file] || @lexer.file
  
      raise except
    end
@@@ -102,7 -111,7 +102,7 @@@
    end
  
    def import(file)
 -    known_resource_types.loader.import_if_possible(file, @lexer.file)
 +    known_resource_types.loader.import(file, @lexer.file)
    end
  
    def initialize(env)
@@@ -146,8 -155,7 +146,7 @@@
    # how should I do error handling here?
    def parse(string = nil)
      if self.file =~ /\.rb$/
-       parse_ruby_file
-       main = nil
+       main = parse_ruby_file
      else
        self.string = string if string
        begin
@@@ -189,7 -197,11 +188,11 @@@
    def parse_ruby_file
      # Execute the contents of the file inside its own "main" object so
      # that it can call methods in the resource type API.
-     Puppet::DSL::ResourceTypeAPI.new.instance_eval(File.read(self.file))
+     main_object = Puppet::DSL::ResourceTypeAPI.new
+     main_object.instance_eval(File.read(self.file))
+ 
+     # Then extract any types that were created.
+     Puppet::Parser::AST::ASTArray.new :children => main_object.instance_eval { @__created_ast_objects__ }
    end
  
    def string=(string)

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list