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.



5
6
7
8
9
# File 'lib/mac_setup/symlink_installer.rb', line 5

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

Instance Method Details



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mac_setup/symlink_installer.rb', line 11

def link
  return if Secrets.encrypted?(source_path)

  short_source_path = MacSetup.shorten_path(source_path)
  short_target_path = MacSetup.shorten_path(target_path)
  MacSetup.log "Linking #{short_source_path} to #{short_target_path}..."

  return unless source_exists

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