Skip to content

Commit

Permalink
Finish 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 16, 2019
2 parents 548b4c6 + 69532cd commit 784de72
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 79 deletions.
13 changes: 3 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
language: ruby
bundler_args: --without debug
script: "bundle exec rspec spec"
before_install:
- 'gem update --system --conservative || (gem i "rubygems-update:~>2.7" --no-document && update_rubygems)'
- 'gem update bundler --conservative'
env:
- CI=true
rvm:
- 2.2.2
- 2.3
- 2.4
- 2.5
- 2.6
- jruby-9
- rbx-3
- 2.7
- jruby
cache: bundler
sudo: false
matrix:
allow_failures:
- rvm: jruby-9
- rvm: rbx-3
- rvm: jruby
dist: trusty
21 changes: 12 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ source "https://rubygems.org"

gemspec

gem "rdf", git: "https://github.com/ruby-rdf/rdf", branch: "develop"
gem "rdf", git: "https://github.com/ruby-rdf/rdf", branch: "develop"

group :development do
gem "rdf-spec", git: "https://github.com/ruby-rdf/rdf-spec", branch: "develop"
gem "rdf-isomorphic", git: "https://github.com/ruby-rdf/rdf-isomorphic", branch: "develop"
gem "rdf-trig", git: "https://github.com/ruby-rdf/rdf-trig", branch: "develop"
gem 'rdf-vocab', git: "https://github.com/ruby-rdf/rdf-vocab", branch: "develop"
gem "rdf-xsd", git: "https://github.com/ruby-rdf/rdf-xsd", branch: "develop"
gem "json-ld", git: "https://github.com/ruby-rdf/json-ld", branch: "develop"
gem 'sparql', git: "https://github.com/ruby-rdf/sparql", branch: "develop"
gem 'sxp', git: "https://github.com/dryruby/sxp.rb", branch: "develop"
gem "ebnf", git: "https://github.com/dryruby/ebnf", branch: "develop"
gem "rdf-aggregate-repo", git: "https://github.com/ruby-rdf/rdf-aggregate-repo", branch: "develop"
gem "rdf-spec", git: "https://github.com/ruby-rdf/rdf-spec", branch: "develop"
gem "rdf-isomorphic", git: "https://github.com/ruby-rdf/rdf-isomorphic", branch: "develop"
gem "rdf-trig", git: "https://github.com/ruby-rdf/rdf-trig", branch: "develop"
gem "rdf-turtle", git: "https://github.com/ruby-rdf/rdf-turtle", branch: "develop"
gem 'rdf-vocab', git: "https://github.com/ruby-rdf/rdf-vocab", branch: "develop"
gem "rdf-xsd", git: "https://github.com/ruby-rdf/rdf-xsd", branch: "develop"
gem "json-ld", git: "https://github.com/ruby-rdf/json-ld", branch: "develop"
gem 'sparql', git: "https://github.com/ruby-rdf/sparql", branch: "develop"
gem 'sxp', git: "https://github.com/dryruby/sxp.rb", branch: "develop"
end

group :debug do
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.0
3.1.1
17 changes: 0 additions & 17 deletions lib/rdf/n3/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,4 @@ def to_sxp
to_sxp_bin.to_sxp
end
end

class Query::Variable

# Transform Statement into an SXP
# @return [Array]
def to_sxp_bin
[:var, name, (value.to_sxp_bin if value)].compact
end

##
# Returns an S-Expression (SXP) representation
#
# @return [String]
def to_sxp
to_sxp_bin.to_sxp
end
end
end
2 changes: 1 addition & 1 deletion lib/rdf/n3/patches/array_hacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def permute(prefixed=[])
# * <tt>:words_connector</tt> - The sign or word used to join the elements in arrays with two or more elements (default: ", ")
# * <tt>:two_words_connector</tt> - The sign or word used to join the elements in arrays with two elements (default: " and ")
# * <tt>:last_word_connector</tt> - The sign or word used to join the last element in arrays with three or more elements (default: ", and ")
def to_sentence(options = {})
def to_sentence(**options)
default_words_connector = ", "
default_two_words_connector = " and "
default_last_word_connector = ", and "
Expand Down
4 changes: 2 additions & 2 deletions lib/rdf/n3/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Reader < RDF::Reader
# @yieldparam [RDF::Reader] reader
# @yieldreturn [void] ignored
# @raise [Error]:: Raises RDF::ReaderError if validating and an error is found
def initialize(input = $stdin, options = {}, &block)
def initialize(input = $stdin, **options, &block)
super do
input.rewind if input.respond_to?(:rewind)
@input = input.respond_to?(:read) ? input : StringIO.new(input.to_s)
Expand Down Expand Up @@ -704,7 +704,7 @@ def uri(value, append = nil)
value = value.join(append) if append
value.validate! if validate? && value.respond_to?(:validate)
value.canonicalize! if canonicalize?
value = RDF::URI.intern(value, {}) if intern?
value = RDF::URI.intern(value) if intern?

# Variable substitution for in-scope variables. Variables are in scope if they are defined in anthing other than the current formula
var = find_var(@formulae.last, value)
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/n3/reasoner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def initialize(input, **options, &block)
else RDF::Repository.new
end

log_debug("reasoner: expression", options) {SXP::Generator.string(formula.to_sxp_bin)}
log_debug("reasoner: expression", **options) {SXP::Generator.string(formula.to_sxp_bin)}

if block_given?
case block.arity
Expand Down
18 changes: 9 additions & 9 deletions lib/rdf/n3/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def self.options
# @yieldreturn [void]
# @yield [writer]
# @yieldparam [RDF::Writer] writer
def initialize(output = $stdout, options = {}, &block)
def initialize(output = $stdout, **options, &block)
@repo = RDF::Repository.new
@uri_to_pname = {}
@uri_to_prefix = {}
Expand Down Expand Up @@ -259,7 +259,7 @@ def sort_properties(properties)
# @param [RDF::Literal, String, #to_s] literal
# @param [Hash{Symbol => Object}] options
# @return [String]
def format_literal(literal, options = {})
def format_literal(literal, **options)
literal = literal.dup.canonicalize! if @options[:canonicalize]
case literal
when RDF::Literal
Expand All @@ -285,7 +285,7 @@ def format_literal(literal, options = {})
# @param [RDF::URI] uri
# @param [Hash{Symbol => Object}] options
# @return [String]
def format_uri(uri, options = {})
def format_uri(uri, **options)
md = uri.relativize(base_uri)
log_debug("relativize") {"#{uri.to_sxp} => #{md.inspect}"} if md != uri.to_s
md != uri.to_s ? "<#{md}>" : (get_pname(uri) || "<#{uri}>")
Expand All @@ -297,7 +297,7 @@ def format_uri(uri, options = {})
# @param [RDF::Node] node
# @param [Hash{Symbol => Object}] options
# @return [String]
def format_node(node, options = {})
def format_node(node, **options)
options[:unique_bnodes] ? node.to_unique_base : node.to_base
end

Expand Down Expand Up @@ -349,7 +349,7 @@ def order_subjects

# Add distinguished classes
top_classes.each do |class_uri|
graph.query(predicate: RDF.type, object: class_uri).
graph.query({predicate: RDF.type, object: class_uri}).
map {|st| st.subject}.
sort.
uniq.
Expand Down Expand Up @@ -504,7 +504,7 @@ def p_term(resource, position)
elsif resource == RDF.nil
"()"
else
format_term(resource, options)
format_term(resource, **options)
end
@output.write(l)
end
Expand Down Expand Up @@ -566,7 +566,7 @@ def predicateObjectList(subject, from_bpl = false)
(properties[st.predicate.to_s] ||= []) << st.object
end
else
@graph.query(subject: subject) do |st|
@graph.query({subject: subject}) do |st|
(properties[st.predicate.to_s] ||= []) << st.object
end
end
Expand Down Expand Up @@ -704,8 +704,8 @@ def resource_in_single_graph?(resource)
select {|st| st.subject.equal?(resource) || st.object.equal?(resource)}.
map(&:graph_name)
else
graph_names = @repo.query(subject: resource).map(&:graph_name)
graph_names += @repo.query(object: resource).map(&:graph_name)
graph_names = @repo.query({subject: resource}).map(&:graph_name)
graph_names += @repo.query({object: resource}).map(&:graph_name)
end
graph_names.uniq.length <= 1
end
Expand Down
22 changes: 11 additions & 11 deletions rdf-n3.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ Gem::Specification.new do |gem|
gem.files = %w(README.md History.markdown AUTHORS VERSION UNLICENSE) + Dir.glob('lib/**/*.rb')
gem.require_paths = %w(lib)

gem.required_ruby_version = '>= 2.2.2'
gem.required_ruby_version = '>= 2.4'
gem.requirements = []

gem.add_dependency 'rdf', '~> 3.0'
gem.add_dependency 'sparql', '~> 3.0'
gem.add_runtime_dependency 'sxp', '~> 1.0'
gem.add_dependency 'rdf', '~> 3.1'
gem.add_dependency 'sparql', '~> 3.1'
gem.add_runtime_dependency 'sxp', '~> 1.1'

gem.add_development_dependency 'json-ld', '~> 3.0'
gem.add_development_dependency 'rspec', '~> 3.8'
gem.add_development_dependency 'rspec-its', '~> 1.2'
gem.add_development_dependency 'rdf-spec', '~> 3.0'
gem.add_development_dependency 'json-ld', '~> 3.1'
gem.add_development_dependency 'rspec', '~> 3.9'
gem.add_development_dependency 'rspec-its', '~> 1.3'
gem.add_development_dependency 'rdf-spec', '~> 3.1'
gem.add_development_dependency 'rdf-isomorphic', '~> 3.0'
gem.add_development_dependency 'rdf-trig', '~> 3.0'
gem.add_development_dependency 'rdf-vocab', '~> 3.0'
gem.add_development_dependency 'yard' , '~> 0.9.16'
gem.add_development_dependency 'rdf-trig', '~> 3.1'
gem.add_development_dependency 'rdf-vocab', '~> 3.1'
gem.add_development_dependency 'yard' , '~> 0.9.20'

gem.post_install_message = nil
end
Expand Down
8 changes: 4 additions & 4 deletions script/build_meta
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class PredictiveParser
chatty("\nToken #{lhs} matches regexp #{rhs}")
tokenRegexps[lhs] = rhs.value

cc = graph.query(subject: lhs, predicate: BNF.canStartWith)
cc = graph.query({subject: lhs, predicate: BNF.canStartWith})
progress(recordError("No record of what token #{lhs} can start with")) if cc.empty?
cc.each {|statement| chatty(" Can start with: #{statement.object}")}
return
Expand All @@ -96,11 +96,11 @@ class PredictiveParser

options = rhs
progress("\nProduction #{lhs} :: #{options}")
graph.query(subject: lhs, predicate: BNF.canPrecede) do |statement|
graph.query({subject: lhs, predicate: BNF.canPrecede}) do |statement|
chatty(" Can precede '#{statement.object}'")
end

graph.query(subject: lhs, predicate: BNF.branch) do |statement|
graph.query({subject: lhs, predicate: BNF.branch}) do |statement|
branch = statement.object
sequence = graph.first_object(subject: statement.object, predicate: BNF.sequence)
option = RDF::List.new(subject: sequence, graph: graph).to_a
Expand All @@ -110,7 +110,7 @@ class PredictiveParser
agenda << part unless already.include?(part) || agenda.include?(part)
end

conditions = graph.query(subject: branch, predicate: BNF.condition).map(&:object)
conditions = graph.query({subject: branch, predicate: BNF.condition}).map(&:object)
if conditions.empty?
progress(recordError("NO SELECTOR for #{lhs} option #{option}"))
if option.empty?
Expand Down
6 changes: 3 additions & 3 deletions script/parse
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require 'rdf/trig'
require 'getoptlong'
require 'open-uri'

def run(input, options)
def run(input, **options)
require 'profiler' if options[:profile]

reader_class = RDF::Reader.for(options[:input_format].to_sym)
Expand Down Expand Up @@ -166,10 +166,10 @@ end

if ARGV.empty?
s = input ? input : $stdin.read
run(StringIO.new(s), options)
run(StringIO.new(s), **options)
else
ARGV.each do |test_file|
run(Kernel.open(test_file), options)
run(Kernel.open(test_file), **options)
end
end
puts
6 changes: 3 additions & 3 deletions spec/reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -960,19 +960,19 @@
it "assumption graph has 2 statements" do
tt = @repo.first(subject: RDF::URI.new("http://a/b#assumption"), predicate: RDF::OWL.sameAs)
expect(tt.object).to be_node
expect(@repo.query(graph_name: tt.object).to_a.length).to eq 2
expect(@repo.query({graph_name: tt.object}).to_a.length).to eq 2
end

it "conclusion graph has 1 statements" do
tt = @repo.first(subject: RDF::URI.new("http://a/b#conclusion"), predicate: RDF::OWL.sameAs)
expect(tt.object).to be_node
expect(@repo.query(graph_name: tt.object).to_a.length).to eq 1
expect(@repo.query({graph_name: tt.object}).to_a.length).to eq 1
end

it "trivialTruth equivalent to empty graph" do
tt = @repo.first(subject: RDF::URI.new("http://a/b#trivialTruth"), predicate: RDF::OWL.sameAs)
expect(tt.object).to be_node
@repo.query(graph_name: tt.object) do |s|
@repo.query({graph_name: tt.object}) do |s|
puts "statement: #{s}"
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/suite_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class << self
# HTTP Request headers.
# @return [IO] File stream
# @yield [IO] File stream
def self.open_file(filename_or_url, options = {}, &block)
def self.open_file(filename_or_url, **options, &block)
case
when filename_or_url.to_s =~ /^file:/
path = filename_or_url[5..-1]
Expand Down Expand Up @@ -103,7 +103,7 @@ def self.open(file)
g = RDF::Repository.load(file, format: :n3)
JSON::LD::API.fromRDF(g) do |expanded|
JSON::LD::API.frame(expanded, FRAME) do |framed|
yield Manifest.new(framed['@graph'].first)
yield Manifest.new(framed)
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
}
}.each do |name, params|
it name do
serialize(params[:input], params[:regexp], params)
serialize(params[:input], params[:regexp], **params)
end
end
end
Expand Down Expand Up @@ -298,7 +298,7 @@
},
}.each do |name, params|
it name do
serialize(params[:input], params[:regexp], params)
serialize(params[:input], params[:regexp], **params)
end
end
end
Expand Down Expand Up @@ -564,7 +564,7 @@
}
}.each do |name, params|
it name do
serialize(params[:input], params[:regexp], params)
serialize(params[:input], params[:regexp], **params)
end
end
end
Expand Down Expand Up @@ -594,7 +594,7 @@
},
}.each do |name, params|
it name do
serialize(params[:input], params[:regexp], params)
serialize(params[:input], params[:regexp], **params)
end
end
end
Expand Down Expand Up @@ -651,15 +651,15 @@
def parse(input, format: :n3, **options)
repo = RDF::Repository.new
reader = RDF::Reader.for(format)
repo << reader.new(input, options)
repo << reader.new(input, **options)
repo
end

# Serialize ntstr to a string and compare against regexps
def serialize(ntstr, regexps = [], base_uri: nil, **options)
prefixes = options[:prefixes] || {}
g = ntstr.is_a?(RDF::Enumerable) ? ntstr : parse(ntstr, base_uri: base_uri, prefixes: prefixes, validate: false, logger: [], format: options.fetch(:input_format, :n3))
result = RDF::N3::Writer.buffer(options.merge(logger: logger, base_uri: base_uri, prefixes: prefixes)) do |writer|
result = RDF::N3::Writer.buffer(**options.merge(logger: logger, base_uri: base_uri, prefixes: prefixes)) do |writer|
writer << g
end
if $verbose
Expand Down

0 comments on commit 784de72

Please sign in to comment.