assert_valid_markup 0.5.0 → 0.5.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.
- data/VERSION +1 -2
- data/lib/assert_valid_markup.rb +20 -3
- metadata +1 -1
data/VERSION
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
0.5.
|
2
|
-
|
1
|
+
0.5.1
|
data/lib/assert_valid_markup.rb
CHANGED
@@ -103,6 +103,8 @@ class Test::Unit::TestCase
|
|
103
103
|
validation_output = `xmllint --catalogs --memory --noout #{dtd_validate ? '--valid' : ''} #{tmpfile.path} 2>&1`
|
104
104
|
ENV.delete("XML_DEBUG_CATALOG")
|
105
105
|
|
106
|
+
added_to_catalog = false
|
107
|
+
last_sysid = ""
|
106
108
|
validation_output.each do |line|
|
107
109
|
line.chomp!
|
108
110
|
if match = line.match(/Resolve: pubID (.*) sysID (.*)/)
|
@@ -111,17 +113,32 @@ class Test::Unit::TestCase
|
|
111
113
|
localdtd = "#{catalog_path}/#{sysid.split('/').last}"
|
112
114
|
if ! File.exists? localdtd
|
113
115
|
puts "Adding xml catalog resource\n\tpublic id: '#{pubid}'\n\turi: '#{sysid}'\n\tfile: '#{localdtd}'"
|
114
|
-
|
116
|
+
if sysid =~ /^file:/
|
117
|
+
basename = sysid.split('/').last
|
118
|
+
dirname = last_sysid.gsub(/\/[^\/]*$/, '')
|
119
|
+
sysid = "#{dirname}/#{basename}"
|
120
|
+
puts "Using sysid relative to parent: #{sysid}"
|
121
|
+
end
|
122
|
+
|
123
|
+
sysid_contents = open(sysid, 'r', 0, 'User-Agent' => 'assert_valid_markup').read()
|
124
|
+
open(localdtd, "w") {|f| f.write(sysid_contents)}
|
125
|
+
added_to_catalog = true
|
126
|
+
|
115
127
|
out = `xmlcatalog --noout --add 'public' '#{pubid}' 'file://#{localdtd}' '#{catalog_file}' 2>&1`
|
116
128
|
if $? != 0
|
117
129
|
puts out
|
118
130
|
exit 1
|
119
131
|
end
|
120
132
|
end
|
133
|
+
last_sysid = sysid
|
121
134
|
end
|
122
135
|
end
|
123
|
-
|
124
|
-
|
136
|
+
if added_to_catalog
|
137
|
+
return local_validate(xmldata, dtd_validate, catalog_path)
|
138
|
+
else
|
139
|
+
validation_failed = validation_output.grep(/^#{Regexp.escape(tmpfile.path)}:/)
|
140
|
+
return validation_failed.collect {|l| l.gsub(/^[^:]*:/, "Invalid markup: line ")}.join("\n")
|
141
|
+
end
|
125
142
|
end
|
126
143
|
|
127
144
|
def w3c_validate(fragment, dtd_validate)
|