Class: R10K::Root

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/r10k/root.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

formatter, included, level, level=, #logger, outputter

Constructor Details

#initialize(hash) ⇒ Root

Returns a new instance of Root.



26
27
28
# File 'lib/r10k/root.rb', line 26

def initialize(hash)
  parse_initialize_hash(hash)
end

Instance Attribute Details

#basedirObject (readonly)

Returns the value of attribute basedir.



16
17
18
# File 'lib/r10k/root.rb', line 16

def basedir
  @basedir
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/r10k/root.rb', line 12

def name
  @name
end

#refObject (readonly)

Returns the value of attribute ref.



24
25
26
# File 'lib/r10k/root.rb', line 24

def ref
  @ref
end

#remoteObject (readonly)

Returns the value of attribute remote.



20
21
22
# File 'lib/r10k/root.rb', line 20

def remote
  @remote
end

Instance Method Details

#full_pathObject



59
60
61
# File 'lib/r10k/root.rb', line 59

def full_path
  @full_path ||= File.expand_path(File.join @basedir, @name)
end

#modulesObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/r10k/root.rb', line 44

def modules
  librarian = R10K::Librarian.new("#{full_path}/Puppetfile")

  module_data = librarian.load

  @modules = module_data.map do |mod|
    name = mod[0]
    args = mod[1]
    R10K::Module.new(name, "#{full_path}/modules", args)
  end
rescue Errno::ENOENT
  logger.warn "#{self}: #{full_path} does not exist, cannot enumerate modules."
  []
end

#sync!(options = {}) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/r10k/root.rb', line 30

def sync!(options = {})
  synchro = R10K::Synchro::Git.new(@remote)
  recursive_needed = !(synchro.cloned?(full_path))
  synchro.sync(full_path, @ref, options)

  sync_modules!(options) if recursive_needed
end

#sync_modules!(options = {}) ⇒ Object



38
39
40
41
42
# File 'lib/r10k/root.rb', line 38

def sync_modules!(options = {})
  modules.each do |mod|
    mod.sync!(options)
  end
end