# class FileServing::Mount::File

### Public Class Methods

localmap() click to toggle source

    # File lib/puppet/file_serving/mount/file.rb, line 4
    def self.localmap
      @localmap ||= {
        "h" => Facter.value("hostname"),
        "H" => [
                 Facter.value("hostname"),
                 Facter.value("domain")
               ].join("."),
        "d" => Facter.value("domain")
      }
    end

### Public Instance Methods

complete_path(relative_path, node) click to toggle source

    # File lib/puppet/file_serving/mount/file.rb, line 15
    def complete_path(relative_path, node)
      full_path = path(node)

      raise ArgumentError.new("Mounts without paths are not usable") unless full_path

      # If there's no relative path name, then we're serving the mount itself.
      return full_path unless relative_path

      file = ::File.join(full_path, relative_path)

      if !(FileTest.exist?(file) or FileTest.symlink?(file))
        Puppet.info("File does not exist or is not accessible: #{file}")
        return nil
      end

      file
    end

find(short_file, request) click to toggle source

Return an instance of the appropriate class.

    # File lib/puppet/file_serving/mount/file.rb, line 34
    def find(short_file, request)
      complete_path(short_file, request.node)
    end

path(node = nil) click to toggle source

Return the path as appropriate, expanding as necessary.

    # File lib/puppet/file_serving/mount/file.rb, line 39
    def path(node = nil)
      if expandable?
        return expand(@path, node)
      else
        return @path
      end
    end

path=(path) click to toggle source

Set the path.

    # File lib/puppet/file_serving/mount/file.rb, line 48
    def path=(path)
      # FIXME: For now, just don't validate paths with replacement
      # patterns in them.
      if path =~ /%./
        # Mark that we're expandable.
        @expandable = true
      else
        raise ArgumentError, "#{path} does not exist or is not a directory" unless FileTest.directory?(path)
        raise ArgumentError, "#{path} is not readable" unless FileTest.readable?(path)
        @expandable = false
      end
      @path = path
    end

search(path, request) click to toggle source

    # File lib/puppet/file_serving/mount/file.rb, line 62
    def search(path, request)
      return nil unless path = complete_path(path, request.node)
      [path]
    end

validate() click to toggle source

Verify our configuration is valid. This should really check to make sure at least someone will be allowed, but, eh.

    # File lib/puppet/file_serving/mount/file.rb, line 69
    def validate
      raise ArgumentError.new("Mounts without paths are not usable") if @path.nil?
    end