Class: Reflection::Directory::Stash

Inherits:
Directory::Base
  • Object
show all
Defined in:
lib/reflection/directory/stash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository, identifier_prefix) ⇒ Stash

Returns a new instance of Stash.



7
8
9
10
# File 'lib/reflection/directory/stash.rb', line 7

def initialize(repository, identifier_prefix)
  @repository = repository
  @identifier_prefix = identifier_prefix
end

Instance Attribute Details

#repository ⇒ Object

Returns the value of attribute repository.



5
6
7
# File 'lib/reflection/directory/stash.rb', line 5

def repository
  @repository
end

Instance Method Details

#clone_repository ⇒ Object



24
25
26
27
# File 'lib/reflection/directory/stash.rb', line 24

def clone_repository
  Reflection.log.debug "Cloning repository '#{self.repository.url}' to '#{self.path}'"      
  @repository.clone(self.path)
end

#path ⇒ Object



12
13
14
# File 'lib/reflection/directory/stash.rb', line 12

def path
  @path = File.join(Reflection.home.path, @identifier_prefix, repository.identifier)
end

#validate_repository ⇒ Object



16
17
18
19
20
21
22
# File 'lib/reflection/directory/stash.rb', line 16

def validate_repository
  if Reflection::Repository.exists?(self.path) && !@repository.same_in_path?(self.path)
    Reflection::Support.exit_with_error "The stash directory '#{self.path}' is a repository, but not the one you specified (--repository)."
  else
    Reflection.log.debug "Directory '#{self.path}' valid."
  end
end