Parent

Methods

Class Index [+]

Quicksearch

Webgen::Source::TarArchive

This class is used to read source paths from a (gzipped) tar archive. The archive can be remote (http(s) or ftp) or local.

For example, the following are all valid URIs:

  http://example.com/directory/file.tgz
  /home/test/my.tar.gz
  ftp://ftp.example.com/archives/archive.tar

Attributes

uri[R]

The URI of the tar archive.

glob[R]

The glob (see File.fnmatch for details) that is used to specify which paths in the archive should be returned by #.

Public Class Methods

new(uri, glob = '**/*') click to toggle source

Create a new tar archive source for the URI string uri.

    # File lib/webgen/source/tararchive.rb, line 53
53:     def initialize(uri, glob = '**/*')
54:       @uri = uri
55:       @glob = glob
56:     end

Public Instance Methods

paths() click to toggle source

Return all paths in the tar archive available at #.

    # File lib/webgen/source/tararchive.rb, line 59
59:     def paths
60:       if !defined?(@paths)
61:         stream = open(@uri)
62:         stream = Zlib::GzipReader.new(stream) if @uri =~ /(\.tar\.gz|\.tgz)$/
63:         Archive::Tar::Minitar::Input.open(stream) do |input|
64:           @paths = input.collect do |entry|
65:             path = entry.full_name
66:             next unless File.fnmatch(@glob, path, File::FNM_DOTMATCH|File::FNM_CASEFOLD|File::FNM_PATHNAME)
67:             path += '/' if entry.directory? && path[1,1] != '/'
68:             path = '/' + path unless path[0,1] == '/'
69:             Path.new(path, entry.read, Time.at(entry.mtime), @uri)
70:           end.compact.to_set
71:         end
72:       end
73:       @paths
74:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.