Class: GitCompound::Component::Destination

Inherits:
Object
  • Object
show all
Defined in:
lib/git_compound/component/destination.rb

Overview

Component destination

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component_path, component) ⇒ Destination

Returns a new instance of Destination.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/git_compound/component/destination.rb', line 10

def initialize(component_path, component)
  raise CompoundSyntaxError, 'Destination cannot be empty' if
    component_path.nil? || component_path.empty?

  raise CompoundSyntaxError,
        'Destination should contain at least one directory' unless
    Pathname.new(component_path).each_filename.count > 0

  @component = component
  @path      = expand_path(component_path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/git_compound/component/destination.rb', line 8

def path
  @path
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/git_compound/component/destination.rb', line 22

def exists?
  FileTest.exist?(@path)
end

#repository {|destination_repository| ... } ⇒ Object

Yields:

  • (destination_repository)


26
27
28
29
30
31
# File 'lib/git_compound/component/destination.rb', line 26

def repository
  destination_repository =
    Repository::RepositoryLocal.new(@path)
  yield destination_repository if block_given?
  destination_repository
end