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 391b4eb + e6d8f48 commit 7dad8f8
Show file tree
Hide file tree
Showing 17 changed files with 83 additions and 92 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
language: ruby
bundler_args: --without debug
script: "bundle exec rspec spec"
env:
- CI=true
rvm:
- 2.2
- 2.3
- 2.4
- jruby-9
- rbx-3
- 2.5
- 2.6
- 2.7
- jruby
matrix:
allow_failures:
- rvm: jruby-9
- rvm: rbx-3
- rvm: jruby
addons:
apt:
packages:
Expand Down
5 changes: 0 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,3 @@ group :debug do
gem 'pry'
gem 'pry-byebug', platforms: :mri
end

platforms :rbx do
gem 'rubysl', '~> 2.0'
gem 'rubinius', '~> 2.0'
end
1 change: 0 additions & 1 deletion README

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Features
* Serializes RDF statements into Graphviz format.
* Provides serialization format autodetection for RDF/XML, Turtle and RDFa.
* Compatible with any operating system supported by Raptor and Ruby.
* Compatible with MRI >= 2.2.2, JRuby and Rubinius.
* Compatible with MRI >= 2.4, JRuby and Rubinius.

Examples
--------
Expand Down Expand Up @@ -139,8 +139,8 @@ Documentation
Dependencies
------------

* [RDF.rb](http://rubygems.org/gems/rdf) (>= 1.0.0)
* [FFI](http://rubygems.org/gems/ffi) (>= 1.0.0)
* [RDF.rb](http://rubygems.org/gems/rdf) (~> 3.1)
* [FFI](http://rubygems.org/gems/ffi) (~> 1.11)
* [Raptor][] (>= 2.0), the `libraptor` library or the `rapper` binary

Installation
Expand Down
13 changes: 10 additions & 3 deletions Rakefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib')))
require 'rubygems'

begin
require 'rakefile' # @see http://github.com/bendiken/rakefile
rescue LoadError => e
namespace :gem do
desc "Build the rdf-raptor-#{File.read('VERSION').chomp}.gem file"
task :build do
sh "gem build rdf-raptor.gemspec && mv rdf-raptor-#{File.read('VERSION').chomp}.gem pkg/"
end

desc "Release the rdf-raptor-#{File.read('VERSION').chomp}.gem file"
task :release do
sh "gem push pkg/rdf-raptor-#{File.read('VERSION').chomp}.gem"
end
end

require 'rdf/raptor'
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
3.1.0
18 changes: 9 additions & 9 deletions lib/rdf/raptor/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,30 @@ class Reader < RDF::Reader
# Initializes the CLI reader instance.
#
# @param [IO, File, RDF::URI, String] input
# @param [String, #to_s] :base_uri ("file:///dev/stdin")
# @param [Hash{Symbol => Object}] options
# any additional options (see `RDF::Reader#initialize`)
# @option options [String, #to_s] :base_uri ("file:///dev/stdin")
# @yield [reader] `self`
# @yieldparam [RDF::Reader] reader
# @yieldreturn [void] ignored
def initialize(input = $stdin, options = {}, &block)
def initialize(input = $stdin, base_uri: nil, **options, &block)
raise RDF::ReaderError, "`rapper` binary not found" unless RDF::Raptor.available?

format = self.class.format.rapper_format
case input
when RDF::URI, %r(^(file|http|https|ftp)://)
@command = "#{RAPPER} -q -i #{format} -o ntriples '#{input}'"
@command << " '#{options[:base_uri]}'" if options.has_key?(:base_uri)
@command << " '#{base_uri}'" if options.has_key?(:base_uri)
@rapper = IO.popen(@command, 'rb')

when File, Tempfile
@command = "#{RAPPER} -q -i #{format} -o ntriples '#{File.expand_path(input.path)}'"
@command << " '#{options[:base_uri]}'" if options.has_key?(:base_uri)
@command << " '#{base_uri}'" if options.has_key?(:base_uri)
@rapper = IO.popen(@command, 'rb')

else # IO, String
@command = "#{RAPPER} -q -i #{format} -o ntriples file:///dev/stdin"
@command << " '#{options[:base_uri]}'" if options.has_key?(:base_uri)
@command << " '#{base_uri}'" if options.has_key?(:base_uri)
@rapper = IO.popen(@command, 'rb+')
pid = fork do
# process to feed `rapper`
Expand Down Expand Up @@ -135,20 +135,20 @@ class Writer < RDF::Writer
# @yield [writer] `self`
# @yieldparam [RDF::Writer] writer
# @yieldreturn [void]
def initialize(output = $stdout, options = {}, &block)
def initialize(output = $stdout, base_uri: nil, **options, &block)
raise RDF::WriterError, "`rapper` binary not found" unless RDF::Raptor.available?

format = self.class.format.rapper_format
case output
when File, IO, StringIO, Tempfile
@command = "#{RAPPER} -q -i turtle -o #{format} file:///dev/stdin"
@command << " '#{options[:base_uri]}'" if options.has_key?(:base_uri)
@command << " '#{base_uri}'" if options.has_key?(:base_uri)
@rapper = IO.popen(@command, 'rb+')
else
raise ArgumentError, "unsupported output type: #{output.inspect}"
end
@writer = RDF::NTriples::Writer.new(@rapper, options)
super(output, options, &block)
@writer = RDF::NTriples::Writer.new(@rapper, **options)
super(output, base_uri: base_uri, **options, &block)
end

protected
Expand Down
12 changes: 6 additions & 6 deletions lib/rdf/raptor/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Reader < RDF::Reader
# @yield [reader] `self`
# @yieldparam [RDF::Reader] reader
# @yieldreturn [void] ignored
def initialize(input = $stdin, options = {}, &block)
def initialize(input = $stdin, **options, &block)
@format = self.class.format.rapper_format
@parser = V2::Parser.new(@format)
@parser.error_handler = ERROR_HANDLER
Expand Down Expand Up @@ -75,7 +75,7 @@ def initialize(input = $stdin, options = {}, &block)
# @yieldparam [RDF::Statement] statement
# @yieldreturn [void] ignored
# @see RDF::Reader#each_statement
def each_statement(options = {}, &block)
def each_statement(**options, &block)
if block_given?
if options[:raw]
# this is up to an order of magnitude faster...
Expand All @@ -92,7 +92,7 @@ def each_statement(options = {}, &block)
raise RDF::ReaderError, "Errors found during processing"
end
end
enum_for(:each_statement, options)
enum_for(:each_statement, **options)
end
alias_method :each, :each_statement

Expand Down Expand Up @@ -121,7 +121,7 @@ def each_triple(&block)
# @yieldreturn [void] ignored
# @return [void]
def parse(input, &block)
@parser.parse(input, @options, &block)
@parser.parse(input, **@options, &block)
end

GENID = /^genid\d+$/
Expand Down Expand Up @@ -156,12 +156,12 @@ class Writer < RDF::Writer
# @yield [writer] `self`
# @yieldparam [RDF::Writer] writer
# @yieldreturn [void] ignored
def initialize(output = $stdout, options = {}, &block)
def initialize(output = $stdout, **options, &block)
@format = self.class.format.rapper_format
@serializer = V2::Serializer.new(@format)
@serializer.error_handler = ERROR_HANDLER
@serializer.warning_handler = WARNING_HANDLER
@serializer.start_to(output, options)
@serializer.start_to(output, **options)
super
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/raptor/ffi/v1/iostream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class IOStream < ::FFI::ManagedStruct
# @overload initialize(file)
# @param [File, Tempfile] file
#
def initialize(ptr_or_obj, options = {})
def initialize(ptr_or_obj, **options)
ptr = case ptr_or_obj
when FFI::Pointer
ptr_or_obj
Expand Down
26 changes: 13 additions & 13 deletions lib/rdf/raptor/ffi/v1/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ def statement_handler=(handler)
# @yieldparam [FFI::Pointer] statement
# @yieldreturn [void] ignored
# @return [void]
def parse(input, options = {}, &block)
def parse(input, **options, &block)
case input
when RDF::URI, %r(^(file|https|http|ftp)://)
parse_url(input, options, &block)
parse_url(input, **options, &block)
when File, Tempfile
parse_file(input, options, &block)
parse_file(input, **options, &block)
when IO, StringIO
parse_stream(input, options, &block)
parse_stream(input, **options, &block)
when String
parse_buffer(input, options, &block)
parse_buffer(input, **options, &block)
else
raise ArgumentError, "don't know how to parse #{input.inspect}"
end
Expand All @@ -101,11 +101,11 @@ def parse(input, options = {}, &block)
# @yieldparam [FFI::Pointer] statement
# @yieldreturn [void] ignored
# @return [void]
def parse_url(url, options = {}, &block)
def parse_url(url, base_uri: nil, **options, &block)
self.statement_handler = block if block_given?

data_url = V1::URI.new((url.respond_to?(:to_uri) ? url.to_uri : url).to_s)
base_uri = options[:base_uri].to_s.empty? ? nil : V1::URI.new(options[:base_uri].to_s)
base_uri = base_uri.to_s.empty? ? nil : V1::URI.new(base_uri.to_s)

result = V1.raptor_parse_uri(self, data_url, base_uri)
# TODO: error handling if result.nonzero?
Expand All @@ -123,11 +123,11 @@ def parse_url(url, options = {}, &block)
# @yieldparam [FFI::Pointer] statement
# @yieldreturn [void] ignored
# @return [void]
def parse_file(file, options = {}, &block)
def parse_file(file, base_uri: nil, **options, &block)
self.statement_handler = block if block_given?

data_url = V1::URI.new("file://#{File.expand_path(file.path)}")
base_uri = options[:base_uri].to_s.empty? ? nil : V1::URI.new(options[:base_uri].to_s)
base_uri = base_uri.to_s.empty? ? nil : V1::URI.new(base_uri.to_s)

result = V1.raptor_parse_file(self, data_url, base_uri)
# TODO: error handling if result.nonzero?
Expand All @@ -144,11 +144,11 @@ def parse_file(file, options = {}, &block)
# @yieldparam [FFI::Pointer] statement
# @yieldreturn [void] ignored
# @return [void]
def parse_stream(stream, options = {}, &block)
def parse_stream(stream, base_uri: nil, **options, &block)
self.statement_handler = block if block_given?

begin
parse_start!((options[:base_uri] || BASE_URI).to_s)
parse_start!((base_uri || BASE_URI).to_s)
loop do
parse_chunk(stream.sysread(BUFFER_SIZE))
end
Expand All @@ -168,10 +168,10 @@ def parse_stream(stream, options = {}, &block)
# @yieldparam [FFI::Pointer] statement
# @yieldreturn [void] ignored
# @return [void]
def parse_buffer(buffer, options = {}, &block)
def parse_buffer(buffer, base_uri: nil, **options, &block)
self.statement_handler = block if block_given?

parse_start!((options[:base_uri] || BASE_URI).to_s)
parse_start!((base_uri || BASE_URI).to_s)
parse_chunk(buffer.to_str)
parse_end!
end
Expand Down
10 changes: 5 additions & 5 deletions lib/rdf/raptor/ffi/v1/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def warning_handler=(handler)
# @option options [String, #to_s] :base_uri (nil)
# the base URI to use when resolving relative URIs
# @return [void]
def start_to(output, options = {})
def start_to(output, **options)
if output.respond_to?(:write)
start_to_stream(output, options)
start_to_stream(output, **options)
else
raise ArgumentError, "don't know how to serialize to #{output.inspect}"
end
Expand All @@ -70,17 +70,17 @@ def start_to(output, options = {})
# @param [Hash{Symbol => Object}] options
# any additional options for serializing (see {#start_to})
# @return [void]
def start_to_stream(stream, options = {})
def start_to_stream(stream, **options)
iostream = V1::IOStream.new(V1::IOStreamHandler.new(stream), free_iostream: false)
start_to_iostream(iostream, options)
start_to_iostream(iostream, **options)
end

##
# @param [V1::IOStream] iostream
# @param [Hash{Symbol => Object}] options
# any additional options for serializing (see {#start_to})
# @return [void]
def start_to_iostream(iostream, options = {})
def start_to_iostream(iostream, **options)
@iostream = iostream # prevents premature GC
@base_uri = options[:base_uri].to_s.empty? ? nil : V1::URI.new(options[:base_uri].to_s)
if V1.raptor_serialize_start_to_iostream(self, @base_uri, @iostream).nonzero?
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/raptor/ffi/v2/iostream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class IOStream < ::FFI::ManagedStruct
# @overload initialize(file)
# @param [File, Tempfile] file
#
def initialize(ptr_or_obj, options = {})
def initialize(ptr_or_obj, **options)
ptr = case ptr_or_obj
when FFI::Pointer
ptr_or_obj
Expand Down
18 changes: 9 additions & 9 deletions lib/rdf/raptor/ffi/v2/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ def namespace_handler=(handler)
# @yieldparam [FFI::Pointer] statement
# @yieldreturn [void] ignored
# @return [void]
def parse(input, options = {}, &block)
def parse(input, **options, &block)
case input
when RDF::URI, URI, %r(^(file|https|http|ftp)://)
parse_url(input, options, &block)
parse_url(input, **options, &block)
when File, Tempfile
parse_file(input, options, &block)
parse_file(input, **options, &block)
when IO, StringIO
parse_stream(input, options, &block)
parse_stream(input, **options, &block)
when String
parse_buffer(input, options, &block)
parse_buffer(input, **options, &block)
else
raise ArgumentError, "don't know how to parse #{input.inspect}"
end
Expand All @@ -108,7 +108,7 @@ def parse(input, options = {}, &block)
# @yieldparam [FFI::Pointer] statement
# @yieldreturn [void] ignored
# @return [void]
def parse_url(url, options = {}, &block)
def parse_url(url, **options, &block)
self.statement_handler = block if block_given?

data_url = V2::URI.new((url.respond_to?(:to_uri) ? url.to_uri : url).to_s)
Expand All @@ -130,7 +130,7 @@ def parse_url(url, options = {}, &block)
# @yieldparam [FFI::Pointer] statement
# @yieldreturn [void] ignored
# @return [void]
def parse_file(file, options = {}, &block)
def parse_file(file, **options, &block)
self.statement_handler = block if block_given?

data_url = V2::URI.new("file://#{File.expand_path(file.path)}")
Expand All @@ -151,7 +151,7 @@ def parse_file(file, options = {}, &block)
# @yieldparam [FFI::Pointer] statement
# @yieldreturn [void] ignored
# @return [void]
def parse_stream(stream, options = {}, &block)
def parse_stream(stream, **options, &block)
self.statement_handler = block if block_given?

begin
Expand All @@ -175,7 +175,7 @@ def parse_stream(stream, options = {}, &block)
# @yieldparam [FFI::Pointer] statement
# @yieldreturn [void] ignored
# @return [void]
def parse_buffer(buffer, options = {}, &block)
def parse_buffer(buffer, **options, &block)
self.statement_handler = block if block_given?

parse_start!((options[:base_uri] || BASE_URI).to_s)
Expand Down
Loading

0 comments on commit 7dad8f8

Please sign in to comment.