class GitCompound::Component::Destination
Component
destination
Attributes
path[R]
Public Class Methods
new(component_path, component)
click to toggle source
# 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
Public Instance Methods
exists?()
click to toggle source
# File lib/git_compound/component/destination.rb, line 22 def exists? FileTest.exist?(@path) end
repository() { |destination_repository| ... }
click to toggle source
# 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
Private Instance Methods
expand_path(component_path)
click to toggle source
# File lib/git_compound/component/destination.rb, line 35 def expand_path(component_path) pathname = Pathname.new(component_path) unless pathname.absolute? ancestor_paths = @component.ancestors.map(&:path) pathname = Pathname.new('.').join(*ancestor_paths) + pathname end Pathname.new("./#{pathname}").cleanpath.to_s + '/' end