Class: R10K::Module::Forge

Inherits:
R10K::Module show all
Includes:
Logging
Defined in:
lib/r10k/module/forge.rb

Instance Attribute Summary

Attributes inherited from R10K::Module

#name, #path

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

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

Methods inherited from R10K::Module

#full_path, inherited, new

Constructor Details

#initialize(name, path, args) ⇒ Forge

Returns a new instance of Forge.



18
19
20
21
22
23
24
25
# File 'lib/r10k/module/forge.rb', line 18

def initialize(name, path, args)
  super

  @full_name = name

  @owner, @name = name.split('/')
  @version = SemVer.new(@args)
end

Class Method Details

.implements(name, args) ⇒ Object



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

def self.implements(name, args)
  args.is_a? String and SemVer.valid?(args)
end

Instance Method Details

#sync!(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/r10k/module/forge.rb', line 27

def sync!(options = {})
  return if insync?

  if insync?
    logger.debug1 "Module #{@full_name} already matches version #{@version}"
  elsif File.exist? 
    logger.debug "Module #{@full_name} is installed but doesn't match version #{@version}, upgrading"
    cmd = []
    cmd << 'upgrade'
    cmd << "--version=#{@version}"
    cmd << "--ignore-dependencies"
    cmd << @full_name
    pmt cmd
  else
    logger.debug "Module #{@full_name} is not installed"
    cmd = []
    cmd << 'install'
    cmd << "--version=#{@version}"
    cmd << "--ignore-dependencies"
    cmd << @full_name
    pmt cmd
  end
end