Class: MacSetup::Symlink
- Inherits:
-
Object
- Object
- MacSetup::Symlink
- Defined in:
- lib/mac_setup/symlink_installer.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Symlink
constructor
A new instance of Symlink.
- #link ⇒ Object
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() @source_path = [:source_path] @file_name = [:name] @target_path = sanitize_target([:target_path]) end |
Instance Method Details
#link ⇒ Object
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 |