Class: MacSetup::Symlink

Inherits:
Object
  • Object
show all
Defined in:
lib/mac_setup/symlink_installer.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Symlink

Returns a new instance of Symlink.



3
4
5
6
7
# File 'lib/mac_setup/symlink_installer.rb', line 3

def initialize(options)
  @source_path = options[:source_path]
  @file_name = options[:name]
  @target_path = options[:target_path]
end

Instance Method Details



9
10
11
12
13
14
15
16
17
# File 'lib/mac_setup/symlink_installer.rb', line 9

def link
  short_sorce_path = MacSetup.shorten_path(source_path)
  short_target_path = MacSetup.shorten_path(target_path)
  puts "Linking #{short_sorce_path} to #{short_target_path}..."

  return unless source_exists

  target_exists? ? replace : FileUtils.ln_s(source_path, target_path)
end