Class: Scorm::Command::Check

Inherits:
Base
  • Object
show all
Defined in:
lib/scorm/commands/check.rb

Instance Attribute Summary

Attributes inherited from Base

#args, #autodetected_package

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

#indexObject

Raises:


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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/scorm/commands/check.rb', line 3

def index
  package = args.shift.strip rescue ''
  raise(CommandFailed, "Invalid package.") if package == ''

  Scorm::Package.open(package, :dry_run => true) do |pkg|
    display "Checking package \"#{File.basename(package)}\""
    display ""
    display "== UUID =="
    display "Identifier: #{pkg.manifest.identifier}"
    display ""
    display "== Manifest =="
    Scorm::Manifest::MANIFEST_FILES.each do |file|
     if pkg.exists?(file)
       display "#{file} -> OK"
      else
        display "#{file} -> Missing"
      end
    end
    display ""
    display "== Organizations =="
    pkg.manifest.organizations.each do |id, organization|
      if organization == pkg.manifest.default_organization
        display "#{organization.title} (default)"
      else
        display "#{organization.title}"
      end
    end
    display ""
    display "== Resources =="
    pkg.manifest.resources.each do |resource|
      display "#{resource.href} (#{resource.type}, #{resource.scorm_type}):"
      resource.files.each do |file|
        if pkg.exists?(file)
          display "  - #{file} -> OK"
        else
          display "  - #{file} -> Missing"
        end
      end
    end
  end
end