# class Puppet::ModuleTool::Applications::Generator

### Public Class Methods

new(full_module_name, options = {}) click to toggle source
Calls superclass method Puppet::ModuleTool::Applications::Application.new

    # File lib/puppet/module_tool/applications/generator.rb, line 9
    def initialize(full_module_name, options = {})
      begin
        @metadata = Metadata.new(:full_module_name => full_module_name)
      rescue ArgumentError
        raise "Could not generate directory #{full_module_name.inspect}, you must specify a dash-separated username and module name."
      end
      super(options)
    end

### Public Instance Methods

destination() click to toggle source

    # File lib/puppet/module_tool/applications/generator.rb, line 69
    def destination
      @destination ||= Pathname.new(@metadata.dashed_name)
    end

get_binding() click to toggle source

    # File lib/puppet/module_tool/applications/generator.rb, line 22
    def get_binding
      binding
    end

run() click to toggle source

    # File lib/puppet/module_tool/applications/generator.rb, line 26
    def run
      if destination.directory?
        raise ArgumentError, "#{destination} already exists."
      end
      Puppet.notice "Generating module at #{Dir.pwd}/#{@metadata.dashed_name}"
      files_created = []
      skeleton.path.find do |path|
        if path == skeleton
          destination.mkpath
        else
          node = Node.on(path, self)
          if node
            node.install!
            files_created << node.target
          else
            Puppet.notice "Could not generate from #{path}"
          end
        end
      end

      # Return an array of Pathname objects representing file paths of files
      # and directories just generated. This return value is used by the
      # module_tool face generate action, and displayed on the console.
      #
      # Example return value:
      #
      #   [
      #     #<Pathname:puppetlabs-apache>,
      #     #<Pathname:puppetlabs-apache/tests>,
      #     #<Pathname:puppetlabs-apache/tests/init.pp>,
      #     #<Pathname:puppetlabs-apache/spec>,
      #     #<Pathname:puppetlabs-apache/spec/spec_helper.rb>,
      #     #<Pathname:puppetlabs-apache/spec/spec.opts>,
      #     #<Pathname:puppetlabs-apache/README>,
      #     #<Pathname:puppetlabs-apache/Modulefile>,
      #     #<Pathname:puppetlabs-apache/metadata.json>,
      #     #<Pathname:puppetlabs-apache/manifests>,
      #     #<Pathname:puppetlabs-apache/manifests/init.pp"
      #   ]
      #
      files_created
    end

skeleton() click to toggle source

    # File lib/puppet/module_tool/applications/generator.rb, line 18
    def skeleton
      @skeleton ||= Skeleton.new
    end