Class: ETL::Processor::ZipFileProcessor
- Defined in:
- lib/etl/processor/zip_file_processor.rb
Overview
Custom processor to zip files
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#infile ⇒ Object
readonly
Returns the value of attribute infile.
Instance Method Summary collapse
-
#initialize(control, configuration) ⇒ ZipFileProcessor
constructor
configuration options include: * infile - File to zip (required) * destination - Zip file name (default: ##infile.zip).
- #process ⇒ Object
Constructor Details
#initialize(control, configuration) ⇒ ZipFileProcessor
configuration options include:
-
infile - File to zip (required)
-
destination - Zip file name (default: ##infile.zip)
13 14 15 16 17 |
# File 'lib/etl/processor/zip_file_processor.rb', line 13 def initialize(control, configuration) path = Pathname.new(configuration[:infile]) @infile = path.absolute? ? path : Pathname.new(File.dirname(File.(configuration[:infile]))) + path @destination = configuration[:destination] || "#{infile}.zip" end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
8 9 10 |
# File 'lib/etl/processor/zip_file_processor.rb', line 8 def destination @destination end |
#infile ⇒ Object (readonly)
Returns the value of attribute infile.
7 8 9 |
# File 'lib/etl/processor/zip_file_processor.rb', line 7 def infile @infile end |
Instance Method Details
#process ⇒ Object
19 20 21 22 23 |
# File 'lib/etl/processor/zip_file_processor.rb', line 19 def process Zip::ZipFile.open(@destination, Zip::ZipFile::CREATE) do |zipfile| zipfile.add(@infile.basename, @infile) end end |