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!

Instance Method Details

#cache!Object



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/librarian/puppet/source/git.rb', line 58

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



89
90
91
92
93
# File 'lib/librarian/puppet/source/git.rb', line 89

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



101
102
103
104
105
# File 'lib/librarian/puppet/source/git.rb', line 101

def fetch_dependencies(name, version, extra)
  repository.dependencies.map do |k, v|
    Dependency.new(k, v, forge_source)
  end
end

#fetch_version(name, extra) ⇒ Object



95
96
97
98
99
# File 'lib/librarian/puppet/source/git.rb', line 95

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

#forge_sourceObject



107
108
109
# File 'lib/librarian/puppet/source/git.rb', line 107

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

#vendor_cached?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/librarian/puppet/source/git.rb', line 74

def vendor_cached?
  vendor_tgz.exist?
end

#vendor_checkout!Object



78
79
80
81
82
83
84
85
86
87
# File 'lib/librarian/puppet/source/git.rb', line 78

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



70
71
72
# File 'lib/librarian/puppet/source/git.rb', line 70

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