Class: Dradis::Plugins::Projects::Export::Package
- Inherits:
-
Export::Base
- Object
- Export::Base
- Dradis::Plugins::Projects::Export::Package
- Defined in:
- lib/dradis/plugins/projects/export/package.rb
Instance Method Summary collapse
-
#export(args = {}) ⇒ Object
Create a new project export bundle.
Instance Method Details
#export(args = {}) ⇒ Object
Create a new project export bundle. It will include an XML file with the contents of the repository (see db_only) and all the attachments that have been uploaded into the system.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dradis/plugins/projects/export/package.rb', line 7 def export(args={}) raise ":filename not provided" unless args.key?(:filename) filename = args[:filename] logger = .fetch(:logger, Rails.logger) File.delete(filename) if File.exists?(filename) logger.debug{ "Creating a new Zip file in #{filename}..." } Zip::File.open(filename, Zip::File::CREATE) do |zipfile| @project.nodes.each do |node| node_path = Attachment.pwd.join(node.id.to_s) Dir["#{node_path}/**/**"].each do |file| logger.debug{ "\tAdding attachment for '#{node.label}': #{file}" } zipfile.add(file.sub("#{Attachment.pwd.to_s}/", ''), file) end end logger.debug{ "\tAdding XML repository dump" } exporter_class = Rails.application.config.dradis.projects.template_exporter template_exporter = exporter_class.new() template = template_exporter.export zipfile.get_output_stream('dradis-repository.xml') { |out| out << template } end logger.debug{ 'Done.' } end |