nom-xml 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nom/xml/decorators/terminology.rb +12 -4
- data/lib/nom/xml/term.rb +4 -0
- data/lib/nom/xml/version.rb +1 -1
- data/spec/examples/mods_example_spec.rb +6 -2
- metadata +3 -3
@@ -52,11 +52,19 @@ module Nom::XML::Decorators::Terminology
|
|
52
52
|
##
|
53
53
|
# Get the terminology terms associated with this node
|
54
54
|
def terms
|
55
|
-
return
|
55
|
+
return @terms if @terms
|
56
|
+
p = self.parent
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
t = []
|
59
|
+
|
60
|
+
until p.is_a? Nokogiri::XML::Document
|
61
|
+
p.term_accessors.each do |k,term|
|
62
|
+
t << term if term.nodes.include? self
|
63
|
+
end
|
64
|
+
p = p.parent
|
65
|
+
end
|
66
|
+
|
67
|
+
@terms ||= t
|
60
68
|
end
|
61
69
|
|
62
70
|
protected
|
data/lib/nom/xml/term.rb
CHANGED
data/lib/nom/xml/version.rb
CHANGED
@@ -16,7 +16,9 @@ describe "Namespaces example" do
|
|
16
16
|
|
17
17
|
t.corporate_authors :path => '//mods:name[@type="corporate"]'
|
18
18
|
t.personal_authors :path => 'mods:name[@type="personal"]' do |n|
|
19
|
-
n.roleTerm :path => 'mods:role/mods:roleTerm', :index_as => [:type_1]
|
19
|
+
n.roleTerm :path => 'mods:role/mods:roleTerm', :index_as => [:type_1] do |r|
|
20
|
+
r.type :path => '@type'
|
21
|
+
end
|
20
22
|
|
21
23
|
n.name_role_pair :path => '.', :accessor => lambda { |node| node.roleTerm.text + ": " + node.namePart.text }
|
22
24
|
|
@@ -64,6 +66,8 @@ describe "Namespaces example" do
|
|
64
66
|
|
65
67
|
eric.namePart.text.should == "Alterman, Eric"
|
66
68
|
eric.roleTerm.text.should == "creator"
|
69
|
+
|
70
|
+
eric.roleTerm.type.text.should == "text"
|
67
71
|
end
|
68
72
|
|
69
73
|
it "should let you mix and match xpaths and nom accessors" do
|
@@ -81,7 +85,7 @@ describe "Namespaces example" do
|
|
81
85
|
end
|
82
86
|
|
83
87
|
it "should let you go from a terminology to nodes" do
|
84
|
-
subject.terminology.flatten.length.should ==
|
88
|
+
subject.terminology.flatten.length.should == 11
|
85
89
|
|
86
90
|
subject.terminology.flatten.select { |x| x.options[:index_as] }.should have(2).terms
|
87
91
|
subject.terminology.flatten.select { |x| x.options[:index_as] }.map { |x| x.nodes }.flatten.should have(2).nodes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nom-xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -174,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
174
|
version: '0'
|
175
175
|
segments:
|
176
176
|
- 0
|
177
|
-
hash:
|
177
|
+
hash: 4560285643406046416
|
178
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
179
179
|
none: false
|
180
180
|
requirements:
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
version: '0'
|
184
184
|
segments:
|
185
185
|
- 0
|
186
|
-
hash:
|
186
|
+
hash: 4560285643406046416
|
187
187
|
requirements: []
|
188
188
|
rubyforge_project:
|
189
189
|
rubygems_version: 1.8.23
|