nom-xml 0.5.4 → 0.6.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.
- checksums.yaml +4 -4
- data/lib/nom/xml/decorators/terminology.rb +0 -15
- data/lib/nom/xml/term.rb +4 -0
- data/lib/nom/xml/version.rb +1 -1
- data/spec/examples/mods_example_spec.rb +1 -5
- data/spec/lib/terminology_decorator_spec.rb +0 -17
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 014aacabf359763825e7eed07089ed3e080df7f7
|
4
|
+
data.tar.gz: 3196afd25586b81fda37a98535c2e55f4b1e0f9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba98c65fe282f957254e7fdd803a62bdc6692ed17d928b3c8666802c069259cb18f0e115c4ba9235c92ca75477cb0e978fc6e1a4d18a084b7343eb46014caeaf
|
7
|
+
data.tar.gz: d2f3b9757f83d81ac615ee5c6b2b317611324c75fc7265c2cbf9b42df2e1da5736a095673f7d154083df9bf3d3327a3a87e9c85ba23ed14e3471ec59ad213f96
|
@@ -1,19 +1,4 @@
|
|
1
1
|
module Nom::XML::Decorators::Terminology
|
2
|
-
|
3
|
-
def self.extended node
|
4
|
-
node.add_terminology_method_overrides!
|
5
|
-
end
|
6
|
-
|
7
|
-
def add_terminology_method_overrides!
|
8
|
-
self.term_accessors.each do |k, term|
|
9
|
-
if self.respond_to_without_terms? k and not term.options[:override]
|
10
|
-
raise "Trying to redefine method #{k} on #{self.to_s}"
|
11
|
-
end
|
12
|
-
end.select { |k, term| term.options[:override] }.each do |method, term|
|
13
|
-
define_term_method(method, self.term_accessors[method.to_sym])
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
2
|
def method_missing method, *args, &block
|
18
3
|
if self.term_accessors[method.to_sym]
|
19
4
|
define_term_method(method, self.term_accessors[method.to_sym])
|
data/lib/nom/xml/term.rb
CHANGED
@@ -16,6 +16,10 @@ module Nom::XML
|
|
16
16
|
# @attr [Hash] options
|
17
17
|
# @yield
|
18
18
|
def initialize parent, name, options = {}, *args, &block
|
19
|
+
if Nokogiri::XML::Node.instance_methods.include?(name.to_sym)
|
20
|
+
raise "Unable to redefine method #{name} on Nokogiri::XML::Node"
|
21
|
+
end
|
22
|
+
|
19
23
|
@name = name
|
20
24
|
@terms = {}
|
21
25
|
@parent = parent
|
data/lib/nom/xml/version.rb
CHANGED
@@ -13,7 +13,7 @@ describe "Namespaces example" do
|
|
13
13
|
|
14
14
|
t.author :path => '//mods:name' do |n|
|
15
15
|
n.authorityURI :path => '@authorityURI', :accessor => lambda { |e| e.text }
|
16
|
-
n.
|
16
|
+
n.mods_description :path => 'mods:description'
|
17
17
|
n.valueURI :path => '@valueURI'
|
18
18
|
n.namePart :path => 'mods:namePart', :single => true, :index_as => [:type_1]
|
19
19
|
end
|
@@ -39,10 +39,6 @@ describe "Namespaces example" do
|
|
39
39
|
xml
|
40
40
|
}
|
41
41
|
|
42
|
-
it "should work with existing reserved method names when override is present" do
|
43
|
-
expect(subject.author.first.description.text).to include('asdf')
|
44
|
-
end
|
45
|
-
|
46
42
|
it "should return nodesets by default" do
|
47
43
|
expect(subject.personal_authors).to be_a_kind_of(Nokogiri::XML::NodeSet)
|
48
44
|
end
|
@@ -32,23 +32,6 @@ describe "Nutrition" do
|
|
32
32
|
xml
|
33
33
|
}
|
34
34
|
|
35
|
-
describe "#add_terminology_method_overrides!" do
|
36
|
-
|
37
|
-
it "should warn you if you try to override already existing methods" do
|
38
|
-
pending if defined? JRUBY_VERSION
|
39
|
-
mock_term = {:text => double(:options => {})}
|
40
|
-
allow(document.a.first).to receive(:term_accessors).and_return mock_term
|
41
|
-
expect { document.a.first.add_terminology_method_overrides! }.to raise_error /Trying to redefine/
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should let you override the warning" do
|
45
|
-
pending if defined? JRUBY_VERSION
|
46
|
-
mock_term = {:text => double(:options => { :override => true } )}
|
47
|
-
allow(document.a.first).to receive(:term_accessors).and_return mock_term
|
48
|
-
expect { document.a.first.add_terminology_method_overrides! }.to_not raise_error
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
35
|
describe "#terms" do
|
53
36
|
|
54
37
|
context "root element" do
|
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.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-09-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
version: '0'
|
173
173
|
requirements: []
|
174
174
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.5.1
|
176
176
|
signing_key:
|
177
177
|
specification_version: 4
|
178
178
|
summary: A library to help you tame sprawling XML schemas.
|
@@ -191,4 +191,3 @@ test_files:
|
|
191
191
|
- spec/lib/terminology_spec.rb
|
192
192
|
- spec/spec_helper.rb
|
193
193
|
- spec/test_spec.rb
|
194
|
-
has_rdoc:
|