module Librarian::Puppet::Source::Local
Public Instance Methods
fetch_dependencies(name, version, extra)
click to toggle source
# File lib/librarian/puppet/source/local.rb, line 37 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
fetch_version(name, extra)
click to toggle source
# File lib/librarian/puppet/source/local.rb, line 31 def fetch_version(name, extra) cache! found_path = found_path(name) module_version end
forge_source()
click to toggle source
# File lib/librarian/puppet/source/local.rb, line 54 def forge_source Forge.default end
install!(manifest)
click to toggle source
# File lib/librarian/puppet/source/local.rb, line 9 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? unless name.include? '/' or name.include? '-' warn { "Invalid module name '#{name}', you should qualify it with 'ORGANIZATION-#{name}' for resolution to work correctly" } 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
install_perform_step_copy!(found_path, install_path)
click to toggle source
# File lib/librarian/puppet/source/local.rb, line 102 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
manifest?(name, path)
click to toggle source
# File lib/librarian/puppet/source/local.rb, line 107 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
metadata()
click to toggle source
# File lib/librarian/puppet/source/local.rb, line 86 def metadata File.join(filesystem_path, 'metadata.json') end
metadata?()
click to toggle source
# File lib/librarian/puppet/source/local.rb, line 90 def metadata? File.exist?(metadata) end
module_version()
click to toggle source
Naming this method ‘version’ causes an exception to be raised.
# File lib/librarian/puppet/source/local.rb, line 61 def module_version if parsed_metadata['version'] parsed_metadata['version'] else warn { "Module #{to_s} does not have version, defaulting to 0.0.1" } '0.0.1' end end
parsed_metadata()
click to toggle source
# File lib/librarian/puppet/source/local.rb, line 70 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
specfile()
click to toggle source
# File lib/librarian/puppet/source/local.rb, line 94 def specfile File.join(filesystem_path, environment.specfile_name) end
specfile?()
click to toggle source
# File lib/librarian/puppet/source/local.rb, line 98 def specfile? File.exist?(specfile) end