Sha256: 5fea3af12040de942cbfa266afa4abe549c18674e9af5ce2a37db6f583be9460

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

module Sprinkle
  module Verifiers
    # = Symlink Verifier
    #
    # Contains a verifier to check the existance of a symbolic link.
    # 
    # == Example Usage
    #
    # First, checking for the existence of a symlink:
    #
    #   verify { has_symlink '/usr/special/secret/pointer' }
    #
    # Second, checking that the symlink points to a specific place:
    #
    #   verify { has_symlink '/usr/special/secret/pointer', '/usr/local/realfile' }
    module Symlink
      Sprinkle::Verify.register(Sprinkle::Verifiers::Symlink)
      
      # Checks that <tt>symlink</tt> is a symbolic link. If <tt>file</tt> is 
      # given, it checks that <tt>symlink</tt> points to <tt>file</tt>
      def has_symlink(symlink, file = nil)
        if RUBY_PLATFORM =~ /win32/
          raise NotImplementedError, "Win32 platform does not support checking for symbolic links"
        else
          if file.nil?
            @commands << "test -L #{symlink}"
          else
            @commands << "test '#{file}' = `readlink #{symlink}`"
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lachlan-sprinkle-0.0.1 lib/sprinkle/verifiers/symlink.rb
lachlan-sprinkle-0.0.2 lib/sprinkle/verifiers/symlink.rb
lachlan-sprinkle-0.0.3 lib/sprinkle/verifiers/symlink.rb
lachlan-sprinkle-0.0.4 lib/sprinkle/verifiers/symlink.rb
lachlan-sprinkle-0.0.5 lib/sprinkle/verifiers/symlink.rb
lachlan-sprinkle-0.0.6 lib/sprinkle/verifiers/symlink.rb
lachlan-sprinkle-0.0.7 lib/sprinkle/verifiers/symlink.rb
lachlan-sprinkle-0.0.8 lib/sprinkle/verifiers/symlink.rb