Class URI::File
In: lib/uri/file.rb
Parent: GenericEx

Methods

checkout   commit   fingerprint   new   save   to_s  

Constants

COMPONENT = [ :scheme, :path

Public Class methods

[Source]

# File lib/uri/file.rb, line 20
    def initialize ( *args )
      super
      unless @host.nil? or @host.empty?
        raise ArgumentError,
          "You cannot neither setup a host (#{@host}), nor a relative path"
      end
    end

Public Instance methods

[Source]

# File lib/uri/file.rb, line 28
    def checkout
      p = pathname
      raise CheckoutError, to_s unless p.exist?
      [p, nil]
    end

[Source]

# File lib/uri/file.rb, line 34
    def commit ( aPath )
      aPath.cp_r(self.pathname)
    end

[Source]

# File lib/uri/file.rb, line 51
    def fingerprint
      digest = Digest::MD5.new
      if pathname.directory?
        pathname.find do |path|
          next if path.directory? or not path.readable?
          digest << path.read
        end
      else
        digest << pathname.read
      end
      digest.to_s
    end

[Source]

# File lib/uri/file.rb, line 38
    def save
      p = pathname
      raise SaveError, to_s unless p.exist?
      if p.directory?
        out = TempPath.new('save', "#{p.basename}.tar.gz")
        shell! { tar 'czf', out, p }
      else
        out = TempPath.new('save', "#{p.basename}.gz")
        shell! { gzip('-c', p) > out }
      end
      [out, nil]
    end

[Source]

# File lib/uri/file.rb, line 64
    def to_s
      super.sub(/^(file:\/)([^\/])/, '\1//\2')
    end

[Validate]