Module: Archive
- Defined in:
- lib/archive.rb,
lib/archive/extract.rb,
lib/archive/version.rb,
lib/archive/compress.rb,
lib/archive/libarchive.rb
Overview
:nodoc:
Defined Under Namespace
Modules: LibArchive Classes: Compress, Extract, Stat
Constant Summary collapse
- VERSION =
"0.0.6"
Class Method Summary collapse
-
.compress(filename, dir = Dir.pwd, args = { :type => :tar, :compression => :gzip }) ⇒ Object
Compress a directory’s files into the filename provided.
-
.compress_and_print(filename, dir = Dir.pwd, args = { :type => :tar, :compression => :gzip }) ⇒ Object
Similar to ::compress, but outputs the files it’s compressing.
-
.extract(filename, dir = Dir.pwd) ⇒ Object
Extract a file into a directory.
-
.extract_and_print(filename, dir = Dir.pwd) ⇒ Object
Just like ::extract, but prints the filenames extracted to stdout.
Class Method Details
.compress(filename, dir = Dir.pwd, args = { :type => :tar, :compression => :gzip }) ⇒ Object
Compress a directory’s files into the filename provided. The default directory is the current directory.
args is a hash that contains two values, :type and :compression.
-
:type may be :tar or :zip
-
:compression may be :gzip, :bzip2, or nil (no compression)
If the type :zip is selected, no compression will be used. Additionally, files in the .zip will all be stored as binary files.
No files in your directory that are not *real files* will be added to the archive.
See Archive::Compress for more information, and a way to compress just the files you want.
52 53 54 |
# File 'lib/archive.rb', line 52 def self.compress(filename, dir=Dir.pwd, args={ :type => :tar, :compression => :gzip }) Archive::Compress.new(filename, args).compress(get_files(dir)) end |
.compress_and_print(filename, dir = Dir.pwd, args = { :type => :tar, :compression => :gzip }) ⇒ Object
Similar to ::compress, but outputs the files it’s compressing.
59 60 61 |
# File 'lib/archive.rb', line 59 def self.compress_and_print(filename, dir=Dir.pwd, args={ :type => :tar, :compression => :gzip }) Archive::Compress.new(filename, args).compress(get_files(dir), true) end |
.extract(filename, dir = Dir.pwd) ⇒ Object
Extract a file into a directory. The default directory is the current directory.
Format and compression will be auto-detected.
See Archive::Extract for more information.
23 24 25 |
# File 'lib/archive.rb', line 23 def self.extract(filename, dir=Dir.pwd) Archive::Extract.new(filename, dir).extract end |