Class: Librarian::Puppet::Source::Repo

Inherits:
Object
  • Object
show all
Defined in:
lib/librarian/puppet/source/repo.rb

Direct Known Subclasses

Forge::Repo, GitHubTarball::Repo

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, name) ⇒ Repo

Returns a new instance of Repo.



10
11
12
13
# File 'lib/librarian/puppet/source/repo.rb', line 10

def initialize(source, name)
  self.source = source
  self.name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/librarian/puppet/source/repo.rb', line 7

def name
  @name
end

#sourceObject

Returns the value of attribute source.



7
8
9
# File 'lib/librarian/puppet/source/repo.rb', line 7

def source
  @source
end

Instance Method Details

#cache_pathObject



19
20
21
# File 'lib/librarian/puppet/source/repo.rb', line 19

def cache_path
  @cache_path ||= source.cache_path.join(name)
end

#environmentObject



15
16
17
# File 'lib/librarian/puppet/source/repo.rb', line 15

def environment
  source.environment
end

#vendored?(name, version) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/librarian/puppet/source/repo.rb', line 35

def vendored?(name, version)
  vendored_path(name, version).exist?
end

#vendored_path(name, version) ⇒ Object



39
40
41
# File 'lib/librarian/puppet/source/repo.rb', line 39

def vendored_path(name, version)
  environment.vendor_cache.join("#{name}-#{version}.tar.gz")
end

#version_unpacked_cache_path(version) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/librarian/puppet/source/repo.rb', line 23

def version_unpacked_cache_path(version)
  if environment.use_short_cache_path
    # Take only the first 7 digits of the SHA1 checksum of the
    # module name + version
    # (short Git commit hash approach)
    dir = Digest::SHA1.hexdigest("#{name}-#{version.to_s}")[0..6]
    source.cache_path.join(dir)
  else
    cache_path.join(version.to_s)
  end
end