Class: ETL::Processor::ZipFileProcessor
Overview
Custom processor to zip files
Instance Attribute Summary (collapse)
-
- (Object) destination
readonly
Returns the value of attribute destination.
-
- (Object) infile
readonly
Returns the value of attribute infile.
Instance Method Summary (collapse)
-
- (ZipFileProcessor) initialize(control, configuration)
constructor
configuration options include:
-
infile - File to zip (required)
-
destination - Zip file name (default: #infile.zip).
-
- - (Object) process
Constructor Details
- (ZipFileProcessor) initialize(control, configuration)
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
- (Object) destination (readonly)
Returns the value of attribute destination
8 9 10 |
# File 'lib/etl/processor/zip_file_processor.rb', line 8 def destination @destination end |
- (Object) infile (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
- (Object) process
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 |