ruby-jing 0.0.1 → 0.0.2

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +2 -1
  3. data/lib/jing.rb +17 -10
  4. data/test/test_jing.rb +2 -2
  5. metadata +14 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d008f4db22a52baedf6f25339cd24ba6e9848ea
4
- data.tar.gz: 3ac4428cf7a0d8c372a401e4585f2c13bc1d8ba9
3
+ metadata.gz: 19b9643f4db8f71aa3ef7df70166632203585784
4
+ data.tar.gz: 7df428f044ebfae4cffcf95f0cf1adca60227782
5
5
  SHA512:
6
- metadata.gz: d4d4a4682496576208a44f81ca98fdd712067f874d35747881f8a966f05061b59c9d62c3b643225bd19b115785b1f9a22279675fe4acad91c73ec6b7a255822b
7
- data.tar.gz: bd73c441aa2ac74bca835316823624234fc1af79d2237847f4e4d4740f1393b915a33f23ee3f30c743f91bd60030d9dc37a1a64c0f92cacf2e139dbd2146eaa4
6
+ metadata.gz: be774aaf821cd382797c28b93146db7da50b114fc357c86bfefbd6e46a4d825f97c27ea88184634b4d08970a84af337852b1e697c95cdc73bce4b4d048b67c39
7
+ data.tar.gz: f49cdcd0d6fa805f8530a8d2f531619885afbcdd3c614e4cd876c61f1e9906d9ff5ef9e929a407bff568ef886e5f79605b6ddfa681ca517badd456e777935c1a
data/README.rdoc CHANGED
@@ -12,7 +12,7 @@ RELAX NG schema validation using the {Jing CLI}[http://www.thaiopensource.com/re
12
12
  jing = Jing.new("schema.rng")
13
13
  begin
14
14
  errors = jing.validate("doc.xml")
15
- rescue Jing::OptionError, Jing::ExecutionError => e
15
+ rescue Jing::Error => e
16
16
  abort "what what what #{e}"
17
17
  end
18
18
 
@@ -112,6 +112,7 @@ Better, don't ya think?
112
112
 
113
113
  * {Docs}[http://rdoc.info/gems/ruby-jing/frames]
114
114
  * {Bugs}[http://github.com/sshaw/ruby-jing/issues]
115
+ * {Source}[http://github.com/sshaw/ruby-jing]
115
116
 
116
117
  === Author
117
118
 
data/lib/jing.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "optout"
2
2
 
3
3
  class Jing
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  DEFAULT_JAR = File.join(File.dirname(__FILE__), "jing-20091111.jar")
6
6
 
7
7
  Error = Class.new(StandardError)
@@ -10,6 +10,7 @@ class Jing
10
10
 
11
11
  @@option_builder = Optout.options do
12
12
  on :java, :required => true, :default => "java"
13
+ on :java_opts, String
13
14
  on :jar, "-jar", Optout::File.exists, :default => DEFAULT_JAR
14
15
  on :compact, "-c", Optout::Boolean
15
16
  on :encoding, "-e", String
@@ -35,7 +36,7 @@ class Jing
35
36
  # [:compact (Boolean)] Set to +true+ if the schema uses the RELAX NG compact syntax. Defaults to false, will be set to +true+ is the schema has a +.rnc+ extension.
36
37
  # [:encoding (String)] Encoding of the XML document.
37
38
  # [:id_check (Boolean)] Disable checking of ID/IDREF/IDREFS. Defaults to +false+
38
-
39
+ #
39
40
  # === Errors
40
41
  #
41
42
  # [ArgumentError] If the options are not +nil+ or a +Hash+.
@@ -51,6 +52,9 @@ class Jing
51
52
  @options[:compact] = true if @options[:compact].nil? and @options[:schema] =~ /\.rnc\Z/i # Don't override an explicit setting
52
53
  # Optout quirk: true will *include* the switch, which means we *don't* want to check
53
54
  @options[:id_check] = !@options[:id_check] if @options.include?(:id_check)
55
+ if @options[:encoding]
56
+ @options[:java_opts] = "-Dfile.encoding=#{@options[:encoding]}"
57
+ end
54
58
  end
55
59
 
56
60
  ##
@@ -90,7 +94,7 @@ class Jing
90
94
  errors
91
95
  end
92
96
 
93
- # Validate an XML document against the schema. To receive a list of vlidation errors use #validate.
97
+ # Validate an XML document against the schema. To receive a list of validation errors use #validate.
94
98
  #
95
99
  # puts "yay!" if jing.valid?("doc.xml")
96
100
  #
@@ -124,16 +128,19 @@ class Jing
124
128
 
125
129
  def parse_output(output)
126
130
  errors = []
127
- output.split("\n").map do |line|
131
+ output.split("\n").each do |line|
128
132
  if line =~ /\A(.+):(\d+):(\d+):\s+\w+:\s+(.+)\Z/
129
- errors << {
130
- :source => $1,
131
- :line => $2.to_i,
132
- :column => $3.to_i,
133
- :message => $4
134
- }
133
+ errors << {
134
+ :source => $1,
135
+ :line => $2.to_i,
136
+ :column => $3.to_i,
137
+ :message => $4
138
+ }
135
139
  end
136
140
  end
137
141
  errors
142
+ rescue ArgumentError => e
143
+ raise ExecutionError, "potentially wrong encoding of jing output." \
144
+ "try setting the file's encoding via the :encoding option: #{e}"
138
145
  end
139
146
  end
data/test/test_jing.rb CHANGED
@@ -43,7 +43,7 @@ class TestJing < MiniTest::Unit::TestCase
43
43
  def test_encoding_option
44
44
  enc = "iso-8859-1"
45
45
  cmd = fakeshell { Jing.new(RNG_SCHEMA, :encoding => enc).validate(VALID_XML) }
46
- assert_match /\A'java'\s+ -jar\s+ '#{Jing::DEFAULT_JAR}'\s+ -e\s+ '#{enc}'/x, cmd
46
+ assert_match /\A'java'\s+ '-Dfile.encoding=#{enc}'\s+ -jar\s+ '#{Jing::DEFAULT_JAR}'\s+ -e\s+ '#{enc}'/x, cmd
47
47
  end
48
48
 
49
49
  def test_id_check_option
@@ -100,7 +100,7 @@ class TestJing < MiniTest::Unit::TestCase
100
100
  assert_equal 1, errors.size
101
101
 
102
102
  err = errors[0]
103
- assert_equal INVALID_XML, err[:source]
103
+ assert_equal INVALID_XML, Pathname.new(err[:source]).cleanpath.to_s
104
104
  assert_equal 4, err[:line]
105
105
  assert_match /\A\d\d?\z/, err[:column].to_s
106
106
  assert_match /\bemail\b/, err[:message]
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-jing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Skye Shaw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-04 00:00:00.000000000 Z
11
+ date: 2021-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: optout
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.0.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.0.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 0.9.2
33
+ version: 12.3.3
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 0.9.2
40
+ version: 12.3.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '4.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4.0'
55
55
  description: |2
@@ -62,10 +62,10 @@ extensions: []
62
62
  extra_rdoc_files:
63
63
  - README.rdoc
64
64
  files:
65
+ - README.rdoc
65
66
  - lib/jing-20091111.jar
66
67
  - lib/jing.rb
67
68
  - test/test_jing.rb
68
- - README.rdoc
69
69
  homepage: http://github.com/sshaw/ruby-jing
70
70
  licenses:
71
71
  - MIT
@@ -76,17 +76,17 @@ require_paths:
76
76
  - lib
77
77
  required_ruby_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - '>='
84
+ - - ">="
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
88
  rubyforge_project:
89
- rubygems_version: 2.0.6
89
+ rubygems_version: 2.6.14
90
90
  signing_key:
91
91
  specification_version: 4
92
92
  summary: RELAX NG schema validation using the Jing CLI