Class: IMS::CC::Manifest

Inherits:
Object
  • Object
show all
Includes:
HappyMapper
Defined in:
lib/ims/cc/manifest.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cartridge_zip_fileObject

Returns the value of attribute cartridge_zip_file.



5
6
7
# File 'lib/ims/cc/manifest.rb', line 5

def cartridge_zip_file
  @cartridge_zip_file
end

#manifest_fileObject

Returns the value of attribute manifest_file.



5
6
7
# File 'lib/ims/cc/manifest.rb', line 5

def manifest_file
  @manifest_file
end

Class Method Details

.read(backup_file) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ims/cc/manifest.rb', line 12

def self.read(backup_file)
  if File.extname(backup_file) == ".xml"
    manifest = parse File.read(backup_file)
    manifest.manifest_file = backup_file
    manifest.post_process
    manifest
  else
    Zip::File.open(backup_file) do |zipfile|
      entry = zipfile.get_entry("imsmanifest.xml")
      xml = entry.get_input_stream.read
      manifest = parse xml
      manifest.cartridge_zip_file = backup_file
      manifest.post_process
      manifest
    end
  end
end

Instance Method Details

#parse_referencesObject



35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ims/cc/manifest.rb', line 35

def parse_references
  if self.cartridge_zip_file
    Zip::File.open(self.cartridge_zip_file) do |zipfile|
      self.resources.resources.each do |res|
        if res.parseable_type? && !res.inline?
          entry = zipfile.get_entry(res.reference_href)
          xml = entry.get_input_stream.read
          res.parse_reference(xml)
        end
      end
    end
  end
end

#post_processObject



30
31
32
33
# File 'lib/ims/cc/manifest.rb', line 30

def post_process
  parse_references
  organizations.attach_resources_to_items(resources)
end