Class: GitCompound::Component::Destination
- Inherits:
-
Object
- Object
- GitCompound::Component::Destination
- Defined in:
- lib/git_compound/component/destination.rb
Overview
Component destination
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(component_path, component) ⇒ Destination
constructor
A new instance of Destination.
- #repository {|destination_repository| ... } ⇒ Object
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 = (component_path) end |
Instance Attribute Details
#path ⇒ Object (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
22 23 24 |
# File 'lib/git_compound/component/destination.rb', line 22 def exists? FileTest.exist?(@path) end |
#repository {|destination_repository| ... } ⇒ Object
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 |