om 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/om/version.rb +1 -1
- data/lib/om/xml/document.rb +21 -10
- data/spec/integration/subclass_terminology_spec.rb +85 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8853ffe68e14cbf9ff2ff97cc6a11dc742f66b9
|
4
|
+
data.tar.gz: 1f871031a8b66f0537598d05c05fc1bbcbbeca2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eb12d59198a4a22597551376e8142be99c0e5567e273490fd4eab40659419f89727267a79795e5049e3a1876c6f479df471146455f69d5c37cbd7cf167390a2
|
7
|
+
data.tar.gz: d8e3386ff684e7fe87d599b5842753050494fba9f6043f070882d21709de794052c46bc3fd64881638476cf099fdaeee277f63b2644fe305ad805ec290553b6c
|
data/lib/om/version.rb
CHANGED
data/lib/om/xml/document.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
module OM::XML::Document
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
|
+
included do
|
5
|
+
include OM::XML::Container
|
6
|
+
include OM::XML::TermValueOperators
|
7
|
+
include OM::XML::Validation
|
8
|
+
include ActiveModel::Dirty
|
9
|
+
end
|
10
|
+
|
4
11
|
# Class Methods -- These methods will be available on classes that include this Module
|
5
12
|
|
6
13
|
module ClassMethods
|
@@ -8,7 +15,12 @@ module OM::XML::Document
|
|
8
15
|
attr_accessor :terminology, :terminology_builder, :template_registry
|
9
16
|
|
10
17
|
def terminology
|
11
|
-
@terminology
|
18
|
+
return @terminology if @terminology
|
19
|
+
@terminology = if superclass.respond_to? :terminology
|
20
|
+
superclass.terminology.dup
|
21
|
+
else
|
22
|
+
terminology_builder.build
|
23
|
+
end
|
12
24
|
end
|
13
25
|
|
14
26
|
def terminology_builder
|
@@ -16,7 +28,12 @@ module OM::XML::Document
|
|
16
28
|
end
|
17
29
|
|
18
30
|
def template_registry
|
19
|
-
@template_registry
|
31
|
+
return @template_registry if @template_registry
|
32
|
+
@template_registry = if superclass.respond_to? :template_registry
|
33
|
+
superclass.template_registry.dup
|
34
|
+
else
|
35
|
+
OM::XML::TemplateRegistry.new
|
36
|
+
end
|
20
37
|
end
|
21
38
|
|
22
39
|
def rebuild_terminology!
|
@@ -24,6 +41,8 @@ module OM::XML::Document
|
|
24
41
|
end
|
25
42
|
|
26
43
|
# Sets the OM::XML::Terminology for the Document
|
44
|
+
# If there already is a termnology for this class, it will be replaced.
|
45
|
+
# @see extend_termniology If you want to add terms to an existing terminology
|
27
46
|
# Expects +&block+ that will be passed into OM::XML::Terminology::Builder.new
|
28
47
|
def set_terminology &block
|
29
48
|
@terminology_builder = OM::XML::Terminology::Builder.new(&block)
|
@@ -60,14 +79,6 @@ module OM::XML::Document
|
|
60
79
|
|
61
80
|
attr_accessor :ox_namespaces
|
62
81
|
|
63
|
-
included do
|
64
|
-
include OM::XML::Container
|
65
|
-
include OM::XML::TermValueOperators
|
66
|
-
include OM::XML::Validation
|
67
|
-
include ActiveModel::Dirty
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
82
|
def ng_xml_will_change!
|
72
83
|
# throw away older version.
|
73
84
|
changed_attributes['ng_xml'] = nil
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Inherited terminology" do
|
4
|
+
describe "with basic terms" do
|
5
|
+
before(:all) do
|
6
|
+
class AbstractTerminology
|
7
|
+
include OM::XML::Document
|
8
|
+
set_terminology do |t|
|
9
|
+
t.root :path => 'root', :xmlns => "asdf"
|
10
|
+
t.foo
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class ConcreteTerminology < AbstractTerminology
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
after(:all) do
|
19
|
+
Object.send(:remove_const, :ConcreteTerminology)
|
20
|
+
Object.send(:remove_const, :AbstractTerminology)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "on the subclass" do
|
24
|
+
subject do
|
25
|
+
xml = '<root xmlns="asdf"><foo>fooval</foo><bar>barval</bar></root>'
|
26
|
+
ConcreteTerminology.from_xml(xml)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should inherit terminology" do
|
30
|
+
subject.foo = "Test value"
|
31
|
+
subject.foo.should == ["Test value"]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "on the superclass" do
|
36
|
+
subject do
|
37
|
+
xml = '<root xmlns="asdf"><foo>fooval</foo><bar>barval</bar></root>'
|
38
|
+
AbstractTerminology.from_xml(xml)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have terminology" do
|
42
|
+
subject.foo = "Test value"
|
43
|
+
subject.foo.should == ["Test value"]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "with template terms" do
|
49
|
+
before(:all) do
|
50
|
+
class AbstractTerminology
|
51
|
+
include OM::XML::Document
|
52
|
+
set_terminology do |t|
|
53
|
+
t.root :path => 'root', :xmlns => "asdf"
|
54
|
+
end
|
55
|
+
|
56
|
+
define_template :creator do |xml, author, role|
|
57
|
+
xml.pbcoreCreator {
|
58
|
+
xml.creator(author)
|
59
|
+
xml.creatorRole(role, :source=>"PBCore creatorRole")
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class ConcreteTerminology < AbstractTerminology
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
after(:all) do
|
69
|
+
Object.send(:remove_const, :ConcreteTerminology)
|
70
|
+
Object.send(:remove_const, :AbstractTerminology)
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "on the subclass" do
|
74
|
+
subject do
|
75
|
+
xml = '<root></root>'
|
76
|
+
ConcreteTerminology.from_xml(xml)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should inherit templates" do
|
80
|
+
subject.add_child_node subject.ng_xml.root, :creator, 'Test author', 'Primary'
|
81
|
+
subject.ng_xml.xpath('//pbcoreCreator/creatorRole[@source="PBCore creatorRole"]').text.should == "Primary"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: om
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Zumwalt
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -256,6 +256,7 @@ files:
|
|
256
256
|
- spec/integration/selective_querying_spec.rb
|
257
257
|
- spec/integration/serialization_spec.rb
|
258
258
|
- spec/integration/set_reentrant_terminology_spec.rb
|
259
|
+
- spec/integration/subclass_terminology_spec.rb
|
259
260
|
- spec/integration/xpathy_stuff_spec.rb
|
260
261
|
- spec/samples.rb
|
261
262
|
- spec/samples/mods_article.rb
|
@@ -319,6 +320,7 @@ test_files:
|
|
319
320
|
- spec/integration/selective_querying_spec.rb
|
320
321
|
- spec/integration/serialization_spec.rb
|
321
322
|
- spec/integration/set_reentrant_terminology_spec.rb
|
323
|
+
- spec/integration/subclass_terminology_spec.rb
|
322
324
|
- spec/integration/xpathy_stuff_spec.rb
|
323
325
|
- spec/samples.rb
|
324
326
|
- spec/samples/mods_article.rb
|