lib/pione/package/package-archiver.rb in pione-0.4.0 vs lib/pione/package/package-archiver.rb in pione-0.4.1

- old
+ new

@@ -29,10 +29,11 @@ Zip::File.open(path.to_s, Zip::File::CREATE) do |zip| archive_package_info(zip) archive_documents(zip, info) archive_scenarios(zip) archive_bins(zip, info) + archive_etcs(zip, info) archive_digest(zip, digest) end # make output location output_location = output_directory_location + filename(show_digest ? digest : nil) @@ -55,17 +56,17 @@ ).to_s end # Archive package info file. def archive_package_info(zip) - add_file_with_keeping_time(zip, "pione-package.json", @location + "pione-package.json") + add_file_with_time(zip, "pione-package.json", @location + "pione-package.json") end # Archive documents based on package info file. def archive_documents(zip, info) info.documents.each do |document| - add_file_with_keeping_time(zip, document, @location + document) + add_file_with_time(zip, document, @location + document) end end # Archive scenarios. This method adds scenario directory, scenario info # file, inputs, and outputs to the archive based on scenario info file. @@ -85,17 +86,17 @@ end # Archive scenario document file. def archive_scenario_document(zip, scenario) document_location = @location + scenario + "Scenario.pione" - add_file_with_keeping_time(zip, File.join(scenario, "Scenario.pione"), document_location) + add_file_with_time(zip, File.join(scenario, "Scenario.pione"), document_location) end # Archive scenario info file. def archive_scenario_info(zip, scenario) info_location = @location + scenario + "pione-scenario.json" - add_file_with_keeping_time(zip, File.join(scenario, "pione-scenario.json"), info_location) + add_file_with_time(zip, File.join(scenario, "pione-scenario.json"), info_location) end # Archive input data of the scenario. def archive_scenario_inputs(zip, scenario, info) if not(info.inputs.empty?) @@ -103,11 +104,11 @@ mkdir_with_time(zip, File.join(scenario, "input"), (@location + scenario + "input").mtime) # archive input data info.inputs.each do |input| input_location = @location + scenario + input - add_file_with_keeping_time(zip, File.join(scenario, input), input_location) + add_file_with_time(zip, File.join(scenario, input), input_location) end end end # Archive output data of the scenario. @@ -116,34 +117,40 @@ # make scenario output directory mkdir_with_time(zip, File.join(scenario, "output"), (@location + scenario + "output").mtime) info.outputs.each do |output| output_location = @location + scenario + output - add_file_with_keeping_time(zip, File.join(scenario, output), output_location) + add_file_with_time(zip, File.join(scenario, output), output_location) end end end def archive_bins(zip, info) info.bins.each do |bin| - add_file_with_keeping_time(zip, bin, @location + bin) + add_file_with_time(zip, bin, @location + bin) end end + def archive_etcs(zip, info) + info.etcs.each do |file| + add_file_with_time(zip, file, @location + file) + end + end + def archive_digest(zip, digest) digest_location = Location[Temppath.create] digest_location.write(digest) - add_file_with_keeping_time(zip, ".digest", digest_location) + add_file_with_time(zip, ".digest", digest_location) end def mkdir_with_time(zip, path, time) zip.mkdir(path) entry = zip.get_entry(path) entry.time = Zip::DOSTime.at(time) entry.extra.delete("UniversalTime") end - def add_file_with_keeping_time(zip, path, orig_location) + def add_file_with_time(zip, path, orig_location) entry = zip.add(path, orig_location.path.to_s) entry.time = Zip::DOSTime.at(orig_location.mtime) entry.extra.delete("UniversalTime") end end