class CommonCartridge::Parsers::Files
Attributes
resource[R]
Public Class Methods
new(zipfile, resource)
click to toggle source
# File lib/common_cartridge/parsers/files.rb, line 6 def initialize(zipfile, resource) @zipfile = zipfile @resource = resource end
Public Instance Methods
parse!(package)
click to toggle source
# File lib/common_cartridge/parsers/files.rb, line 11 def parse!(package) if mapping = resource_to_mapping(resource) resource.files.each do |f| Parser.use_file(@zipfile, f.href) do |xml| f.content = mapping.last.parse(xml) f.content.identifier = resource.identifier if resource.type =~ CommonCartridge::Elements::Resources::Assignment.pattern && f.href =~ /assignment.*xml/ && !(resource.href =~ /course/) doc = Nokogiri::XML(xml) doc.remove_namespaces! f.content.points_possible = doc.xpath('//points_possible').text package.assignments << f.content end end end end end
Private Instance Methods
resource_to_mapping(resource)
click to toggle source
# File lib/common_cartridge/parsers/files.rb, line 29 def resource_to_mapping(resource) CommonCartridge::Elements::Resources.type_mappings.detect { |regex, klass| resource.type =~ regex } end