scorm2004-manifest 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +7 -0
- data/VERSION +1 -1
- data/lib/scorm2004/manifest/visitor_pattern.rb +26 -0
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -74,6 +74,13 @@ For example, <organizations> element has one or more
|
|
74
74
|
organization_0 = organizations.organizations[0]
|
75
75
|
|
76
76
|
|
77
|
+
Each parsed element also responds to the +to_hash+ method.
|
78
|
+
Using this method, you can convert your manifest file into
|
79
|
+
Hash or more useful forms.
|
80
|
+
|
81
|
+
json_manifest = Scorm2004::Manifest(open('imsmanifest.xml')).to_hash.to_json
|
82
|
+
|
83
|
+
|
77
84
|
== Documentation
|
78
85
|
|
79
86
|
To generate scorm2004-manifest's document set, use the following command:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
@@ -20,6 +20,17 @@ module Scorm2004
|
|
20
20
|
self
|
21
21
|
end
|
22
22
|
|
23
|
+
def to_hash
|
24
|
+
if respond_to? :content
|
25
|
+
content
|
26
|
+
else
|
27
|
+
{}.merge(self.class.respond_to?(:attributes) ? attributes_hash : {})
|
28
|
+
.merge(self.class.respond_to?(:children) ? children_hash : {})
|
29
|
+
.merge(respond_to?(:href) ? {:href => href } : {})
|
30
|
+
.reject { |k, v| v.nil? || v == [] || v == {} }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
23
34
|
# @return [Nokogiri::XML::Node, nil] The <metadata> element or +nil+
|
24
35
|
def metadata
|
25
36
|
@el.at('./imscp:metadata', NS)
|
@@ -42,6 +53,21 @@ module Scorm2004
|
|
42
53
|
send("visit_#{child}".intern)
|
43
54
|
end
|
44
55
|
end
|
56
|
+
|
57
|
+
def attributes_hash
|
58
|
+
Hash[self.class.attributes.map { |attr| [attr, instance_variable_get("@#{attr}")]}]
|
59
|
+
end
|
60
|
+
|
61
|
+
def children_hash
|
62
|
+
Hash[self.class.children.map { |child|
|
63
|
+
value = instance_variable_get("@#{child}")
|
64
|
+
if value.respond_to?(:map)
|
65
|
+
[child, value.map { |v| v.to_hash }]
|
66
|
+
else
|
67
|
+
[child, value.try(:to_hash)]
|
68
|
+
end
|
69
|
+
}]
|
70
|
+
end
|
45
71
|
end
|
46
72
|
end
|
47
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scorm2004-manifest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -277,7 +277,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
277
277
|
version: '0'
|
278
278
|
segments:
|
279
279
|
- 0
|
280
|
-
hash:
|
280
|
+
hash: 4009410034375150094
|
281
281
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
282
282
|
none: false
|
283
283
|
requirements:
|