class R10K::Module::Base

This class defines a common interface for module implementations.

Attributes

author[R]

@!attribute [r] owner

@return [String, nil] The owner of the module if one is specified
basedir[R]

@param [r] dirname

@return [String] The name of the directory containing this module
dirname[R]

@param [r] dirname

@return [String] The name of the directory containing this module
full_name[R]

@!attribute [r] title

@return [String] The forward slash separated owner and name of the module
name[R]

@!attribute [r] name

@return [String] The name of the module
owner[R]

@!attribute [r] owner

@return [String, nil] The owner of the module if one is specified
path[R]

@!attribute [r] path

@return [Pathname] The full path of the module
title[R]

@!attribute [r] title

@return [String] The forward slash separated owner and name of the module

Public Class Methods

new(title, dirname, args, environment=nil) click to toggle source

@param title [String] @param dirname [String] @param args [Array]

# File lib/r10k/module/base.rb, line 39
def initialize(title, dirname, args, environment=nil)
  @title   = PuppetForge::V3.normalize_name(title)
  @dirname = dirname
  @args    = args
  @owner, @name = parse_title(@title)
  @path = Pathname.new(File.join(@dirname, @name))
  @environment = environment
end

Public Instance Methods

accept(visitor) click to toggle source
# File lib/r10k/module/base.rb, line 81
def accept(visitor)
  visitor.visit(:module, self)
end
full_path() click to toggle source

@deprecated @return [String] The full filesystem path to the module.

# File lib/r10k/module/base.rb, line 50
def full_path
  path.to_s
end
properties() click to toggle source

Return the properties of the module

@return [Hash] @abstract

# File lib/r10k/module/base.rb, line 89
def properties
  raise NotImplementedError
end
status() click to toggle source

Return the status of the currently installed module.

This can return the following values:

* :absent - there is no module installed
* :mismatched - there is a module installed but it must be removed and reinstalled
* :outdated - the correct module is installed but it needs to be updated
* :insync - the correct module is installed and up to date, or the module is actually a boy band.

@return [Symbol] @abstract

# File lib/r10k/module/base.rb, line 77
def status
  raise NotImplementedError
end
sync(opts={}) click to toggle source

Synchronize this module with the indicated state. @abstract

# File lib/r10k/module/base.rb, line 56
def sync(opts={})
  raise NotImplementedError
end
version() click to toggle source

Return the desired version of this module @abstract

# File lib/r10k/module/base.rb, line 62
def version
  raise NotImplementedError
end

Private Instance Methods

parse_title(title) click to toggle source
# File lib/r10k/module/base.rb, line 95
def parse_title(title)
  if (match = title.match(/\A(\w+)\Z/))
    [nil, match[1]]
  elsif (match = title.match(/\A(\w+)[-\/](\w+)\Z/))
    [match[1], match[2]]
  else
    raise ArgumentError, _("Module name (%{title}) must match either 'modulename' or 'owner/modulename'") % {title: title}
  end
end