Class: Reflection::Directory::Base
- Inherits:
-
Object
- Object
- Reflection::Directory::Base
- Defined in:
- lib/reflection/directory/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #clean! ⇒ Object
- #copy_git_index_to(target_path) ⇒ Object
- #exists? ⇒ Boolean
- #get_git_index_from(target_path) ⇒ Object
- #git_index ⇒ Object
-
#initialize(new_path) ⇒ Base
constructor
A new instance of Base.
- #move_content_to(target_path) ⇒ Object
- #name ⇒ Object
- #parent ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(new_path) ⇒ Base
Returns a new instance of Base.
7 8 9 |
# File 'lib/reflection/directory/base.rb', line 7 def initialize(new_path) self.path = new_path end |
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/reflection/directory/base.rb', line 5 def path @path end |
Instance Method Details
#clean! ⇒ Object
19 20 21 22 |
# File 'lib/reflection/directory/base.rb', line 19 def clean! Reflection.log.debug "Cleaning #{self.path}/.." %x(rm -r #{self.path}/*) end |
#copy_git_index_to(target_path) ⇒ Object
36 37 38 39 |
# File 'lib/reflection/directory/base.rb', line 36 def copy_git_index_to(target_path) Reflection.log.debug "Copying git-index '#{self.git_index}' to #{target_path}" %x(cp -R #{self.git_index} #{target_path}) end |
#exists? ⇒ Boolean
15 16 17 |
# File 'lib/reflection/directory/base.rb', line 15 def exists? File.exist?(self.path) end |
#get_git_index_from(target_path) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/reflection/directory/base.rb', line 41 def get_git_index_from(target_path) Reflection.log.debug "Getting git-index from #{target_path}" %x(rm -rf #{self.git_index}) if File.exists?(self.git_index) %x(mkdir -p #{self.path}) %x(mv -f #{File.join(target_path, '/.git')} #{File.join(self.path, "/")}) end |
#git_index ⇒ Object
32 33 34 |
# File 'lib/reflection/directory/base.rb', line 32 def git_index File.(File.join(self.path, '.git')) end |
#move_content_to(target_path) ⇒ Object
49 50 51 52 53 |
# File 'lib/reflection/directory/base.rb', line 49 def move_content_to(target_path) Reflection.log.debug "Moving content to '#{target_path}'.." %x(cp -R #{File.join(self.path, '/.')} #{target_path}) %x(rm -rf #{self.path}) end |
#name ⇒ Object
28 29 30 |
# File 'lib/reflection/directory/base.rb', line 28 def name self.path.split('/').last end |
#parent ⇒ Object
24 25 26 |
# File 'lib/reflection/directory/base.rb', line 24 def parent Base.new(File.(self.path.split('/')[0..-2].join('/'))) end |
#to_s ⇒ Object
11 12 13 |
# File 'lib/reflection/directory/base.rb', line 11 def to_s self.path end |