resync 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aeaccafe9b78c6c1b73438dbc3615691e55acf37
4
- data.tar.gz: 20ca197220dff4f8ac252d1fd3060446fad6e5e4
3
+ metadata.gz: 8c504db116de3859b95c4acea4ea950fb2a37a48
4
+ data.tar.gz: 1f0c7ef67cb41ca6dcdbf87ef943aa64b38b16d7
5
5
  SHA512:
6
- metadata.gz: b82cd0986b56ea9aed5f12abc1532ead2bb942128938fed721b68fee918987acbc8fdb8683074d0669c5999cd9036d6b28c72b184ab39d44ed2f8928c48f2d85
7
- data.tar.gz: eb88c946de862ab36cf3be1f9c01ff94f1f5ebe01d586ae6424bc729c004f0c6c80fd8b8a779415502c550faed3b350ee0f56b3e6c53e3d2e6273bd3934d10a9
6
+ metadata.gz: 8b4ae0258fe913c876274be50963832f0022a2a71fee6d0c9cb9ad40e7cb2e83e97cba776eba0a7194e631177b16e19aab8e80ce89a4343c862572c7f3c1fb87
7
+ data.tar.gz: 3e04a2227d2434fda5c8628a484027542a9d7bf713f742a3c062d87a5836339037b0c520363dc348b59487eebb2d6fb801a9f41e7f7e0f21e548fac352bfa71f
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.1
2
+
3
+ - Fixed issue where extra whitespace in `<loc/>` tags could prevent URI parsing.
4
+
1
5
  ## 0.2.0
2
6
 
3
7
  - `BaseResourceList#resources` now returns an `IndexableLazy` instead of a plain array.
@@ -1,4 +1,4 @@
1
1
  module Resync
2
2
  # The version of this gem.
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
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
- (url.is_a? URI) ? url : URI.parse(url)
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
- URI(default_when_xpath_err { @path.first(xml).text })
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles