Skip to content

Commit

Permalink
Finish 3.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 29, 2021
2 parents d1532bc + 6d71a9c commit 1b0e261
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 95 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/ci.yml
Expand Up @@ -15,17 +15,18 @@ jobs:
runs-on: ubuntu-latest
env:
CI: true
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
strategy:
fail-fast: false
matrix:
ruby:
- 2.4
- 2.5
- 2.6
- 2.7
#- ruby-head # Until net-http-persistent updated
#- jruby # No Nokogumbo on JRuby
- 3.0
- 3.1
- ruby-head
- jruby
gemfile:
- Gemfile
- Gemfile-pure
Expand All @@ -39,5 +40,9 @@ jobs:
- name: Install dependencies
run: bundle install --jobs 4 --retry 3
- name: Run tests
run: bundle exec rspec spec

run: ruby --version; bundle exec rspec spec || $ALLOW_FAILURES
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v1.1.2
if: ${{ matrix.ruby == '3.0' && matrix.gemfile == 'Gemfile' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

11 changes: 5 additions & 6 deletions Gemfile
Expand Up @@ -2,9 +2,9 @@ source "https://rubygems.org"

gemspec

gem 'rdf', github: "ruby-rdf/rdf", branch: "develop"
gem 'rdf-rdfa', github: "ruby-rdf/rdf-rdfa", branch: "develop"
gem "nokogiri"
gem 'rdf', github: "ruby-rdf/rdf", branch: "develop"
gem 'rdf-rdfa', github: "ruby-rdf/rdf-rdfa", branch: "develop"
gem "nokogiri", '~> 1.12', platforms: [:mri, :jruby]

group :development do
gem 'ebnf', github: "dryruby/ebnf", branch: "develop"
Expand All @@ -21,11 +21,10 @@ group :development do
end

group :debug do
gem "ruby-debug", platforms: :jruby
gem "byebug", platform: :mri
end

group :test do
gem 'simplecov', platforms: :mri
gem 'coveralls', '~> 0.8', platforms: :mri
gem 'simplecov', '~> 0.21', platforms: :mri
gem 'simplecov-lcov', '~> 0.8', platforms: :mri
end
15 changes: 5 additions & 10 deletions README.md
Expand Up @@ -20,7 +20,7 @@ Install with `gem install rdf-rdfxml`

* 100% free and unencumbered [public domain](https://unlicense.org/) software.
* Implements a complete parser for [RDF/XML][].
* Compatible with Ruby >= 2.4.
* Compatible with Ruby >= 2.6.

## Usage:
Instantiate a parser and parse source, specifying type and base-URL
Expand All @@ -42,8 +42,8 @@ Write a graph to a file:
end

## Dependencies
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.1)
* Soft dependency on [Nokogiri](https://rubygems.org/gems/nokogiri) (>= 1.10)
* [RDF.rb](https://rubygems.org/gems/rdf) (~> 3.2)
* Soft dependency on [Nokogiri](https://rubygems.org/gems/nokogiri) (>= 1.12)

## Documentation
Full documentation available on [Rubydoc.info][RDF/XML doc])
Expand All @@ -54,12 +54,6 @@ Full documentation available on [Rubydoc.info][RDF/XML doc])
* {RDF::RDFXML::Reader}
* {RDF::RDFXML::Writer}

### Additional vocabularies
* {RDF::XML}

## TODO
* Consider a SAX-based parser for improved performance

## Resources
* [RDF.rb][RDF.rb]
* [RDF/XML][RDF/XML]
Expand Down Expand Up @@ -109,4 +103,5 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
[YARD]: https://yardoc.org/
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: https://unlicense.org/#unlicensing-contributions
[RDF/XML doc]: https://rubydoc.info/github/ruby-rdf/rdf-rdfxml/master/frames
[RDF/XML doc]: https://rubydoc.info/github/ruby-rdf/rdf-rdfxml/master/frames
[RDF-star]: https://w3c.github.io/rdf-star/rdf-star-cg-spec.html
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.1.1
3.2.0
20 changes: 9 additions & 11 deletions rdf-rdfxml.gemspec
Expand Up @@ -18,23 +18,21 @@ Gem::Specification.new do |gem|
gem.files = %w(README.md History.md AUTHORS CONTRIBUTORS VERSION UNLICENSE) + Dir.glob('lib/**/*.rb')
gem.require_paths = %w(lib)

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

gem.add_runtime_dependency 'rdf', '~> 3.1'
gem.add_runtime_dependency 'rdf-xsd', '~> 3.1'
gem.add_runtime_dependency 'rdf-rdfa', '~> 3.1'
gem.add_runtime_dependency 'rdf', '~> 3.2'
gem.add_runtime_dependency 'rdf-xsd', '~> 3.2'
gem.add_runtime_dependency 'rdf-rdfa', '~> 3.2'
gem.add_runtime_dependency 'htmlentities', '~> 4.3'

#gem.add_development_dependency 'nokogiri' , '~> 1.10'
#gem.add_development_dependency 'equivalent-xml' , '~> 0.6' # conditionally done in Gemfile
gem.add_development_dependency 'json-ld', '>= 3.1'
gem.add_development_dependency 'json-ld', '>= 3.2'
gem.add_development_dependency 'rspec', '~> 3.10'
gem.add_development_dependency 'rspec-its', '~> 1.3'
gem.add_development_dependency 'rdf-isomorphic', '~> 3.1'
gem.add_development_dependency 'rdf-turtle', '~> 3.1'
gem.add_development_dependency 'rdf-spec', '~> 3.1'
gem.add_development_dependency 'rdf-vocab', '~> 3.1'
gem.add_development_dependency 'rdf-isomorphic', '~> 3.2'
gem.add_development_dependency 'rdf-turtle', '~> 3.2'
gem.add_development_dependency 'rdf-spec', '~> 3.2'
gem.add_development_dependency 'rdf-vocab', '~> 3.2'
gem.add_development_dependency 'yard' , '~> 0.9'

gem.post_install_message = nil
Expand Down
124 changes: 86 additions & 38 deletions script/parse
Expand Up @@ -5,9 +5,9 @@ require "bundler/setup"
require 'rdf/rdfxml'
require 'rdf/turtle'
require 'rdf/ntriples'
require 'rdf/ordered_repo'
require 'getoptlong'
require 'logger'
require 'open-uri'

def run(input, **options)
reader_class = RDF::Reader.for(options[:input_format].to_sym)
Expand All @@ -17,10 +17,12 @@ def run(input, **options)
num = 0

if options[:output_format] == :ntriples || options[:quiet]
reader_class.new(input, **options).each do |statement|
reader_class.new(input, **options[:parser_options]).each do |statement|
num += 1
if options[:quiet]
#print "."
if options[:errors] && statement.invalid?
$stderr.puts "Invalid statement #{statement.inspect}"
elsif options[:quiet]
print "." if options[:quiet] == 1
else
options[:output].puts statement.to_ntriples
end
Expand All @@ -31,63 +33,108 @@ def run(input, **options)
options[:output].puts statement.inspect
end
else
r = reader_class.new(input, **options)
g = RDF::Repository.new << r
r = reader_class.new(input, **options[:parser_options])
g = RDF::OrderedRepo.new << r
num = g.count
STDERR.puts "graph: #{g.dump(:ttl)}" if options[:verbose]
options[:output].puts g.dump(options[:output_format], options.merge(prefixes: r.prefixes))
options[:output].puts g.dump(options[:output_format], prefixes: r.prefixes, **options[:writer_options])
end
STDERR.puts
$stderr.puts
secs = Time.new - start
STDERR.puts "Parsed #{num} statements in #{secs} seconds @ #{num/secs} statements/second."
rescue
$stderr.puts "Parsed #{num} statements in #{secs} seconds @ #{num/secs} statements/second."
rescue Exception => e
fname = input.respond_to?(:path) ? input.path : "-stdin-"
STDERR.puts("Error in #{fname}")
raise
$stderr.puts("Error in #{fname}: #{e.message}")
$stderr.puts "Backtrace: " + e.backtrace.join("\n ")
raise e
end

logger = Logger.new(STDERR)
logger.level = Logger::WARN
logger.formatter = lambda {|severity, datetime, progname, msg| "#{severity}: #{msg}\n"}

parser_options = {
base_uri: nil,
validate: false,
logger: logger,
}

writer_options = {
base_uri: nil,
standard_prefixes: true,
logger: logger,
}

options = {
parser_options: parser_options,
writer_options: writer_options,
input_format: :rdfxml,
output: STDOUT,
output_format: :ntriples,
output: STDOUT,
strict: true,
validate: false,
verbose: false,
logger: logger
}

input = nil

opts = GetoptLong.new(
["--dbg", GetoptLong::NO_ARGUMENT],
["--execute", "-e", GetoptLong::REQUIRED_ARGUMENT],
["--format", GetoptLong::REQUIRED_ARGUMENT],
["--input-format", GetoptLong::REQUIRED_ARGUMENT],
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT],
["--quiet", GetoptLong::NO_ARGUMENT],
["--template", GetoptLong::REQUIRED_ARGUMENT],
["--uri", GetoptLong::REQUIRED_ARGUMENT],
["--validate", GetoptLong::NO_ARGUMENT],
["--verbose", GetoptLong::NO_ARGUMENT],
)
OPT_ARGS = [
["--canonicalize", GetoptLong::NO_ARGUMENT, "Canonize all terms"],
["--debug", GetoptLong::NO_ARGUMENT, "Debugging output"],
["--errors", GetoptLong::NO_ARGUMENT, "Display invalid statements"],
["--execute", "-e", GetoptLong::REQUIRED_ARGUMENT, "Run against source in argument"],
["--format", GetoptLong::REQUIRED_ARGUMENT, "Output format, any RDF format symbol, sxp, or inspect"],
["--help", "-?", GetoptLong::NO_ARGUMENT, "print this message"],
["--input-format", GetoptLong::REQUIRED_ARGUMENT, "Format of the input file, defaults to ttl"],
["--info", GetoptLong::NO_ARGUMENT, "Show progress on execution"],
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT, "Save output to file"],
["--quiet", GetoptLong::NO_ARGUMENT, "Do not show parser output"],
["--stream", GetoptLong::NO_ARGUMENT, "Use streaming writer"],
["--template", GetoptLong::REQUIRED_ARGUMENT, "Haml template for writer"],
["--uri", GetoptLong::REQUIRED_ARGUMENT, "Default base URI"],
["--validate", GetoptLong::NO_ARGUMENT, "Run parser in strict validation mode"],
["--verbose", GetoptLong::NO_ARGUMENT, "Verbose output"],
]

def usage
STDERR.puts %{
RDF::RDFXML version #{RDF::RDFXML::VERSION}
Usage: #{$0} [options] file ...
}.gsub(/^ /, '')
width = OPT_ARGS.map do |o|
l = o.first.length
l += o[1].length + 2 if o[1].is_a?(String)
l
end.max
OPT_ARGS.each do |o|
s = " %-*s " % [width, (o[1].is_a?(String) ? "#{o[0,2].join(', ')}" : o[0])]
s += o.last
STDERR.puts s
end
exit(1)
end

opts = GetoptLong.new(*OPT_ARGS.map {|o| o[0..-2]})

opts.each do |opt, arg|
case opt
when '--dbg' then logger.level = Logger::DEBUG
when '--execute' then input = arg
when '--format' then options[:output_format] = arg.to_sym
when '--input-format' then options[:input_format] = arg.to_sym
when '--output' then options[:output] = File.open(arg, "w")
when '--debug' then logger.level = Logger::DEBUG
when '--canonicalize' then parser_options[:canonicalize] = true
when '--errors' then options[:errors] = true
when '--execute' then input = arg
when '--format' then options[:output_format] = arg.to_sym
when "--help" then usage()
when '--input-format' then options[:input_format] = arg.to_sym
when '--output' then options[:output] = File.open(arg, "w")
when '--rdfstar' then parser_options[:rdfstar] = true
when '--quiet'
options[:quiet] = true
options[:quiet] = options[:quiet].to_i + 1
logger.level = Logger::FATAL
when '--template' then options[:haml] = arg.to_sym
when '--uri' then options[:base_uri] = arg
when '--validate' then options[:validate] = true
when '--verbose' then options[:verbose] = true
when '--version' then options[:version] = arg
when '--template' then options[:haml] = arg.to_sym
when '--uri' then parser_options[:base_uri] = writer_options[:base_uri] = arg
when '--validate' then parser_options[:validate] = true
when '--verbose' then options[:verbose] = true
when '--version' then options[:version] = arg
end
end

Expand All @@ -99,3 +146,4 @@ else
run(Kernel.open(test_file), **options)
end
end
puts
10 changes: 8 additions & 2 deletions spec/spec_helper.rb
Expand Up @@ -16,10 +16,16 @@
end
begin
require 'simplecov'
require 'coveralls'
require 'simplecov-lcov'
SimpleCov::Formatter::LcovFormatter.config do |config|
#Coveralls is coverage by default/lcov. Send info results
config.report_with_single_file = true
config.single_report_path = 'coverage/lcov.info'
end

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
SimpleCov::Formatter::LcovFormatter
])
SimpleCov.start do
add_filter "/spec/"
Expand Down

0 comments on commit 1b0e261

Please sign in to comment.