Sha256: 61aa790182a6e56a2a35bcef5b8f1903aec1b77289c9ef403d61f6329e4784d1

Contents?: true

Size: 1.71 KB

Versions: 5

Compression:

Stored size: 1.71 KB

Contents

module Librarian
  module Puppet
    module Source
      module Local

        def install!(manifest)
          manifest.source == self or raise ArgumentError

          debug { "Installing #{manifest}" }

          name, version = manifest.name, manifest.version
          found_path = found_path(name)
          raise Error, "Path for #{name} doesn't contain a puppet module" if found_path.nil?

          if name.include? '/'
            new_name = name.split('/').last
            debug { "Invalid module name '#{name}', guessing you meant '#{new_name}'" }
            name = new_name
          end

          install_path = environment.install_path.join(name)
          if install_path.exist?
            debug { "Deleting #{relative_path_to(install_path)}" }
            install_path.rmtree
          end

          install_perform_step_copy!(found_path, install_path)
        end

        def fetch_version(name, extra)
          cache!
          found_path = found_path(name)
          '0.0.1'
        end

        def fetch_dependencies(name, version, extra)
          {}
        end

      private

        def install_perform_step_copy!(found_path, install_path)
          debug { "Copying #{relative_path_to(found_path)} to #{relative_path_to(install_path)}" }
          FileUtils.cp_r(found_path, install_path, :preserve => true)
        end

        def manifest?(name, path)
          return true if path.join('manifests').exist?
          return true if path.join('lib').join('puppet').exist?
          return true if path.join('lib').join('facter').exist?
          debug { "Could not find manifests, lib/puppet or lib/facter under #{path}, assuming is not a puppet module" }
          false
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
librarian-puppet-maestrodev-0.9.11.5 lib/librarian/puppet/source/local.rb
librarian-puppet-maestrodev-0.9.11.4 lib/librarian/puppet/source/local.rb
librarian-puppet-maestrodev-0.9.11.3 lib/librarian/puppet/source/local.rb
librarian-puppet-maestrodev-0.9.11.2 lib/librarian/puppet/source/local.rb
librarian-puppet-maestrodev-0.9.11.1 lib/librarian/puppet/source/local.rb