Module: Librarian::Puppet::Source::Local

Includes:
Util
Included in:
Git, Path
Defined in:
lib/librarian/puppet/source/local.rb

Instance Method Summary collapse

Methods included from Util

#clean_uri, #cp_r, #debug, #info, #normalize_name, #warn

Instance Method Details

#fetch_dependencies(name, version, extra) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/librarian/puppet/source/local.rb', line 48

def fetch_dependencies(name, version, extra)
  dependencies = Set.new

  if modulefile?
    evaluate_modulefile(modulefile).dependencies.each do |dependency|
      dependency_name = dependency.instance_variable_get(:@full_module_name)
      version = dependency.instance_variable_get(:@version_requirement)
      gem_requirement = Requirement.new(version).gem_requirement
      dependencies << Dependency.new(dependency_name, gem_requirement, forge_source)
    end
  end

  if specfile?
    spec = environment.dsl(Pathname(specfile))
    dependencies.merge spec.dependencies
  end

  dependencies
end

#fetch_version(name, extra) ⇒ Object



42
43
44
45
46
# File 'lib/librarian/puppet/source/local.rb', line 42

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

#forge_sourceObject



68
69
70
# File 'lib/librarian/puppet/source/local.rb', line 68

def forge_source
  Forge.from_lock_options(environment, :remote=>"http://forge.puppetlabs.com")
end

#install!(manifest) ⇒ Object

Raises:

  • (Error)


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/librarian/puppet/source/local.rb', line 20

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(name.split('-').last)
  if install_path.exist?
    debug { "Deleting #{relative_path_to(install_path)}" }
    install_path.rmtree
  end

  install_perform_step_copy!(found_path, install_path)
end