Class: Librarian::Source::Git::Repository

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

Instance Method Summary collapse

Instance Method Details

#dependenciesObject



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/librarian/puppet/source/git.rb', line 28

def dependencies
  return {} unless modulefile?

   = ::Puppet::ModuleTool::Metadata.new

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

  .dependencies.inject({}) do |h, dependency|
    name = dependency.instance_variable_get(:@full_module_name)
    version = dependency.instance_variable_get(:@version_requirement)
    h.update(name => version)
  end
end

#hash_from(remote, reference) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/librarian/puppet/source/git.rb', line 8

def hash_from(remote, reference)
  branch_names = remote_branch_names[remote]
  if branch_names.include?(reference)
    reference = "#{remote}/#{reference}"
  end

  command = %W(rev-parse #{reference}^{commit} --quiet)
  run!(command, :chdir => true).strip
end

#module_versionObject

Naming this method ‘version’ causes an exception to be raised.



19
20
21
22
23
24
25
26
# File 'lib/librarian/puppet/source/git.rb', line 19

def module_version
  return '0.0.1' unless modulefile?

    = ::Puppet::ModuleTool::Metadata.new
  ::Puppet::ModuleTool::ModulefileReader.evaluate(, modulefile)

  .version
end

#modulefileObject



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

def modulefile
  File.join(path, 'Modulefile')
end

#modulefile?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/librarian/puppet/source/git.rb', line 46

def modulefile?
  File.exists?(modulefile)
end