Skip to content

Commit 84fd24a

Browse files
committed
Updates for 3.1 release and Ruby 2.7 calling sequences.
1 parent 8e30a73 commit 84fd24a

9 files changed

Lines changed: 54 additions & 58 deletions

File tree

.travis.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
language: ruby
22
bundler_args: --without debug
33
script: "bundle exec rspec spec"
4-
before_install:
5-
- 'gem update --system --conservative || (gem i "rubygems-update:~>2.7" --no-document && update_rubygems)'
6-
- 'gem update bundler --conservative'
74
env:
85
- CI=true
96
rvm:
10-
- 2.2
11-
- 2.3
127
- 2.4
138
- 2.5
149
- 2.6
15-
- jruby-9
16-
- rbx-3
10+
- 2.7
11+
- jruby
1712
cache: bundler
1813
sudo: false
1914
matrix:
2015
allow_failures:
21-
- rvm: jruby-9
22-
- rvm: rbx-3
16+
- rvm: jruby
2317
dist: trusty

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This gem implements the [LD Patch][] specification with a couple of changes and/
2424
* 100% free and unencumbered [public domain](http://unlicense.org/) software.
2525
* Complete [Linked Data Patch Format][LD Patch] parsing and execution
2626
* Implementation Report: {file:etc/earl.html EARL}
27-
* Compatible with Ruby >= 2.2.2.
27+
* Compatible with Ruby >= 2.4.
2828

2929
## Documentation
3030
Full documentation available on [Rubydoc.info][LD-Patch doc]
@@ -73,12 +73,12 @@ The parser takes branch and follow tables generated from the [LD Patch Grammar](
7373

7474
## Dependencies
7575

76-
* [Ruby](http://ruby-lang.org/) (>= 2.2.2)
77-
* [RDF.rb](http://rubygems.org/gems/rdf) (~> 3.0)
78-
* [EBNF][] (~> 1.1)
79-
* [SPARQL][] (~> 3.0)
80-
* [SXP][] (~> 1.0)
81-
* [RDF::XSD][] (~> 3.0)
76+
* [Ruby](http://ruby-lang.org/) (>= 2.4)
77+
* [RDF.rb](http://rubygems.org/gems/rdf) (~> 3.1)
78+
* [EBNF][] (~> 1.2)
79+
* [SPARQL][] (~> 3.1)
80+
* [SXP][] (~> 1.1)
81+
* [RDF::XSD][] (~> 3.1)
8282

8383
## Mailing List
8484
* <http://lists.w3.org/Archives/Public/public-rdf-ruby/>

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.3
1+
3.1.0

ld-patch.gemspec

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,22 @@ Gem::Specification.new do |gem|
2020
Implements the W3C Linked Data Patch Format and operations for RDF.rb.
2121
Makes use of the SPARQL gem for performing updates.)
2222

23-
gem.required_ruby_version = '>= 2.2.2'
23+
gem.required_ruby_version = '>= 2.4'
2424
gem.requirements = []
25-
gem.add_runtime_dependency 'rdf', '~> 3.0'
26-
gem.add_runtime_dependency 'ebnf', '~> 1.1'
27-
gem.add_runtime_dependency 'sparql', '~> 3.0'
28-
gem.add_runtime_dependency 'sxp', '~> 1.0'
29-
gem.add_runtime_dependency 'rdf-xsd', '~> 3.0'
25+
gem.add_runtime_dependency 'rdf', '~> 3.1'
26+
gem.add_runtime_dependency 'ebnf', '~> 1.2'
27+
gem.add_runtime_dependency 'sparql', '~> 3.1'
28+
gem.add_runtime_dependency 'sxp', '~> 1.1'
29+
gem.add_runtime_dependency 'rdf-xsd', '~> 3.1'
3030

31-
#gem.add_development_dependency 'json-ld', '~> 3.0'
32-
gem.add_development_dependency 'json-ld', '>= 2.1', '< 4.0'
33-
gem.add_development_dependency 'rack', '~> 1.6'
34-
gem.add_development_dependency 'rdf-spec', '~> 3.0'
31+
gem.add_development_dependency 'json-ld', '~> 3.1'
32+
gem.add_development_dependency 'rack', '~> 2.0'
33+
gem.add_development_dependency 'rdf-spec', '~> 3.1'
3534
gem.add_development_dependency 'open-uri-cached', '~> 0.0', '>= 0.0.5'
36-
gem.add_development_dependency 'rspec', '~> 3.7'
37-
gem.add_development_dependency 'rspec-its', '~> 1.2'
38-
gem.add_development_dependency 'yard' , '~> 0.9.12'
39-
gem.add_development_dependency 'webmock', '~> 3.0'
35+
gem.add_development_dependency 'rspec', '~> 3.9'
36+
gem.add_development_dependency 'rspec-its', '~> 1.3'
37+
gem.add_development_dependency 'yard' , '~> 0.9.20'
38+
gem.add_development_dependency 'webmock', '~> 3.7'
4039

4140
gem.post_install_message = nil
4241
end

lib/ld/patch.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ module Patch
2828
# the base URI to use when resolving relative URIs
2929
# @option (see LD::Patch::Parser#initialize)
3030
# @return [SPARQL::Algebra::Operator] The executable parsed Patch
31-
def self.parse(input, options = {})
32-
LD::Patch::Parser.new(input, options).parse
31+
def self.parse(input, **options)
32+
LD::Patch::Parser.new(input, **options).parse
3333
end
3434

3535
class Error < StandardError
@@ -42,7 +42,7 @@ class Error < StandardError
4242
# @param [String, #to_s] message
4343
# @param [Hash{Symbol => Object}] options
4444
# @option options [Integer] :code (422)
45-
def initialize(message, options = {})
45+
def initialize(message, **options)
4646
@code = options.fetch(:status_code, 422)
4747
super(message.to_s)
4848
end
@@ -70,7 +70,7 @@ class ParseError < Error
7070
# @option options [String] :token (nil)
7171
# @option options [Integer] :lineno (nil)
7272
# @option options [Integer] :code (400)
73-
def initialize(message, options = {})
73+
def initialize(message, **options)
7474
@token = options[:token]
7575
@lineno = options[:lineno] || (@token.lineno if @token.respond_to?(:lineno))
7676
super(message.to_s, code: options.fetch(:code, 400))

lib/ld/patch/format.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def self.cli_commands
4242
control: :none,
4343
on: ["--patch-input STRING"],
4444
description: "Patch in URI encoded format"
45-
) {|v| URI.decode(v)},
45+
) {|v| CGI.decode(v)},
4646
RDF::CLI::Option.new(
4747
symbol: :patch_file,
4848
datatype: String,

lib/ld/patch/parser.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class Parser
295295
str = lit.delete(:string)
296296
lit[:datatype] = lit.delete(:iri) if lit[:iri]
297297
lit[:language] = lit.delete(:language).last.downcase if lit[:language]
298-
input[:literal] = RDF::Literal.new(str, lit) if str
298+
input[:literal] = RDF::Literal.new(str, **lit) if str
299299
end
300300
end
301301

@@ -323,7 +323,7 @@ class Parser
323323
# @yield [parser] `self`
324324
# @yieldparam [LD::Patch::Parser] parser
325325
# @return [LD::Patch::Parser] The parser instance, or result returned from block
326-
def initialize(input = nil, options = {}, &block)
326+
def initialize(input = nil, **options, &block)
327327
@input = case input
328328
when IO, StringIO then input.read
329329
else input.to_s.dup
@@ -366,10 +366,13 @@ def initialize(input = nil, options = {}, &block)
366366
# @return [SPARQL::Algebra::Operator, Object]
367367
# @raise [ParseError] when illegal grammar detected.
368368
def parse(prod = START)
369-
ll1_parse(@input, prod.to_sym, @options.merge(branch: BRANCH,
370-
first: FIRST,
371-
follow: FOLLOW,
372-
whitespace: WS)
369+
ll1_parse(@input,
370+
prod.to_sym,
371+
branch: BRANCH,
372+
first: FIRST,
373+
follow: FOLLOW,
374+
whitespace: WS,
375+
**@options
373376
) do |context, *data|
374377
case context
375378
when :trace
@@ -545,7 +548,7 @@ def ns(prefix, suffix)
545548
end
546549

547550
# Create a literal
548-
def literal(value, options = {})
551+
def literal(value, **options)
549552
options = options.dup
550553
# Internal representation is to not use xsd:string, although it could arguably go the other way.
551554
options.delete(:datatype) if options[:datatype] == RDF::XSD.string
@@ -554,7 +557,7 @@ def literal(value, options = {})
554557
"options: #{options.inspect}, " +
555558
"validate: #{validate?.inspect}, "
556559
end
557-
RDF::Literal.new(value, options.merge(validate: validate?))
560+
RDF::Literal.new(value, validate: validate?, **options)
558561
end
559562
end
560563
end

spec/matchers.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
array_nl: "\n"
99
)
1010

11-
RSpec::Matchers.define :generate do |expected, options = {}|
11+
RSpec::Matchers.define :generate do |expected, **options|
1212
def parser(options = {})
1313
@debug = options[:progress] ? 2 : []
1414
Proc.new do |input|
15-
parser = LD::Patch::Parser.new(input, {debug: @debug, resolve_iris: false}.merge(options))
15+
parser = LD::Patch::Parser.new(input, debug: @debug, resolve_iris: false, **options)
1616
options[:production] ? parser.parse(options[:production]) : parser.parse
1717
end
1818
end
@@ -31,15 +31,15 @@ def normalize(obj)
3131
match do |input|
3232
case
3333
when expected == LD::Patch::ParseError
34-
expect {parser(options).call(input)}.to raise_error(expected)
34+
expect {parser(**options).call(input)}.to raise_error(expected)
3535
when expected.is_a?(Regexp)
36-
@actual = parser(options).call(input)
36+
@actual = parser(**options).call(input)
3737
expect(normalize(@actual.to_sxp)).to match(expected)
3838
when expected.is_a?(String)
39-
@actual = parser(options).call(input)
39+
@actual = parser(**options).call(input)
4040
expect(normalize(@actual.to_sxp)).to eq normalize(expected)
4141
else
42-
@actual = parser(options).call(input)
42+
@actual = parser(**options).call(input)
4343
expect(@actual).to eq expected
4444
end
4545
end

spec/suite_helper.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class << self
2222
# HTTP Request headers.
2323
# @return [IO] File stream
2424
# @yield [IO] File stream
25-
def self.open_file(filename_or_url, options = {}, &block)
25+
def self.open_file(filename_or_url, **options, &block)
2626
case
2727
when filename_or_url.to_s =~ /^file:/
2828
path = filename_or_url[5..-1]
29-
Kernel.open(path.to_s, options, &block)
29+
Kernel.open(path.to_s, **options, &block)
3030
when (filename_or_url.to_s =~ %r{^#{REMOTE_PATH}} && Dir.exist?(LOCAL_PATH))
3131
localpath = RDF::URI(filename_or_url).dup
3232
localpath.query = nil
@@ -54,14 +54,14 @@ def self.open_file(filename_or_url, options = {}, &block)
5454
# For overriding content type from test data
5555
document_options[:headers][:content_type] = options[:contentType] if options[:contentType]
5656

57-
remote_document = RDF::Util::File::RemoteDocument.new(response.read, document_options)
57+
remote_document = RDF::Util::File::RemoteDocument.new(response.read, **document_options)
5858
if block_given?
5959
yield remote_document
6060
else
6161
remote_document
6262
end
6363
else
64-
original_open_file(filename_or_url, options) do |rd|
64+
original_open_file(filename_or_url, **options) do |rd|
6565
# Override content_type
6666
if options[:contentType]
6767
rd.headers[:content_type] = options[:contentType]
@@ -143,23 +143,23 @@ def input
143143
when Hash then action['patch']
144144
else action
145145
end
146-
@input ||= RDF::Util::File.open_file(URI.decode(url)) {|f| f.read}
146+
@input ||= RDF::Util::File.open_file(CGI.unescape(url)) {|f| f.read}
147147
end
148148

149149
def data
150150
action.is_a?(Hash) && action["data"]
151151
end
152152

153153
def target_graph
154-
@graph ||= RDF::Graph.load(URI.decode(data), base_uri: base)
154+
@graph ||= RDF::Graph.load(CGI.unescape(data), base_uri: base)
155155
end
156156

157157
def expected
158-
@expected ||= RDF::Util::File.open_file(URI.decode(result)) {|f| f.read}
158+
@expected ||= RDF::Util::File.open_file(CGI.unescape(result)) {|f| f.read}
159159
end
160160

161161
def expected_graph
162-
@expected_graph ||= RDF::Graph.load(URI.decode(result), base_uri: base)
162+
@expected_graph ||= RDF::Graph.load(CGI.unescape(result), base_uri: base)
163163
end
164164

165165
def evaluate?

0 commit comments

Comments
 (0)