Class: R10K::Module::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/r10k/module/base.rb

Overview

This class defines a common interface for module implementations.

Direct Known Subclasses

Forge, Git, Local, SVN

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, dirname, args, environment = nil) ⇒ Base

Returns a new instance of Base.

Parameters:

  • title (String)
  • dirname (String)
  • args (Array)


47
48
49
50
51
52
53
54
55
# File 'lib/r10k/module/base.rb', line 47

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
  @origin = 'external' # Expect Puppetfile or R10k::Environment to set this to a specific value
end

Instance Attribute Details

#dirnameObject (readonly) Also known as: basedir

Parameters:

  • dirname (r)

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



17
18
19
# File 'lib/r10k/module/base.rb', line 17

def dirname
  @dirname
end

#environmentObject (readonly)

Returns the value of attribute environment.



32
33
34
# File 'lib/r10k/module/base.rb', line 32

def environment
  @environment
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/r10k/module/base.rb', line 13

def name
  @name
end

#originString

Returns Where the module was sourced from. E.g., “Puppetfile”.

Returns:

  • (String)

    Where the module was sourced from. E.g., “Puppetfile”



36
37
38
# File 'lib/r10k/module/base.rb', line 36

def origin
  @origin
end

#ownerObject (readonly) Also known as: author

Returns the value of attribute owner.



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

def owner
  @owner
end

#pathObject (readonly)

Returns the value of attribute path.



28
29
30
# File 'lib/r10k/module/base.rb', line 28

def path
  @path
end

#titleObject (readonly) Also known as: full_name

Returns the value of attribute title.



9
10
11
# File 'lib/r10k/module/base.rb', line 9

def title
  @title
end

Instance Method Details

#accept(visitor) ⇒ Object



90
91
92
# File 'lib/r10k/module/base.rb', line 90

def accept(visitor)
  visitor.visit(:module, self)
end

#full_pathString

Deprecated.

Returns The full filesystem path to the module.

Returns:

  • (String)

    The full filesystem path to the module.



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

def full_path
  path.to_s
end

#propertiesHash

This method is abstract.

Return the properties of the module

Returns:

  • (Hash)

Raises:

  • (NotImplementedError)


98
99
100
# File 'lib/r10k/module/base.rb', line 98

def properties
  raise NotImplementedError
end

#statusSymbol

This method is abstract.

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.

Returns:

  • (Symbol)

Raises:

  • (NotImplementedError)


86
87
88
# File 'lib/r10k/module/base.rb', line 86

def status
  raise NotImplementedError
end

#sync(opts = {}) ⇒ Object

This method is abstract.

Synchronize this module with the indicated state.

Raises:

  • (NotImplementedError)


65
66
67
# File 'lib/r10k/module/base.rb', line 65

def sync(opts={})
  raise NotImplementedError
end

#versionObject

This method is abstract.

Return the desired version of this module

Raises:

  • (NotImplementedError)


71
72
73
# File 'lib/r10k/module/base.rb', line 71

def version
  raise NotImplementedError
end