# class Puppet::ModuleTool::Applications::Installer

### Public Class Methods

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

    # File lib/puppet/module_tool/applications/installer.rb, line 18
    def initialize(name, forge, install_dir, options = {})
      super(options)
      @action              = :install
      @environment         = Puppet::Node::Environment.new(Puppet.settings[:environment])
      @force               = options[:force]
      @ignore_dependencies = options[:force] || options[:ignore_dependencies]
      @name                = name
      @forge               = forge
      @install_dir         = install_dir
    end

### Public Instance Methods

run() click to toggle source

    # File lib/puppet/module_tool/applications/installer.rb, line 29
    def run
      begin
        if is_module_package?(@name)
          @source = :filesystem
          @filename = File.expand_path(@name)
          raise MissingPackageError, :requested_package => @filename unless File.exist?(@filename)

          parsed = parse_filename(@filename)
          @module_name = parsed[:module_name]
          @version     = parsed[:version]
        else
          @source = :repository
          @module_name = @name.gsub('/', '-')
          @version = options[:version]
        end

        results = {
          :module_name    => @module_name,
          :module_version => @version,
          :install_dir    => options[:target_dir],
        }

        @install_dir.prepare(@module_name, @version || 'latest')

        cached_paths = get_release_packages

        unless @graph.empty?
          Puppet.notice 'Installing -- do not interrupt ...'
          cached_paths.each do |hash|
            hash.each do |dir, path|
              Unpacker.new(path, @options.merge(:target_dir => dir)).run
            end
          end
        end
      rescue ModuleToolError, ForgeError => err
        results[:error] = {
          :oneline   => err.message,
          :multiline => err.multiline,
        }
      else
        results[:result] = :success
        results[:installed_modules] = @graph
      ensure
        results[:result] ||= :failure
      end

      results
    end