ruby-jing 0.0.2 → 0.0.3
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 +5 -5
- data/README.rdoc +4 -4
- data/lib/jing.rb +12 -8
- data/test/test_jing.rb +8 -0
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9b1085cc25a09ba6773d7b0dfb4e6f8049054aaadccff23342b7a69861a64584
|
4
|
+
data.tar.gz: a033dc727afee925c526ec476f68a25b7e491efb6f5e799a755484e6c2d996d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1186148de2672e4ea4924cc7065878d3ce7a1d94732517bfb7159a613ffeb12bbec509b7bddf50c84ad2121ecf885e5a365edd09d2222562e89bcc8d0c872bbe
|
7
|
+
data.tar.gz: 9211e3e156bf374b48f32814c058a80d63df45ab6261e1726296b2ef319b037d4f045c199596e2b1efd95298a7c84da03c693a8138335b68fa417dee548025f6
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Ruby Jing
|
2
2
|
|
3
|
-
{<img src="https://
|
3
|
+
{<img src="https://github.com/sshaw/ruby-jing/actions/workflows/rake.yml/badge.svg"/>}[https://github.com/sshaw/ruby-jing/actions/workflows/rake.yml]
|
4
4
|
{<img src="https://codeclimate.com/github/sshaw/ruby-jing.png" />}[https://codeclimate.com/github/sshaw/ruby-jing]
|
5
5
|
|
6
6
|
RELAX NG schema validation using the {Jing CLI}[http://www.thaiopensource.com/relaxng/jing.html]
|
@@ -55,7 +55,7 @@ Simple: good error messages. Let's look at the error messages provided by each o
|
|
55
55
|
|
56
56
|
<!-- XML B -->
|
57
57
|
<addressBook>
|
58
|
-
<card verison="v100">
|
58
|
+
<card verison="v100">
|
59
59
|
<name>John Smith</name>
|
60
60
|
<oops>Doh!</oops>
|
61
61
|
</card>
|
@@ -65,7 +65,7 @@ Simple: good error messages. Let's look at the error messages provided by each o
|
|
65
65
|
|
66
66
|
schema = Nokogiri::XML::RelaxNG(File.read(rng))
|
67
67
|
doc = Nokogiri::XML(File.read(xml))
|
68
|
-
errors = schema.validate(doc)
|
68
|
+
errors = schema.validate(doc)
|
69
69
|
errors.each { |e| puts e }
|
70
70
|
|
71
71
|
Resulting errors:
|
@@ -87,7 +87,7 @@ Resulting errors:
|
|
87
87
|
|
88
88
|
Fails for XML A and XML B --it treats the XML declaration as a validation error!
|
89
89
|
|
90
|
-
Validation error. Expected: :start_element( addressBook ) from < S.1 #:start_element( addressBook ), < Z.2 #:start_element( card ), :start_attribute( version ), < C.3 :text( v1 ) or :text( v2 ) >, :end_attribute( ), :start_element( name ), :text( ), :end_element( ), :start_element( email ), :text( ), :end_element( ), :end_element( ) >, :end_element( ), :end_document( ) > but got <?xml ... ?>(
|
90
|
+
Validation error. Expected: :start_element( addressBook ) from < S.1 #:start_element( addressBook ), < Z.2 #:start_element( card ), :start_attribute( version ), < C.3 :text( v1 ) or :text( v2 ) >, :end_attribute( ), :start_element( name ), :text( ), :end_element( ), :start_element( email ), :text( ), :end_element( ), :end_element( ) >, :end_element( ), :end_document( ) > but got <?xml ... ?>(
|
91
91
|
)
|
92
92
|
|
93
93
|
==== Jing
|
data/lib/jing.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "optout"
|
2
2
|
|
3
3
|
class Jing
|
4
|
-
VERSION = "0.0.
|
4
|
+
VERSION = "0.0.3"
|
5
5
|
DEFAULT_JAR = File.join(File.dirname(__FILE__), "jing-20091111.jar")
|
6
6
|
|
7
7
|
Error = Class.new(StandardError)
|
@@ -89,9 +89,8 @@ class Jing
|
|
89
89
|
|
90
90
|
out = execute(@options)
|
91
91
|
return [] if $?.success? and out.empty?
|
92
|
-
|
93
|
-
|
94
|
-
errors
|
92
|
+
|
93
|
+
parse_output(out)
|
95
94
|
end
|
96
95
|
|
97
96
|
# Validate an XML document against the schema. To receive a list of validation errors use #validate.
|
@@ -107,15 +106,15 @@ class Jing
|
|
107
106
|
# Same as #validate
|
108
107
|
#
|
109
108
|
# === Returns
|
110
|
-
#
|
109
|
+
#
|
111
110
|
# [Boolean] +true+ if valid, +false+ if invalid
|
112
111
|
#
|
113
|
-
|
112
|
+
|
114
113
|
def valid?(xml)
|
115
114
|
errors = validate(xml)
|
116
115
|
errors.none?
|
117
116
|
end
|
118
|
-
|
117
|
+
|
119
118
|
private
|
120
119
|
def execute(options)
|
121
120
|
cmd = @@option_builder.shell(options)
|
@@ -129,13 +128,18 @@ class Jing
|
|
129
128
|
def parse_output(output)
|
130
129
|
errors = []
|
131
130
|
output.split("\n").each do |line|
|
132
|
-
|
131
|
+
case line
|
132
|
+
when /\A(.+):(\d+):(\d+):\s+\w+:\s+(.+)\Z/
|
133
133
|
errors << {
|
134
134
|
:source => $1,
|
135
135
|
:line => $2.to_i,
|
136
136
|
:column => $3.to_i,
|
137
137
|
:message => $4
|
138
138
|
}
|
139
|
+
when /Picked up _JAVA_OPTIONS: /
|
140
|
+
# ignore diagnostic message
|
141
|
+
else # There must have been a problem that was not schema related
|
142
|
+
raise ExecutionError, output
|
139
143
|
end
|
140
144
|
end
|
141
145
|
errors
|
data/test/test_jing.rb
CHANGED
@@ -113,6 +113,14 @@ class TestJing < MiniTest::Unit::TestCase
|
|
113
113
|
end
|
114
114
|
end
|
115
115
|
|
116
|
+
def test_java_options_env_diagnostic_message
|
117
|
+
output = "Picked up _JAVA_OPTIONS: -Djava.io.tmpdir=/tmp"
|
118
|
+
fakeshell(:exit => 0, :output => output) {
|
119
|
+
errors = Jing.new(RNG_SCHEMA).validate(VALID_XML)
|
120
|
+
assert_equal 0, errors.size
|
121
|
+
}
|
122
|
+
end
|
123
|
+
|
116
124
|
private
|
117
125
|
def fakeshell(options = {})
|
118
126
|
output = options.delete(:output) || ""
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Skye Shaw
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: optout
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.0.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,8 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
99
|
- !ruby/object:Gem::Version
|
86
100
|
version: '0'
|
87
101
|
requirements: []
|
88
|
-
|
89
|
-
rubygems_version: 2.6.14
|
102
|
+
rubygems_version: 3.0.3
|
90
103
|
signing_key:
|
91
104
|
specification_version: 4
|
92
105
|
summary: RELAX NG schema validation using the Jing CLI
|