module Librarian::Puppet::Source::Local
Public Instance Methods
Source
# File lib/librarian/puppet/source/local.rb, line 42 def fetch_dependencies(name, _version, _extra) dependencies = Set.new if specfile? spec = environment.dsl(Pathname(specfile)) dependencies.merge spec.dependencies end parsed_metadata['dependencies'].each do |d| gem_requirement = Librarian::Dependency::Requirement.new(d['version_requirement']).to_gem_requirement new_dependency = Dependency.new(d['name'], gem_requirement, forge_source, name) dependencies << new_dependency end dependencies end
Source
# File lib/librarian/puppet/source/local.rb, line 36 def fetch_version(name, _extra) cache! found_path(name) module_version end
Source
# File lib/librarian/puppet/source/local.rb, line 59 def forge_source Forge.default end
Source
# File lib/librarian/puppet/source/local.rb, line 11 def install!(manifest) manifest.source == self or raise ArgumentError debug { "Installing #{manifest}" } name = manifest.name _ = manifest.version found_path = found_path(name) raise Error, "Path for #{name} doesn't contain a puppet module" if found_path.nil? unless name.include? '/' or name.include? '-' warn do "Invalid module name '#{name}', you should qualify it with 'ORGANIZATION-#{name}' for resolution to work correctly" end end install_path = environment.install_path.join(module_name(name)) if install_path.exist? && rsync? != true debug { "Deleting #{relative_path_to(install_path)}" } install_path.rmtree end install_perform_step_copy!(found_path, install_path) end
Private Instance Methods
Source
# File lib/librarian/puppet/source/local.rb, line 107 def install_perform_step_copy!(found_path, install_path) debug { "Copying #{relative_path_to(found_path)} to #{relative_path_to(install_path)}" } cp_r(found_path, install_path) end
Source
# File lib/librarian/puppet/source/local.rb, line 112 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}, maybe it is not a puppet module" } true end
Source
# File lib/librarian/puppet/source/local.rb, line 91 def metadata File.join(filesystem_path, 'metadata.json') end
Source
# File lib/librarian/puppet/source/local.rb, line 95 def metadata? File.exist?(metadata) end
Source
# File lib/librarian/puppet/source/local.rb, line 66 def module_version if parsed_metadata['version'] parsed_metadata['version'] else warn { "Module #{self} does not have version, defaulting to 0.0.1" } '0.0.1' end end
Naming this method ‘version’ causes an exception to be raised.
Source
# File lib/librarian/puppet/source/local.rb, line 75 def parsed_metadata if @metadata.nil? @metadata = if metadata? begin JSON.parse(File.read(metadata)) rescue JSON::ParserError => e raise Error, "Unable to parse json file #{metadata}: #{e}" end else {} end @metadata['dependencies'] ||= [] end @metadata end
Source
# File lib/librarian/puppet/source/local.rb, line 99 def specfile File.join(filesystem_path, environment.specfile_name) end
Source
# File lib/librarian/puppet/source/local.rb, line 103 def specfile? File.exist?(specfile) end