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
41
42
43
44
45
# File 'lib/librarian/puppet/source/git.rb', line 28

def dependencies
  return {} unless modulefile? or puppetfile?
  
  if modulefile?
     = ::Puppet::ModuleTool::Metadata.new

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

    .dependencies.map do |dependency|
      name = dependency.instance_variable_get(:@full_module_name)
      version = dependency.instance_variable_get(:@version_requirement) || ">=0"
      v = Librarian::Puppet::Requirement.new(version).gem_requirement
      Dependency.new(name, v, forge_source)
    end
  elsif puppetfile?
    Librarian::Puppet::Environment.new(:project_path => path).specfile.read.dependencies
  end
end

#forge_sourceObject



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

def forge_source
  Librarian::Puppet::Source::Forge.from_lock_options(environment, :remote=>"http://forge.puppetlabs.com")
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



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

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

#modulefile?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/librarian/puppet/source/git.rb', line 51

def modulefile?
  File.exists?(modulefile)
end

#puppetfile?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/librarian/puppet/source/git.rb', line 55

def puppetfile?
  File.exists?(File.join(path, 'Puppetfile'))
end