Class: Librarian::Puppet::Source::Git

Inherits:
Source::Git show all
Includes:
Local
Defined in:
lib/librarian/puppet/source/git.rb

Instance Method Summary collapse

Methods included from Local

#install!

Methods inherited from Source::Git

#hash

Instance Method Details

#cache!Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/librarian/puppet/source/git.rb', line 26

def cache!
  return vendor_checkout! if vendor_cached?

  if environment.local?
    raise Error, "Could not find a local copy of #{uri} at #{sha}."
  end

  super

  cache_in_vendor(repository.path) if environment.vendor?
end

#cache_in_vendor(tmp_path) ⇒ Object



57
58
59
60
61
# File 'lib/librarian/puppet/source/git.rb', line 57

def cache_in_vendor(tmp_path)
  Dir.chdir(tmp_path.to_s) do
    %x{git archive #{sha} | gzip > #{vendor_tgz}}
  end
end

#fetch_dependencies(name, version, extra) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/librarian/puppet/source/git.rb', line 69

def fetch_dependencies(name, version, extra)
  dependencies = []

  if modulefile?
     = ::Puppet::ModuleTool::Metadata.new

    ::Puppet::ModuleTool::ModulefileReader.evaluate(, modulefile)

    .dependencies.each do |dependency|
      name = dependency.instance_variable_get(:@full_module_name)
      version = dependency.instance_variable_get(:@version_requirement)
      gem_requirement = Requirement.new(version).gem_requirement
      dependencies.push Dependency.new(name, gem_requirement, forge_source)
    end
  end

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

  dependencies
end

#fetch_version(name, extra) ⇒ Object



63
64
65
66
67
# File 'lib/librarian/puppet/source/git.rb', line 63

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

#forge_sourceObject



93
94
95
# File 'lib/librarian/puppet/source/git.rb', line 93

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

#vendor_cached?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/librarian/puppet/source/git.rb', line 42

def vendor_cached?
  vendor_tgz.exist?
end

#vendor_checkout!Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/librarian/puppet/source/git.rb', line 46

def vendor_checkout!
  repository.path.rmtree if repository.path.exist?
  repository.path.mkpath

  Dir.chdir(repository.path.to_s) do
    %x{tar xzf #{vendor_tgz}}
  end

  repository_cached!
end

#vendor_tgzObject



38
39
40
# File 'lib/librarian/puppet/source/git.rb', line 38

def vendor_tgz
  environment.vendor_source + "#{sha}.tar.gz"
end