Class: Kiip::Tasks::SymlinkTask

Inherits:
Hashie::Dash
  • Object
show all
Includes:
Hashie::Extensions::Dash::PropertyTranslation
Defined in:
lib/kiip/tasks/symlink_task.rb

Overview

basic task, just does symlinks. More might follow

Instance Method Summary collapse

Instance Method Details

#exec!Object

actually execute the task



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/kiip/tasks/symlink_task.rb', line 22

def exec!
  return initialize! unless File.exists? target

  if File.symlink? source
    if File.readlink(source) == target
      puts "#{source} already linked" if is_verbose
      return
    end

    if cli.agree "#{source} already exists, linking to #{File.readlink(source)}. Replace?"
      remove_source
    end
  end


  return create_symlink_from_source_to_target unless File.exists? source

  if cli.agree "#{source} already exists. Replace with symlink?"
    remove_source
    create_symlink_from_source_to_target
  end
end