Class: Kiip::Entry
- Inherits:
-
Hashie::Dash
- Object
- Hashie::Dash
- Kiip::Entry
- Defined in:
- lib/kiip/entry.rb
Instance Method Summary collapse
-
#restore ⇒ Object
restores the entry to it’s original place.
- #status ⇒ Object
-
#unlink ⇒ Object
removes the source.
Instance Method Details
#restore ⇒ Object
restores the entry to it’s original place
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/kiip/entry.rb', line 8 def restore remove_source if correct_link? # if file exists, remove or return if File.exist?() cli.agree("#{source} exists. Remove it?") ? remove_source : return end puts "copy #{target} to #{source}" if verbose? FileUtils.copy_entry(target, ) unless dry? end |
#status ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/kiip/entry.rb', line 33 def status return :linked if correct_link? return :symlink if File.symlink?() return :directory if File.directory?() return :file if File.file?() return :not_existent unless File.exist?() raise 'unknown status' end |
#unlink ⇒ Object
removes the source. If source is not a link to target, it asks the users.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/kiip/entry.rb', line 21 def unlink if not File.exist?() cli.say "#{source} does not exist." if [:verbose] return end if correct_link? or cli.agree("#{source} is not a symlink to #{target}. Still remove it?") puts "removing #{source}" if [:verbose] FileUtils.remove_entry(, **) unless [:noop] end end |