assert_valid_markup 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -2
  2. data/lib/assert_valid_markup.rb +20 -3
  3. metadata +1 -1
data/VERSION CHANGED
@@ -1,2 +1 @@
1
- 0.5.0
2
-
1
+ 0.5.1
@@ -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
- open(localdtd, "w") {|f| f.write(open(sysid).read())}
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
- validation_failed = validation_output.grep(/^#{Regexp.escape(tmpfile.path)}:/)
124
- return validation_failed.collect {|l| l.gsub(/^[^:]*:/, "Invalid markup: line ")}.join("\n")
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assert_valid_markup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway