Skip to content

Commit

Permalink
Finish 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 16, 2019
2 parents 64711e3 + 43d4393 commit 0d06bb3
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 78 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
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ group :development, :test do
gem 'rdf-vocab', git: "https://github.com/ruby-rdf/rdf-vocab", branch: "develop"
gem 'sxp', git: "https://github.com/dryruby/sxp.rb", branch: "develop"
gem "redcarpet", platforms: :ruby
gem 'simplecov', require: false, platform: :mri
gem 'coveralls', require: false, platform: :mri
gem 'simplecov', platforms: :mri
gem 'coveralls', '~> 0.8', platforms: :mri
end
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ This version uses a hand-written parser using the Lexer from the [EBNF][] gem in

## Dependencies

* [Ruby](https://ruby-lang.org/) (>= 2.2)
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.0)
* [Ruby](https://ruby-lang.org/) (>= 2.4)
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
* [EBNF][] (~> 1.1)

## Installation
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.6
3.1.0
2 changes: 1 addition & 1 deletion lib/rdf/turtle/freebase_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def read_prefix
##
# Read a PNAME of the form `prefix:suffix`.
# @return [RDF::URI]
def read_pname(options = {})
def read_pname(**options)
if pname_str = match(/^(\w+:\S+)/)
ns, suffix = pname_str.split(':', 2)
if suffix[-1,1] == "."
Expand Down
14 changes: 7 additions & 7 deletions lib/rdf/turtle/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ def self.options
# Redirect for Freebase Reader
#
# @private
def self.new(input = nil, options = {}, &block)
def self.new(input = nil, **options, &block)
klass = if options[:freebase]
FreebaseReader
else
self
end
reader = klass.allocate
reader.send(:initialize, input, options, &block)
reader.send(:initialize, input, **options, &block)
reader
end

Expand All @@ -82,7 +82,7 @@ def self.new(input = nil, options = {}, &block)
# @option options [Boolean] :freebase (false)
# Use optimized Freebase reader
# @return [RDF::Turtle::Reader]
def initialize(input = nil, options = {}, &block)
def initialize(input = nil, **options, &block)
super do
@options = {
anon_base: "b0",
Expand All @@ -98,7 +98,7 @@ def initialize(input = nil, options = {}, &block)
log_debug("canonicalize") {canonicalize?.inspect}
log_debug("intern") {intern?.inspect}

@lexer = EBNF::LL1::Lexer.new(input, self.class.patterns, @options)
@lexer = EBNF::LL1::Lexer.new(input, self.class.patterns, **@options)

if block_given?
case block.arity
Expand Down Expand Up @@ -184,14 +184,14 @@ def process_iri(iri)
end

# Create a literal
def literal(value, options = {})
def literal(value, **options)
log_debug("literal") do
"value: #{value.inspect}, " +
"options: #{options.inspect}, " +
"validate: #{validate?.inspect}, " +
"c14n?: #{canonicalize?.inspect}"
end
RDF::Literal.new(value, options.merge(validate: validate?, canonicalize: canonicalize?))
RDF::Literal.new(value, validate: validate?, canonicalize: canonicalize?, **options)
rescue ArgumentError => e
error("Argument Error #{e.message}", production: :literal, token: @lexer.first)
end
Expand Down Expand Up @@ -587,7 +587,7 @@ class SyntaxError < RDF::ReaderError
# @option options [Symbol] :production (nil)
# @option options [String] :token (nil)
# @option options [Integer] :lineno (nil)
def initialize(message, options = {})
def initialize(message, **options)
@production = options[:production]
@token = options[:token]
@lineno = options[:lineno] || (@token.lineno if @token.respond_to?(:lineno))
Expand Down
8 changes: 4 additions & 4 deletions lib/rdf/turtle/streaming_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def stream_statement(statement)
if statement.subject != @streaming_subject
@output.puts ' .' if @streaming_subject
@streaming_subject, @streaming_predicate = statement.subject, statement.predicate
@output.write "#{format_term(statement.subject, options)} "
@output.write "#{format_term(statement.predicate, options)} "
@output.write "#{format_term(statement.subject, **options)} "
@output.write "#{format_term(statement.predicate, **options)} "
elsif statement.predicate != @streaming_predicate
@streaming_predicate = statement.predicate
@output.write ";\n#{indent(1)}#{format_term(statement.predicate, options)} "
@output.write ";\n#{indent(1)}#{format_term(statement.predicate, **options)} "
else
@output.write ",\n#{indent(2)}"
end
@output.write("#{format_term(statement.object, options)}")
@output.write("#{format_term(statement.object, **options)}")
end

##
Expand Down
14 changes: 7 additions & 7 deletions lib/rdf/turtle/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def self.options
# @yieldreturn [void]
# @yield [writer]
# @yieldparam [RDF::Writer] writer
def initialize(output = $stdout, options = {}, &block)
def initialize(output = $stdout, **options, &block)
@graph = RDF::Graph.new
@uri_to_pname = {}
@uri_to_prefix = {}
Expand Down Expand Up @@ -272,7 +272,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)
case literal
when RDF::Literal
case @options[:literal_shorthand] && literal.valid? ? literal.datatype : false
Expand All @@ -297,7 +297,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_ntriples} => #{md.inspect}"} if md != uri.to_s
md != uri.to_s ? "<#{md}>" : (get_pname(uri) || "<#{uri}>")
Expand All @@ -309,7 +309,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 @@ -546,7 +546,7 @@ def p_term(resource, position)
l = if resource == RDF.nil
"()"
else
format_term(resource, options)
format_term(resource, **options)
end
@output.write(l)
end
Expand Down Expand Up @@ -595,7 +595,7 @@ def objectList(objects)
# @return [Integer] the number of properties serialized
def predicateObjectList(subject, from_bpl = false)
properties = {}
@graph.query(subject: subject) do |st|
@graph.query({subject: subject}) do |st|
(properties[st.predicate.to_s] ||= []) << st.object
end

Expand Down
23 changes: 11 additions & 12 deletions rdf-turtle.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ Gem::Specification.new do |gem|
gem.files = %w(AUTHORS README.md History UNLICENSE VERSION) + 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_runtime_dependency 'rdf', '~> 3.0'
gem.add_runtime_dependency 'ebnf', '~> 1.1'
gem.add_development_dependency 'rspec', '~> 3.7'
gem.add_development_dependency 'rspec-its', '~> 1.2'
gem.add_development_dependency 'rdf-isomorphic', '~> 3.0'
#gem.add_development_dependency 'json-ld', '~> 3.0'
gem.add_development_dependency 'rdf-spec', '~> 3.0'
gem.add_development_dependency 'rdf-vocab', '~> 3.0'
gem.add_development_dependency 'json-ld', '>= 2.1', '< 4.0'
gem.add_runtime_dependency 'rdf', '~> 3.1'
gem.add_runtime_dependency 'ebnf', '~> 1.2'
gem.add_development_dependency 'rspec', '~> 3.9'
gem.add_development_dependency 'rspec-its', '~> 1.3'
gem.add_development_dependency 'rdf-isomorphic', '~> 3.1'
gem.add_development_dependency 'json-ld', '~> 3.1'
gem.add_development_dependency 'rdf-spec', '~> 3.1'
gem.add_development_dependency 'rdf-vocab', '~> 3.1'

gem.add_development_dependency 'rake', '~> 12.0'
gem.add_development_dependency 'yard' , '~> 0.9.12'
gem.add_development_dependency 'rake', '~> 13.0'
gem.add_development_dependency 'yard' , '~> 0.9.20'
gem.post_install_message = nil
end
14 changes: 7 additions & 7 deletions script/parse
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require 'rdf/ntriples'
require 'ebnf/ll1/parser'
require 'getoptlong'

def run(input, options)
def run(input, **options)
if options[:profile]
require 'profiler'
end
Expand All @@ -31,7 +31,7 @@ def run(input, options)
num = 0
Profiler__::start_profile if options[:profile]
if options[:output_format] == :ntriples || options[:quiet] || options[:benchmark]
r = reader_class.new(input, options[:parser_options])
r = reader_class.new(input, **options[:parser_options])
r.each do |statement|
num += 1
if options[:errors] && statement.invalid?
Expand All @@ -45,15 +45,15 @@ def run(input, options)
end
end
elsif options[:output_format] == :inspect
reader_class.new(input, options[:parser_options]).each do |statement|
reader_class.new(input, **options[:parser_options]).each do |statement|
num += 1
options[:output].puts statement.inspect
end
else
r = reader_class.new(input, options[:parser_options])
r = reader_class.new(input, **options[:parser_options])
g = RDF::Graph.new << r
num = g.count
options[:output].puts g.dump(options[:output_format], {prefixes: r.prefixes}.merge(options[:writer_options]))
options[:output].puts g.dump(options[:output_format], prefixes: r.prefixes, **options[:writer_options])
end
if options[:profile]
Profiler__::stop_profile
Expand Down Expand Up @@ -137,10 +137,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
14 changes: 7 additions & 7 deletions script/tc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require 'getoptlong'
ASSERTOR = "https://greggkellogg.net/foaf#me"
RUN_TIME = Time.now

def earl_preamble(options)
def earl_preamble(**options)
options[:output].write File.read(File.expand_path("../../etc/doap#{'-ntriples' if options[:ntriples]}.ttl", __FILE__))
options[:output].puts %(
<> foaf:primaryTopic <https://rubygems.org/gems/rdf#{'-turtle' unless options[:ntriples]}> ;
Expand Down Expand Up @@ -43,7 +43,7 @@ def earl_preamble(options)
)
end

def run_tc(tc, options)
def run_tc(tc, **options)
STDERR.write "run #{tc.name}"

if options[:verbose]
Expand All @@ -64,7 +64,7 @@ def run_tc(tc, options)
logger: logger
}.merge(options)

reader = RDF::Reader.for(tc.action).new(tc.input, options)
reader = RDF::Reader.for(tc.action).new(tc.input, **options)

graph = RDF::Repository.new
result = nil
Expand Down Expand Up @@ -139,7 +139,7 @@ opts = GetoptLong.new(
["--verbose", "-v", GetoptLong::NO_ARGUMENT]
)

def help(options)
def help(**options)
puts "Usage: #{$0} [options] [test-number ...]"
puts "Options:"
puts " --debug: Display detailed debug output"
Expand All @@ -157,7 +157,7 @@ end

opts.each do |opt, arg|
case opt
when '--help' then help(options)
when '--help' then help(**options)
when '--dbg' then options[:level] = Logger::DEBUG
when '--earl'
options[:quiet] = options[:earl] = true
Expand All @@ -175,14 +175,14 @@ end

manifest = (options[:ntriples] ? Fixtures::SuiteTest::NTBASE : Fixtures::SuiteTest::BASE) + "manifest.ttl"

earl_preamble(options) if options[:earl]
earl_preamble(**options) if options[:earl]

result_count = {}

Fixtures::SuiteTest::Manifest.open(manifest) do |m|
m.entries.each do |tc|
next unless ARGV.empty? || ARGV.any? {|n| tc.name.match(/#{n}/)}
run_tc(tc, options.merge(result_count: result_count))
run_tc(tc, result_count: result_count, **options)
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/freebase_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@
end
end

def parse(input, options = {})
def parse(input, **options)
@logger = RDF::Spec.logger
options = {
logger: @logger,
validate: true,
canonicalize: false,
}.merge(options)
graph = options[:graph] || RDF::Graph.new
RDF::Turtle::FreebaseReader.new(input, options).each do |statement|
RDF::Turtle::FreebaseReader.new(input, **options).each do |statement|
graph << statement
end
graph
Expand Down
4 changes: 2 additions & 2 deletions spec/reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1865,15 +1865,15 @@
end
end

def parse(input, options = {})
def parse(input, **options)
@logger = RDF::Spec.logger
options = {
logger: @logger,
validate: true,
canonicalize: false,
}.merge(options)
graph = options[:graph] || RDF::Graph.new
RDF::Turtle::Reader.new(input, options).each do |statement|
RDF::Turtle::Reader.new(input, **options).each do |statement|
graph << statement
end
graph
Expand Down
Loading

0 comments on commit 0d06bb3

Please sign in to comment.