Class: DarwinCore::Expander
- Inherits:
-
Object
- Object
- DarwinCore::Expander
- Defined in:
- lib/dwc_archive/expander.rb
Overview
Unpacks compressed archives into a temp directory
Instance Method Summary collapse
- #clean ⇒ Object
- #files ⇒ Object
-
#initialize(archive_path, tmp_dir) ⇒ Expander
constructor
A new instance of Expander.
- #path ⇒ Object
- #unpack ⇒ Object
Constructor Details
#initialize(archive_path, tmp_dir) ⇒ Expander
Returns a new instance of Expander.
6 7 8 9 10 11 |
# File 'lib/dwc_archive/expander.rb', line 6 def initialize(archive_path, tmp_dir) @archive_path = archive_path @tmp_dir = tmp_dir @dir_path = DarwinCore.random_path(tmp_dir) @unpacker = init_unpacker end |
Instance Method Details
#clean ⇒ Object
30 31 32 |
# File 'lib/dwc_archive/expander.rb', line 30 def clean DarwinCore.clean(@dir_path) end |
#files ⇒ Object
34 35 36 |
# File 'lib/dwc_archive/expander.rb', line 34 def files DarwinCore.files(path) end |
#path ⇒ Object
26 27 28 |
# File 'lib/dwc_archive/expander.rb', line 26 def path @path ||= files_path end |
#unpack ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/dwc_archive/expander.rb', line 13 def unpack clean raise DarwinCore::FileNotFoundError unless File.exist?(@archive_path) success = @unpacker.call(@dir_path, @archive_path) if @unpacker if @unpacker && success && $CHILD_STATUS.exitstatus.zero? success else clean raise DarwinCore::UnpackingError end end |