app/models/product.rb
##
# Collects all Artifact and Passage files inside a zip and presents it to the user as downloadable file
Collects all Artifact and Passage files inside a zip and presents it to the user as downloadable file
Collects all Artifact and Passage files inside a zip and presents it to the user as downloadable file
def create_zip(tempfile)
    Zip::OutputStream.open(tempfile) do |zipfile|
      zipfile.put_next_entry(project.name + " description.txt")
      zipfile.print project.description
      features.each do |feature|
        zipfile.put_next_entry(feature.name + "/description.txt")
        zipfile.print feature.description
        feature.artifacts.each do |artifact|
          zipfile.put_next_entry(feature.name + "/" + artifact.name + "/description.txt")
          zipfile.print artifact.description
          zipfile.put_next_entry(feature.name + "/" + artifact.name + "/" + artifact.file.filename.to_s)
          zipfile.print artifact.file.download
        end
        feature.passages.each do |passage|
          zipfile.put_next_entry(feature.name + "/" + passage.name + "/description.txt")
          zipfile.print passage.description
          zipfile.put_next_entry(feature.name + "/" + passage.name + "/" + passage.file.filename.to_s)
          zipfile.print passage.file.download
        end
      end
      zipfile.close
    end
  end
def create_zip ( tempfile ) Zip :: OutputStream . open ( tempfile ) do | zipfile | zipfile . put_next_entry ( project . name + " description.txt" ) zipfile . print project . description features . each do | feature | zipfile . put_next_entry ( feature . name + "/description.txt" ) zipfile . print feature . description feature . artifacts . each do | artifact | zipfile . put_next_entry ( feature . name + "/" + artifact . name + "/description.txt" ) zipfile . print artifact . description zipfile . put_next_entry ( feature . name + "/" + artifact . name + "/" + artifact . file . filename . to_s ) zipfile . print artifact . file . download end feature . passages . each do | passage | zipfile . put_next_entry ( feature . name + "/" + passage . name + "/description.txt" ) zipfile . print passage . description zipfile . put_next_entry ( feature . name + "/" + passage . name + "/" + passage . file . filename . to_s ) zipfile . print passage . file . download end end zipfile . close end end
Collects all Artifact and Passage files inside a zip and presents it to the user as downloadable file
Collects all Artifact and Passage files inside a zip and presents it to the user as downloadable file
# project description # feature description
tempfile