Class: R10K::Source::Base

Inherits:
Object
  • Object
show all
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, SVN

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Since:

  • 1.3.0



29
30
31
32
33
34
# File 'lib/r10k/source/base.rb', line 29

def initialize(name, basedir, options = {})
  @name    = name
  @basedir = basedir
  @prefix  = options.delete(:prefix)
  @options = options
end

Instance Attribute Details

#basedirObject (readonly)

Since:

  • 1.3.0



8
9
10
# File 'lib/r10k/source/base.rb', line 8

def basedir
  @basedir
end

#nameObject (readonly)

Since:

  • 1.3.0



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

def name
  @name
end

#prefixObject (readonly)

Since:

  • 1.3.0



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

def prefix
  @prefix
end

Instance Method Details

#accept(visitor) ⇒ Object

Since:

  • 1.3.0



61
62
63
64
65
66
67
# File 'lib/r10k/source/base.rb', line 61

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



57
58
59
# File 'lib/r10k/source/base.rb', line 57

def environments
  raise NotImplementedError, "#{self.class} has not implemented 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



47
48
49
# File 'lib/r10k/source/base.rb', line 47

def preload!

end