Class: R10K::Source::Base

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

Overview

This class defines a common interface for source implementations.

Since:

  • 1.3.0

Direct Known Subclasses

Git, Hash, SVN

Constant Summary

Constants included from Logging

Logging::LOG_LEVELS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

debug_formatter, default_formatter, default_outputter, #logger, #logger_name, parse_level

Constructor Details

#initialize(name, basedir, options = {}) ⇒ Base

Initialize the given source.

Parameters:

  • name (String)

    The identifier for this source.

  • basedir (String)

    The base directory where the generated environments will be created.

  • options (Hash) (defaults to: {})

    An additional set of options for this source. The semantics of this hash may depend on the source implementation.

Options Hash (options):

  • :prefix (Boolean, String)

    If a String this becomes the prefix. If true, will use the source name as the prefix. All sources should respect this option. Defaults to false for no environment prefix.

  • :strip_component (String)

    If a string, this value will be removed from the beginning of each generated environment’s name, if present. If the string is contained within two “/” characters, it will be treated as a regular expression.

Since:

  • 1.3.0



42
43
44
45
46
47
48
49
# File 'lib/r10k/source/base.rb', line 42

def initialize(name, basedir, options = {})
  @name    = name
  @basedir = Pathname.new(basedir).cleanpath.to_s
  @prefix  = options.delete(:prefix)
  @strip_component = options.delete(:strip_component)
  @puppetfile_name = options.delete(:puppetfile_name)
  @options = options
end

Instance Attribute Details

#basedirObject (readonly)

Since:

  • 1.3.0



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

def basedir
  @basedir
end

#nameObject (readonly)

Since:

  • 1.3.0



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

def name
  @name
end

#prefixObject (readonly)

Since:

  • 1.3.0



21
22
23
# File 'lib/r10k/source/base.rb', line 21

def prefix
  @prefix
end

#puppetfile_nameObject (readonly)

Since:

  • 1.3.0



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

def puppetfile_name
  @puppetfile_name
end

Instance Method Details

#accept(visitor) ⇒ Object

Since:

  • 1.3.0



86
87
88
89
90
91
92
# File 'lib/r10k/source/base.rb', line 86

def accept(visitor)
  visitor.visit(:source, self) do
    environments.each do |env|
      env.accept(visitor)
    end
  end
end

#environmentsArray<R10K::Environment::Base>

This method is abstract.

Enumerate the environments associated with this SVN source.

Returns:

Raises:

  • (NotImplementedError)

Since:

  • 1.3.0



82
83
84
# File 'lib/r10k/source/base.rb', line 82

def environments
  raise NotImplementedError, _("%{class} has not implemented method %{method}") % {class: self.class, method: __method__}
end

#preload!void

This method is abstract.

This method returns an undefined value.

Perform any actions needed for loading environments that may have side effects.

Actions done during preloading may include things like updating caches or performing network queries. If an environment has not been preloaded but #environments is invoked, it should return the best known state of environments or return an empty list.

Since:

  • 1.3.0



62
63
64
# File 'lib/r10k/source/base.rb', line 62

def preload!

end

#reload!void

This method is abstract.

This method returns an undefined value.

Perform actions to reload environments after the ‘preload!`. Similar to preload!, and likely to include network queries and rerunning environment generation.

Since:

  • 1.3.0



73
74
# File 'lib/r10k/source/base.rb', line 73

def reload!
end