Skip to content

Commit 831b63a

Browse files
committed
Finish 3.1.0
2 parents 115bdcd + 87f6df2 commit 831b63a

10 files changed

Lines changed: 61 additions & 71 deletions

File tree

.travis.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
language: ruby
2-
bundler_args: --without debug
32
script: "bundle exec rspec spec"
43
env:
54
- CI=true
65
rvm:
7-
- 2.2
8-
- 2.3
96
- 2.4
10-
- jruby-9
11-
- rbx-3
7+
- 2.5
8+
- 2.6
9+
- 2.7
10+
- jruby
1211
cache: bundler
1312
sudo: false
1413
matrix:
1514
allow_failures:
16-
- rvm: jruby-9
17-
- rvm: rbx-3
15+
- rvm: jruby
1816
dist: trusty

Gemfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source "http://rubygems.org"
33
gemspec
44

55
gem 'rdf', github: "ruby-rdf/rdf", branch: "develop"
6-
gem 'ebnf', github: "gkellogg/ebnf", branch: "develop"
6+
gem 'ebnf', github: "dryruby/ebnf", branch: "develop"
77

88
group :debug do
99
gem "byebug", platforms: :mri
@@ -21,13 +21,7 @@ group :development, :test do
2121
gem 'sparql-client', github: "ruby-rdf/sparql-client", branch: "develop"
2222
gem 'sxp', github: "dryruby/sxp.rb", branch: "develop"
2323
gem 'rest-client-components'
24-
gem 'simplecov', require: false
25-
gem 'coveralls', require: false
24+
gem 'simplecov', platforms: :mri
25+
gem 'coveralls', '~> 0.8', platforms: :mri
2626
gem 'psych', platforms: [:mri, :rbx]
2727
end
28-
29-
platforms :rbx do
30-
gem 'rubysl', '~> 2.0'
31-
gem 'rubinius', '~> 2.0'
32-
gem 'json'
33-
end

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) (~> 2.0)
78-
* [EBNF][] (~> 1.0)
79-
* [SPARQL][] (~> 2.0)
80-
* [SXP][] (~> 0.1.6)
81-
* [RDF::XSD][] (~> 2.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 & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,26 @@ Gem::Specification.new do |gem|
1616
gem.platform = Gem::Platform::RUBY
1717
gem.files = %w(AUTHORS README.md LICENSE VERSION bin/ldpatch) + Dir.glob('lib/**/*.rb')
1818
gem.require_paths = %w(lib)
19-
gem.has_rdoc = false
2019
gem.description = %(
2120
Implements the W3C Linked Data Patch Format and operations for RDF.rb.
2221
Makes use of the SPARQL gem for performing updates.)
2322

24-
gem.required_ruby_version = '>= 2.2.2'
23+
gem.required_ruby_version = '>= 2.4'
2524
gem.requirements = []
26-
#gem.add_runtime_dependency 'rdf', '~> 3.0'
27-
gem.add_runtime_dependency 'rdf', '>= 2.2', '< 4.0'
28-
gem.add_runtime_dependency 'ebnf', '~> 1.1'
29-
#gem.add_runtime_dependency 'sparql', '~> 3.0'
30-
gem.add_runtime_dependency 'sparql', '>= 2.2', '< 4.0'
31-
gem.add_runtime_dependency 'sxp', '~> 1.0'
32-
#gem.add_runtime_dependency 'rdf-xsd', '~> 3.0'
33-
gem.add_runtime_dependency 'rdf-xsd', '>= 2.2', '< 4.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'
3430

35-
#gem.add_development_dependency 'json-ld', '~> 2.0'
36-
gem.add_development_dependency 'json-ld', '>= 2.1', '< 4.0'
37-
gem.add_development_dependency 'rack', '~> 1.6'
38-
#gem.add_development_dependency 'rdf-spec', '~> 2.0'
39-
gem.add_development_dependency 'rdf-spec', '>= 2.2', '< 4.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'
4034
gem.add_development_dependency 'open-uri-cached', '~> 0.0', '>= 0.0.5'
41-
gem.add_development_dependency 'rspec', '~> 3.7'
42-
gem.add_development_dependency 'rspec-its', '~> 1.2'
43-
gem.add_development_dependency 'yard' , '~> 0.9'
44-
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'
4539

4640
gem.post_install_message = nil
4741
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: 10 additions & 9 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
@@ -44,6 +44,7 @@ def self.open_file(filename_or_url, options = {}, &block)
4444
}
4545
#puts "use #{filename_or_url} locally"
4646
document_options[:headers][:content_type] = case filename_or_url.to_s
47+
when /\.nt$/ then 'application/n-triples'
4748
when /\.ttl$/ then 'text/turtle'
4849
when /\.ldpatch$/ then 'text/ldpatch'
4950
else 'unknown'
@@ -53,14 +54,14 @@ def self.open_file(filename_or_url, options = {}, &block)
5354
# For overriding content type from test data
5455
document_options[:headers][:content_type] = options[:contentType] if options[:contentType]
5556

56-
remote_document = RDF::Util::File::RemoteDocument.new(response.read, document_options)
57+
remote_document = RDF::Util::File::RemoteDocument.new(response.read, **document_options)
5758
if block_given?
5859
yield remote_document
5960
else
6061
remote_document
6162
end
6263
else
63-
original_open_file(filename_or_url, options) do |rd|
64+
original_open_file(filename_or_url, **options) do |rd|
6465
# Override content_type
6566
if options[:contentType]
6667
rd.headers[:content_type] = options[:contentType]
@@ -112,7 +113,7 @@ def self.open(file)
112113
g = RDF::Repository.load(file, format: :ttl)
113114
JSON::LD::API.fromRDF(g) do |expanded|
114115
JSON::LD::API.frame(expanded, FRAME) do |framed|
115-
yield Manifest.new(framed['@graph'].first)
116+
yield Manifest.new(framed)
116117
end
117118
end
118119
end
@@ -142,23 +143,23 @@ def input
142143
when Hash then action['patch']
143144
else action
144145
end
145-
@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}
146147
end
147148

148149
def data
149150
action.is_a?(Hash) && action["data"]
150151
end
151152

152153
def target_graph
153-
@graph ||= RDF::Graph.load(URI.decode(data), base_uri: base)
154+
@graph ||= RDF::Graph.load(CGI.unescape(data), base_uri: base)
154155
end
155156

156157
def expected
157-
@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}
158159
end
159160

160161
def expected_graph
161-
@expected_graph ||= RDF::Graph.load(URI.decode(result), base_uri: base)
162+
@expected_graph ||= RDF::Graph.load(CGI.unescape(result), base_uri: base)
162163
end
163164

164165
def evaluate?

0 commit comments

Comments
 (0)