Module: IMW::Archives::Tarbz2
- Includes:
- Base, CompressedFiles::Base
- Defined in:
- lib/imw/archives/tarbz2.rb
Instance Method Summary collapse
- #archive_settings ⇒ Object
- #compression_settings ⇒ Object
-
#create(*input_paths) ⇒ Object
Overrides default behvaior of IMW::Files::Archive#create to compress files after creating them.
- #decompressed_basename ⇒ Object
-
#extname ⇒ Object
It’s a compressed file AND an archive!.
Methods included from Base
#append, #contents, #extract, #is_archive?
Methods included from CompressedFiles::Base
#decompress, #decompress!, #decompressed_path, #is_compressed?, #is_compressible?
Instance Method Details
#archive_settings ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/imw/archives/tarbz2.rb', line 26 def archive_settings @archive_settings ||= { :program => :tar, :create => '-cf', :list => "-tjf", :extract => "-xjf" } end |
#compression_settings ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/imw/archives/tarbz2.rb', line 11 def compression_settings @compression_settings ||= { :program => :bzip2, :decompression_program => :bunzip2, :decompress => '', :extension => 'bz2' } end |
#create(*input_paths) ⇒ Object
Overrides default behvaior of IMW::Files::Archive#create to compress files after creating them.
37 38 39 40 |
# File 'lib/imw/archives/tarbz2.rb', line 37 def create *input_paths IMW.system(archive_settings[:program], archive_settings[:create], path_between_archive_and_compression, *input_paths.flatten) IMW.open(path_between_archive_and_compression).compress! end |
#decompressed_basename ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/imw/archives/tarbz2.rb', line 42 def decompressed_basename case extname when '.tar.bz2' then basename[0..-5] # .tar.bz2 => .tar when '.tbz2' then basename.gsub(/tbz2$/, 'tar') # .tbz2 => .tar else basename[0..-(extname.size + 1)] end end |
#extname ⇒ Object
It’s a compressed file AND an archive!
62 63 64 65 66 67 68 |
# File 'lib/imw/archives/tarbz2.rb', line 62 def extname case path when /\.tar\.bz2$/ then '.tar.bz2' when /\.tbz2$/ then '.tbz2' else File.extname(path) end end |