Class: Wright::Provider::Symlink

Inherits:
Wright::Provider show all
Defined in:
lib/wright/provider/symlink.rb

Overview

Symlink provider. Used as a provider for Resource::Symlink.

Constant Summary

Constants inherited from Wright::Provider

PROVIDER_DIR

Instance Method Summary collapse

Methods inherited from Wright::Provider

#initialize, #updated?

Constructor Details

This class inherits a constructor from Wright::Provider

Instance Method Details

#createvoid

This method returns an undefined value.

Creates or updates the symlink.



12
13
14
15
16
17
18
19
20
21
# File 'lib/wright/provider/symlink.rb', line 12

def create
  fail Errno::EEXIST, link_name_expanded if regular_file?

  symlink = symlink_to_s
  unless_uptodate(:create, "symlink already created: #{symlink}") do
    unless_dry_run("create symlink: #{symlink}") do
      Wright::Util::File.ln_sfn(link_to_expanded, link_name_expanded)
    end
  end
end

#removevoid

This method returns an undefined value.

Removes the symlink.



26
27
28
29
30
31
32
33
34
# File 'lib/wright/provider/symlink.rb', line 26

def remove
  fail "'#{link_name_expanded}' is not a symlink" if regular_file?

  unless_uptodate(:remove, "symlink already removed: '#{link_name}'") do
    unless_dry_run("remove symlink: '#{link_name}'") do
      FileUtils.rm(link_name_expanded)
    end
  end
end