Class: CommonCartridge::Parsers::Parser
- Inherits:
-
Object
- Object
- CommonCartridge::Parsers::Parser
- Defined in:
- lib/common_cartridge/parsers/parser.rb
Defined Under Namespace
Classes: ManifestDocument
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(zipfile) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
Class Method Details
.use_file(zipfile, path) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/common_cartridge/parsers/parser.rb', line 18 def self.use_file(zipfile, path) Zip::File.open(File.join(CommonCartridge.config.import_directory, zipfile)) do |file| f = file.glob(path).first unless f.nil? yield f.get_input_stream.read end end end |
Instance Method Details
#parse ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/common_cartridge/parsers/parser.rb', line 32 def parse Parser.use_file(@zipfile, 'imsmanifest.xml') do |xml| @package.manifest = ManifestDocument.parse(xml).manifest end parse_content! @package.outcomes = parse_outcomes parse_questions! parse_module_items! @package end |