Class: GitCompound::Component::Source

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/git_compound/component/source.rb

Overview

Component source

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(origin, version, strategy, options, component) ⇒ Source

Returns a new instance of Source.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/git_compound/component/source.rb', line 12

def initialize(origin, version, strategy, options, component)
  raise CompoundSyntaxError, 'Source cannot be empty' if
    origin.nil? || origin.empty?

  @origin     = origin
  @strategy   = strategy
  @options    = options
  @component  = component
  @repository = Repository.factory(@origin)
  @version    = strategy.new(@repository, version)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



10
11
12
# File 'lib/git_compound/component/source.rb', line 10

def options
  @options
end

#originObject (readonly)

Returns the value of attribute origin.



10
11
12
# File 'lib/git_compound/component/source.rb', line 10

def origin
  @origin
end

#repositoryObject (readonly)

Returns the value of attribute repository.



10
11
12
# File 'lib/git_compound/component/source.rb', line 10

def repository
  @repository
end

#versionObject (readonly)

Returns the value of attribute version.



10
11
12
# File 'lib/git_compound/component/source.rb', line 10

def version
  @version
end

Instance Method Details

#clone(destination) ⇒ Object



36
37
38
# File 'lib/git_compound/component/source.rb', line 36

def clone(destination)
  @repository.clone(destination, clone_args)
end

#manifestObject

Loads manifest from source repository



26
27
28
29
30
31
32
33
34
# File 'lib/git_compound/component/source.rb', line 26

def manifest
  raise DependencyError,
        "Version #{@version} unreachable" unless @version.reachable?

  contents = @repository.files_contents(Manifest::FILENAMES, @version.ref)
  Manifest.new(contents, @component)
rescue FileNotFoundError
  Manifest.new(nil, @component)
end