resync 0.2.0 → 0.2.1
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/CHANGES.md +4 -0
- data/lib/resync/version.rb +1 -1
- data/lib/resync/xml.rb +5 -2
- data/spec/unit/resync/change_list_spec.rb +30 -0
- data/spec/unit/resync/shared/uri_field_examples.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c504db116de3859b95c4acea4ea950fb2a37a48
|
4
|
+
data.tar.gz: 1f0c7ef67cb41ca6dcdbf87ef943aa64b38b16d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b4ae0258fe913c876274be50963832f0022a2a71fee6d0c9cb9ad40e7cb2e83e97cba776eba0a7194e631177b16e19aab8e80ce89a4343c862572c7f3c1fb87
|
7
|
+
data.tar.gz: 3e04a2227d2434fda5c8628a484027542a9d7bf713f742a3c062d87a5836339037b0c520363dc348b59487eebb2d6fb801a9f41e7f7e0f21e548fac352bfa71f
|
data/CHANGES.md
CHANGED
data/lib/resync/version.rb
CHANGED
data/lib/resync/xml.rb
CHANGED
@@ -15,7 +15,9 @@ module Resync
|
|
15
15
|
# @raise [URI::InvalidURIError] if +url+ cannot be converted to a URI.
|
16
16
|
def self.to_uri(url)
|
17
17
|
return nil unless url
|
18
|
-
|
18
|
+
return url if url.is_a? URI
|
19
|
+
stripped = url.respond_to?(:strip) ? url.strip : url.to_s.strip
|
20
|
+
URI.parse(stripped)
|
19
21
|
end
|
20
22
|
|
21
23
|
# Extracts a +REXML::Element+ from the specified object.
|
@@ -91,7 +93,8 @@ module Resync
|
|
91
93
|
|
92
94
|
# Implements +::XML::Mapping::SingleAttributeNode#extract_attr_value+.
|
93
95
|
def extract_attr_value(xml)
|
94
|
-
|
96
|
+
val = default_when_xpath_err { @path.first(xml).text }
|
97
|
+
URI(val.strip)
|
95
98
|
end
|
96
99
|
|
97
100
|
# Implements +::XML::Mapping::SingleAttributeNode#set_attr_value+.
|
@@ -69,6 +69,36 @@ module Resync
|
|
69
69
|
xml = list.save_to_xml
|
70
70
|
expect(xml).to be_xml(data)
|
71
71
|
end
|
72
|
+
|
73
|
+
it 'can round-trip with pretty-printing' do
|
74
|
+
data = "
|
75
|
+
<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9' xmlns:rs='http://www.openarchives.org/rs/terms/'>
|
76
|
+
<rs:ln rel='up' href='http://example.com/dataset1/capabilitylist.xml'/>
|
77
|
+
<rs:md from='2013-01-03T00:00:00Z' capability='changelist'/>
|
78
|
+
<url>
|
79
|
+
<loc>
|
80
|
+
http://example.com/res4
|
81
|
+
</loc>
|
82
|
+
<lastmod>
|
83
|
+
2013-01-03T17:00:00Z
|
84
|
+
</lastmod>
|
85
|
+
<rs:ln modified='2013-01-03T17:00:00Z' length='73' type='application/json-patch' hash='sha-256:f4OxZX_x_DFGFDgghgdfb6rtSx-iosjf6735432nklj' rel='http://www.openarchives.org/rs/terms/patch' href='http://example.com/res4-json-patch'/>
|
86
|
+
<rs:md length='56778' type='application/json' hash='sha-256:f4OxZX_x_DFGFDgghgdfb6rtSx-iosjf6735432nklj' change='updated'/>
|
87
|
+
</url>
|
88
|
+
<url>
|
89
|
+
<loc>
|
90
|
+
http://example.com/res5-full.tiff
|
91
|
+
</loc>
|
92
|
+
<lastmod>
|
93
|
+
2013-01-03T18:00:00Z
|
94
|
+
</lastmod>
|
95
|
+
<rs:md change='deleted'/>
|
96
|
+
</url>
|
97
|
+
</urlset>"
|
98
|
+
list = ChangeList.load_from_xml(XML.element(data))
|
99
|
+
xml = list.save_to_xml
|
100
|
+
expect(xml).to be_xml(data)
|
101
|
+
end
|
72
102
|
end
|
73
103
|
end
|
74
104
|
end
|
@@ -23,6 +23,14 @@ module Resync
|
|
23
23
|
expect(instance.uri).to eq(URI(uri))
|
24
24
|
end
|
25
25
|
|
26
|
+
it 'accepts a string URI with extra whitespace' do
|
27
|
+
uri_val = '
|
28
|
+
http://example.org/
|
29
|
+
'
|
30
|
+
instance = new_instance(uri: uri_val)
|
31
|
+
expect(instance.uri).to eq(URI('http://example.org/'))
|
32
|
+
end
|
33
|
+
|
26
34
|
it 'rejects an invalid URI' do
|
27
35
|
invalid_url = 'I am not a valid URI'
|
28
36
|
expect { new_instance(uri: invalid_url) }.to raise_error(URI::InvalidURIError)
|