Sha256: d45387839dd5164c4d4ea0c8e9172621baa1644daefbc12be3df8ddec88ab196

Contents?: true

Size: 1.22 KB

Versions: 39

Compression:

Stored size: 1.22 KB

Contents

module Puppet
  module ModuleTool
    # Control the install location for modules.
    class InstallDirectory
      include Puppet::ModuleTool::Errors

      def initialize(target_directory)
        @target_directory = target_directory
      end

      # prepare the module install location. This will create the location if
      # needed.
      def prepare(module_name, version)
        return if @target_directory.directory?

        begin
          @target_directory.mkpath
          Puppet.notice "Created target directory #{@target_directory}"
        rescue SystemCallError => orig_error
          raise converted_to_friendly_error(module_name, version, orig_error)
        end
      end

    private

      ERROR_MAPPINGS = {
        Errno::EACCES => PermissionDeniedCreateInstallDirectoryError,
        Errno::EEXIST => InstallPathExistsNotDirectoryError,
      }

      def converted_to_friendly_error(module_name, version, orig_error)
        return orig_error if not ERROR_MAPPINGS.include?(orig_error.class)

        ERROR_MAPPINGS[orig_error.class].new(orig_error,
          :requested_module  => module_name,
          :requested_version => version,
          :directory         => @target_directory.to_s)
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
puppet-3.4.3 lib/puppet/module_tool/install_directory.rb
puppet-3.4.2 lib/puppet/module_tool/install_directory.rb
puppet-3.4.1 lib/puppet/module_tool/install_directory.rb
puppet-3.4.0 lib/puppet/module_tool/install_directory.rb
puppet-3.4.0.rc2 lib/puppet/module_tool/install_directory.rb
puppet-3.4.0.rc1 lib/puppet/module_tool/install_directory.rb
puppet-3.3.2 lib/puppet/module_tool/install_directory.rb
puppet-3.3.1 lib/puppet/module_tool/install_directory.rb
puppet-3.3.1.rc3 lib/puppet/module_tool/install_directory.rb
puppet-3.3.1.rc2 lib/puppet/module_tool/install_directory.rb
puppet-3.3.1.rc1 lib/puppet/module_tool/install_directory.rb
puppet-3.3.0 lib/puppet/module_tool/install_directory.rb
puppet-3.3.0.rc3 lib/puppet/module_tool/install_directory.rb
puppet-3.3.0.rc2 lib/puppet/module_tool/install_directory.rb
puppet-3.2.4 lib/puppet/module_tool/install_directory.rb
puppet-3.2.3 lib/puppet/module_tool/install_directory.rb
puppet-3.2.3.rc1 lib/puppet/module_tool/install_directory.rb
puppet-3.2.2 lib/puppet/module_tool/install_directory.rb
puppet-3.2.1 lib/puppet/module_tool/install_directory.rb
puppet-3.2.1.rc1 lib/puppet/module_tool/install_directory.rb