Class: Scorm::Command::Bundle
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#display, #error, #extract_option, #extract_package, #initialize
Constructor Details
This class inherits a constructor from Scorm::Command::Base
Instance Method Details
#index ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/scorm/commands/bundle.rb', line 3 def index name = args.shift.strip rescue '.' unless File.exist?(File.join(File.(name), 'imsmanifest.xml')) raise(CommandFailed, "Invalid package, didn't find any imsmanifest.xml file.") end outname = File.basename(File.(name)) + '.zip' require 'zip/zip' Zip::ZipFile.open(outname, Zip::ZipFile::CREATE) do |zipfile| Scorm::Package.open(name) do |pkg| Scorm::Manifest::MANIFEST_FILES.each do |file| zipfile.get_output_stream(file) {|f| f.write(pkg.file(file)) } display file end files = pkg.manifest.resources.map {|r| r.files }.flatten.uniq files.each do |file| zipfile.get_output_stream(file) {|f| f.write(pkg.file(file)) } display file end end end display "Created new SCORM package \"#{outname}\"." end |