Low commit activity in last 3 years
Parse IMS Common Cartridge packages
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.0

Runtime

~> 1.14.3
~> 1.3.0
~> 1.3.2
 Project Readme

common_cartridge_parser

A gem for the parsing of IMS Common Cartridge bundles.

It's a fork of the common_cartridge gem (https://github.com/instructure/common_cartridge). The main difference is that is adds support for XML namespaces and Basic LTI links resource.

Usage

common_cartridge_parser transforms the XML contained in a Common Cartridge zip file into a nested object representation.

require 'common_cartridge'

manifest = CommonCartridge.parse_from_zip('location/to/common/cartridge/zip/file')
puts manifest.metadata.schema
# => "IMS Common Cartridge"

puts manifest.metadata.schemaversion
# => "1.1.0"

# Get title of course
puts manifest.lom.general.title
# => "Art History 101"

# Get all associated resource types (discussion topics, assignments, etc)
resource_types = manifest.resources.map { |r| r.type }
puts resource_types
# => ['webcontent', 'imsdt', 'webcontent', 'assignment', 'webcontent', 'imsdt']

puts manifest.resources.first.title
# => "Portrait of Pablo Picasso"

You can also parse a Common Cartridge manifest XML file that's already been extracted.

xml = File.open('imsmanifest.xml').read

CommonCartridge::Parser.parse(xml)

You can configure common_cartridge_parser as well.

CommonCartridge.configure do |c|
  # import_directory is where CommonCartridge.parse_from_zip scopes to.
  c.import_directory = '/home/me/courses' # defaults to '.'

  # no-op currently, until resource parsing is done.
  c.export_directory = '/home/me/outputs' # defaults to '/tmp'
end