Skip to content

Commit 04a6144

Browse files
committed
Finish 3.3.1
2 parents b0422b3 + 76cfd99 commit 04a6144

File tree

7 files changed

+67
-37
lines changed

7 files changed

+67
-37
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
ruby: ['3.0', 3.1, 3.2, ruby-head, jruby]
22+
ruby: ['3.0', 3.1, 3.2, 3.3, ruby-head, jruby]
2323
steps:
2424
- name: Clone repository
2525
uses: actions/checkout@v3
@@ -33,6 +33,6 @@ jobs:
3333
run: ruby --version; bundle exec rspec spec || $ALLOW_FAILURES
3434
- name: Coveralls GitHub Action
3535
uses: coverallsapp/github-action@v2
36-
if: "matrix.ruby == '3.2'"
36+
if: "matrix.ruby == '3.3'"
3737
with:
3838
github-token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,15 @@ The parser takes branch and follow tables generated from the [LD Patch Grammar](
7676

7777
* [Ruby](http://ruby-lang.org/) (>= 3.0)
7878
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.3)
79-
* [EBNF][] (~> 2.4)
79+
* [EBNF][] (~> 2.5)
8080
* [SPARQL][] (~> 3.2)
81-
* [SXP][] (~> 1.2)
81+
* [SXP][] (~> 2.0)
8282
* [RDF::XSD][] (~> 3.2)
8383

84+
## Change Log
85+
86+
See [Release Notes on GitHub](https://github.com/ruby-rdf/ld-patch/releases)
87+
8488
## Mailing List
8589
* <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
8690

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.0
1+
3.3.1

ld-patch.gemspec

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,20 @@ Gem::Specification.new do |gem|
3030
gem.required_ruby_version = '>= 3.0'
3131
gem.requirements = []
3232
gem.add_runtime_dependency 'rdf', '~> 3.3'
33-
gem.add_runtime_dependency 'ebnf', '~> 2.4'
33+
gem.add_runtime_dependency 'ebnf', '~> 2.6'
3434
gem.add_runtime_dependency 'sparql', '~> 3.3'
35-
gem.add_runtime_dependency 'sxp', '~> 1.3'
35+
gem.add_runtime_dependency 'sxp', '~> 2.0'
3636
gem.add_runtime_dependency 'rdf-xsd', '~> 3.3'
3737

38+
gem.add_development_dependency 'getoptlong', '~> 0.2'
3839
gem.add_development_dependency 'json-ld', '~> 3.3'
39-
gem.add_development_dependency 'rack', '>= 2.2', '< 4'
40+
gem.add_development_dependency 'rack', '~> 3.1'
4041
gem.add_development_dependency 'rdf-normalize', '~> 0.7'
4142
gem.add_development_dependency 'rdf-spec', '~> 3.3'
42-
gem.add_development_dependency 'rspec', '~> 3.12'
43+
gem.add_development_dependency 'rspec', '~> 3.13'
4344
gem.add_development_dependency 'rspec-its', '~> 1.3'
4445
gem.add_development_dependency 'yard' , '~> 0.9'
45-
gem.add_development_dependency 'webmock', '~> 3.19'
46+
gem.add_development_dependency 'webmock', '~> 3.15'
4647

4748
gem.post_install_message = nil
4849
end

lib/ld/patch/parser.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,14 @@ def iri(value)
539539
def ns(prefix, suffix)
540540
error("pname", "undefined prefix #{prefix.inspect}") unless prefix(prefix)
541541
base = prefix(prefix).to_s
542+
543+
# Unescape PN_LOCAL_ESC
544+
suffix = suffix.gsub(PN_LOCAL_ESC) {|esc| esc[1]} if
545+
suffix.to_s.match?(PN_LOCAL_ESC)
546+
547+
# Remove any redundant leading hash from suffix
542548
suffix = suffix.to_s.sub(/^\#/, "") if base.index("#")
549+
543550
debug {"ns(#{prefix.inspect}): base: '#{base}', suffix: '#{suffix}'"}
544551
iri = iri(base + suffix.to_s)
545552
# Cause URI to be serialized as a lexical

script/tc

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,50 +27,60 @@ def earl_preamble(options)
2727
)
2828
end
2929

30-
def run_tc(t, options)
31-
STDERR.write "run #{t.name}"
30+
def run_tc(tc, options)
31+
STDERR.write "run #{tc.name}"
32+
33+
if options[:verbose]
34+
puts "\nTestCase: #{tc.inspect}"
35+
puts "\nInput:\n" + tc.input
36+
puts "\nData:\n" + tc.data if tc.data
37+
puts "\nExpected:\n" + tc.expected if tc.expected
38+
end
39+
3240
result = "untested"
3341

3442
begin
35-
operator = LD::Patch.parse(t.input,
36-
base_uri: t.base,
43+
operator = LD::Patch.parse(tc.input,
44+
base_uri: tc.base,
3745
validate: true,
3846
errors: []
3947
)
40-
if t.positive_test?
41-
if t.evaluate?
42-
ug = operator.execute(t.target_graph)
43-
result = t.target_graph.isomorphic_with?(t.expected_graph) ? "passed" : "failed"
48+
if tc.positive_test?
49+
if tc.evaluate?
50+
ug = operator.execute(tc.target_graph)
51+
result = tc.target_graph.isomorphic_with?(tc.expected_graph) ? "passed" : "failed"
4452
else
4553
result = operator.is_a?(SPARQL::Algebra::Operator) ? "passed" : "failed"
4654
end
4755
else
48-
operator.execute(t.target_graph) if t.evaluate?
49-
if %w(turtle-syntax-bad-struct-09 turtle-syntax-bad-struct-10).include?(t.name)
56+
operator.execute(tc.target_graph) if tc.evaluate?
57+
if %w(turtle-syntax-bad-struct-09 turtle-syntax-bad-struct-10).include?(tc.name)
5058
STDERR.puts "Multiple '.' allowed in this grammar" unless options[:quiet]
5159
result = "inapplicable"
5260
else
5361
result = "failed"
5462
end
5563
end
5664
rescue LD::Patch::ParseError => e
57-
if %w(turtle-eval-bad-01 turtle-eval-bad-02 turtle-eval-bad-03).include?(t.name)
65+
if %w(turtle-eval-bad-01 turtle-eval-bad-02 turtle-eval-bad-03).include?(tc.name)
5866
result = "passed"
59-
elsif t.syntax? && t.negative_test?
67+
elsif tc.syntax? && tc.negative_test?
6068
result = "passed"
6169
else
70+
STDERR.puts "#{"exception:" unless options[:quiet]}: #{e}"
6271
result = "failed"
6372
end
6473
rescue LD::Patch::Error => e
65-
if t.evaluate? && t.negative_test?
66-
result = e.code == t.statusCode.to_i ? "passed" : "failed"
74+
if tc.evaluate? && tc.negative_test?
75+
result = e.code == tc.statusCode.to_i ? "passed" : "failed"
6776
else
6877
result = "failed"
6978
end
79+
STDERR.puts "#{"exception:" unless options[:quiet]}: #{e}" if result == "failed"
7080
end
7181

7282
if options[:earl]
73-
test = t.id.sub("ldp:", Fixtures::SuiteTest::BASE + "manifest.ttl#")
83+
test = tc.id.sub("ldp:", Fixtures::SuiteTest::BASE + "manifest.ttl#")
7484
options[:output].puts %{
7585
[ a earl:Assertion;
7686
earl:assertedBy <#{ASSERTOR}>;
@@ -95,7 +105,7 @@ options = {
95105
validate: true,
96106
verbose: false,
97107
}
98-
suite = "rdfxml"
108+
99109
opts = GetoptLong.new(
100110
["--debug", GetoptLong::NO_ARGUMENT],
101111
["--earl", GetoptLong::NO_ARGUMENT],
@@ -135,7 +145,7 @@ result_count = {}
135145

136146
Fixtures::SuiteTest::Manifest.open(manifest) do |m|
137147
m.entries.each do |tc|
138-
next unless ARGV.empty? || ARGV.any? {|n| tc.name.match(/#{n}/)}
148+
next unless ARGV.empty? || ARGV.any? {|n| tc.name.match?(/#{n}/)}
139149
run_tc(tc, options.merge(result_count: result_count))
140150
end
141151
end

spec/suite_helper.rb

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ module SuiteTest
110110
class Manifest < JSON::LD::Resource
111111
def self.open(file)
112112
#puts "open: #{file}"
113-
prefixes = {}
114113
g = RDF::Repository.load(file, format: :ttl)
115114
JSON::LD::API.fromRDF(g) do |expanded|
116115
JSON::LD::API.frame(expanded, FRAME) do |framed|
@@ -149,35 +148,35 @@ def input
149148
end
150149

151150
def data
152-
action.is_a?(Hash) && action["data"]
151+
@data ||= RDF::Util::File.open_file(CGI.unescape(action["data"])) {|f| f.read} if action["data"]
153152
end
154153

155154
def target_graph
156155
@graph ||= RDF::Graph.new do |g|
157-
g << RDF::Reader.open(CGI.unescape(data), base_uri: base)
156+
g << RDF::Reader.open(CGI.unescape(action["data"]), base_uri: base) if action["data"]
158157
end
159158
end
160159

161160
def expected
162-
@expected ||= RDF::Util::File.open_file(CGI.unescape(result)) {|f| f.read}
161+
@expected ||= RDF::Util::File.open_file(CGI.unescape(result)) {|f| f.read} if result
163162
end
164163

165164
def expected_graph
166165
@expected_graph ||= RDF::Graph.new do |g|
167-
g << RDF::Reader.open(CGI.unescape(result), base_uri: base)
166+
g << RDF::Reader.open(CGI.unescape(result), base_uri: base) if result
168167
end
169168
end
170169

171170
def evaluate?
172-
Array(attributes['@type']).join(" ").match(/Eval/)
171+
Array(attributes['@type']).join(" ").match?(/Eval/)
173172
end
174173

175174
def syntax?
176-
Array(attributes['@type']).join(" ").match(/Syntax/)
175+
Array(attributes['@type']).join(" ").match?(/Syntax/)
177176
end
178177

179178
def positive_test?
180-
!Array(attributes['@type']).join(" ").match(/Negative/)
179+
!Array(attributes['@type']).join(" ").match?(/Negative/)
181180
end
182181

183182
def negative_test?
@@ -194,12 +193,21 @@ def logger
194193
end
195194

196195
def inspect
197-
super.sub('>', "\n" +
196+
"<Entry id\n" +
197+
" id: #{self.id}\n" +
198+
" type: #{self.type}\n" +
199+
" name: #{self.name}\n" +
200+
(self.action.is_a?(Hash) ?
201+
" action.base: #{self.action['base']}\n" +
202+
" action.data: #{self.action['data']}\n" +
203+
" action.patch: #{self.action['patch']}\n"
204+
: " action: #{self.action}"
205+
) +
206+
" result: #{self.result}\n" +
198207
" syntax?: #{syntax?.inspect}\n" +
199208
" positive?: #{positive_test?.inspect}\n" +
200209
" evaluate?: #{evaluate?.inspect}\n" +
201210
">"
202-
)
203211
end
204212
end
205213
end

0 commit comments

Comments
 (0)