Class: Gesund::Checks::Link

Inherits:
Object
  • Object
show all
Includes:
Gesund::Check
Defined in:
lib/gesund/checks/link.rb

Instance Attribute Summary

Attributes included from Gesund::Check

#message, #success

Instance Method Summary collapse

Methods included from Gesund::Check

#call, #fail, #pass

Constructor Details

#initialize(linkname, target = nil) ⇒ Link

Returns a new instance of Link.



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/gesund/checks/link.rb', line 3

def initialize(linkname, target=nil)
  if not File.symlink?(linkname)
    self.success = false
    self.message = "Symbolic link #{linkname} is not a symlink"
  elsif target
    self.success = (File.readlink(linkname) == target)
    self.message = "Symbolic link somelink-xxx is#{self.success ? '' : ' not'} targetting #{target}"
  else
    self.success = true
    self.message = "Symbolic link #{linkname} is a symlink"
  end
end