Skip to content

Commit 1b0e261

Browse files
committed
Finish 3.2.0
2 parents d1532bc + 6d71a9c commit 1b0e261

File tree

8 files changed

+125
-95
lines changed

8 files changed

+125
-95
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ jobs:
1515
runs-on: ubuntu-latest
1616
env:
1717
CI: true
18+
ALLOW_FAILURES: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'jruby' }}
1819
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
1920
strategy:
2021
fail-fast: false
2122
matrix:
2223
ruby:
23-
- 2.4
24-
- 2.5
2524
- 2.6
2625
- 2.7
27-
#- ruby-head # Until net-http-persistent updated
28-
#- jruby # No Nokogumbo on JRuby
26+
- 3.0
27+
- 3.1
28+
- ruby-head
29+
- jruby
2930
gemfile:
3031
- Gemfile
3132
- Gemfile-pure
@@ -39,5 +40,9 @@ jobs:
3940
- name: Install dependencies
4041
run: bundle install --jobs 4 --retry 3
4142
- name: Run tests
42-
run: bundle exec rspec spec
43-
43+
run: ruby --version; bundle exec rspec spec || $ALLOW_FAILURES
44+
- name: Coveralls GitHub Action
45+
uses: coverallsapp/[email protected]
46+
if: ${{ matrix.ruby == '3.0' && matrix.gemfile == 'Gemfile' }}
47+
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

Gemfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ source "https://rubygems.org"
22

33
gemspec
44

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

99
group :development do
1010
gem 'ebnf', github: "dryruby/ebnf", branch: "develop"
@@ -21,11 +21,10 @@ group :development do
2121
end
2222

2323
group :debug do
24-
gem "ruby-debug", platforms: :jruby
2524
gem "byebug", platform: :mri
2625
end
2726

2827
group :test do
29-
gem 'simplecov', platforms: :mri
30-
gem 'coveralls', '~> 0.8', platforms: :mri
28+
gem 'simplecov', '~> 0.21', platforms: :mri
29+
gem 'simplecov-lcov', '~> 0.8', platforms: :mri
3130
end

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Install with `gem install rdf-rdfxml`
2020

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

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

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

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

57-
### Additional vocabularies
58-
* {RDF::XML}
59-
60-
## TODO
61-
* Consider a SAX-based parser for improved performance
62-
6357
## Resources
6458
* [RDF.rb][RDF.rb]
6559
* [RDF/XML][RDF/XML]
@@ -109,4 +103,5 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
109103
[YARD]: https://yardoc.org/
110104
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
111105
[PDD]: https://unlicense.org/#unlicensing-contributions
112-
[RDF/XML doc]: https://rubydoc.info/github/ruby-rdf/rdf-rdfxml/master/frames
106+
[RDF/XML doc]: https://rubydoc.info/github/ruby-rdf/rdf-rdfxml/master/frames
107+
[RDF-star]: https://w3c.github.io/rdf-star/rdf-star-cg-spec.html

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.1
1+
3.2.0

rdf-rdfxml.gemspec

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,21 @@ Gem::Specification.new do |gem|
1818
gem.files = %w(README.md History.md AUTHORS CONTRIBUTORS VERSION UNLICENSE) + Dir.glob('lib/**/*.rb')
1919
gem.require_paths = %w(lib)
2020

21-
gem.required_ruby_version = '>= 2.4'
21+
gem.required_ruby_version = '>= 2.6'
2222
gem.requirements = []
2323

24-
gem.add_runtime_dependency 'rdf', '~> 3.1'
25-
gem.add_runtime_dependency 'rdf-xsd', '~> 3.1'
26-
gem.add_runtime_dependency 'rdf-rdfa', '~> 3.1'
24+
gem.add_runtime_dependency 'rdf', '~> 3.2'
25+
gem.add_runtime_dependency 'rdf-xsd', '~> 3.2'
26+
gem.add_runtime_dependency 'rdf-rdfa', '~> 3.2'
2727
gem.add_runtime_dependency 'htmlentities', '~> 4.3'
2828

29-
#gem.add_development_dependency 'nokogiri' , '~> 1.10'
30-
#gem.add_development_dependency 'equivalent-xml' , '~> 0.6' # conditionally done in Gemfile
31-
gem.add_development_dependency 'json-ld', '>= 3.1'
29+
gem.add_development_dependency 'json-ld', '>= 3.2'
3230
gem.add_development_dependency 'rspec', '~> 3.10'
3331
gem.add_development_dependency 'rspec-its', '~> 1.3'
34-
gem.add_development_dependency 'rdf-isomorphic', '~> 3.1'
35-
gem.add_development_dependency 'rdf-turtle', '~> 3.1'
36-
gem.add_development_dependency 'rdf-spec', '~> 3.1'
37-
gem.add_development_dependency 'rdf-vocab', '~> 3.1'
32+
gem.add_development_dependency 'rdf-isomorphic', '~> 3.2'
33+
gem.add_development_dependency 'rdf-turtle', '~> 3.2'
34+
gem.add_development_dependency 'rdf-spec', '~> 3.2'
35+
gem.add_development_dependency 'rdf-vocab', '~> 3.2'
3836
gem.add_development_dependency 'yard' , '~> 0.9'
3937

4038
gem.post_install_message = nil

script/parse

Lines changed: 86 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ require "bundler/setup"
55
require 'rdf/rdfxml'
66
require 'rdf/turtle'
77
require 'rdf/ntriples'
8+
require 'rdf/ordered_repo'
89
require 'getoptlong'
910
require 'logger'
10-
require 'open-uri'
1111

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

1919
if options[:output_format] == :ntriples || options[:quiet]
20-
reader_class.new(input, **options).each do |statement|
20+
reader_class.new(input, **options[:parser_options]).each do |statement|
2121
num += 1
22-
if options[:quiet]
23-
#print "."
22+
if options[:errors] && statement.invalid?
23+
$stderr.puts "Invalid statement #{statement.inspect}"
24+
elsif options[:quiet]
25+
print "." if options[:quiet] == 1
2426
else
2527
options[:output].puts statement.to_ntriples
2628
end
@@ -31,63 +33,108 @@ def run(input, **options)
3133
options[:output].puts statement.inspect
3234
end
3335
else
34-
r = reader_class.new(input, **options)
35-
g = RDF::Repository.new << r
36+
r = reader_class.new(input, **options[:parser_options])
37+
g = RDF::OrderedRepo.new << r
3638
num = g.count
37-
STDERR.puts "graph: #{g.dump(:ttl)}" if options[:verbose]
38-
options[:output].puts g.dump(options[:output_format], options.merge(prefixes: r.prefixes))
39+
options[:output].puts g.dump(options[:output_format], prefixes: r.prefixes, **options[:writer_options])
3940
end
40-
STDERR.puts
41+
$stderr.puts
4142
secs = Time.new - start
42-
STDERR.puts "Parsed #{num} statements in #{secs} seconds @ #{num/secs} statements/second."
43-
rescue
43+
$stderr.puts "Parsed #{num} statements in #{secs} seconds @ #{num/secs} statements/second."
44+
rescue Exception => e
4445
fname = input.respond_to?(:path) ? input.path : "-stdin-"
45-
STDERR.puts("Error in #{fname}")
46-
raise
46+
$stderr.puts("Error in #{fname}: #{e.message}")
47+
$stderr.puts "Backtrace: " + e.backtrace.join("\n ")
48+
raise e
4749
end
4850

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

55+
parser_options = {
56+
base_uri: nil,
57+
validate: false,
58+
logger: logger,
59+
}
60+
61+
writer_options = {
62+
base_uri: nil,
63+
standard_prefixes: true,
64+
logger: logger,
65+
}
66+
5367
options = {
68+
parser_options: parser_options,
69+
writer_options: writer_options,
5470
input_format: :rdfxml,
55-
output: STDOUT,
5671
output_format: :ntriples,
72+
output: STDOUT,
5773
strict: true,
5874
validate: false,
5975
verbose: false,
60-
logger: logger
6176
}
77+
6278
input = nil
6379

64-
opts = GetoptLong.new(
65-
["--dbg", GetoptLong::NO_ARGUMENT],
66-
["--execute", "-e", GetoptLong::REQUIRED_ARGUMENT],
67-
["--format", GetoptLong::REQUIRED_ARGUMENT],
68-
["--input-format", GetoptLong::REQUIRED_ARGUMENT],
69-
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT],
70-
["--quiet", GetoptLong::NO_ARGUMENT],
71-
["--template", GetoptLong::REQUIRED_ARGUMENT],
72-
["--uri", GetoptLong::REQUIRED_ARGUMENT],
73-
["--validate", GetoptLong::NO_ARGUMENT],
74-
["--verbose", GetoptLong::NO_ARGUMENT],
75-
)
80+
OPT_ARGS = [
81+
["--canonicalize", GetoptLong::NO_ARGUMENT, "Canonize all terms"],
82+
["--debug", GetoptLong::NO_ARGUMENT, "Debugging output"],
83+
["--errors", GetoptLong::NO_ARGUMENT, "Display invalid statements"],
84+
["--execute", "-e", GetoptLong::REQUIRED_ARGUMENT, "Run against source in argument"],
85+
["--format", GetoptLong::REQUIRED_ARGUMENT, "Output format, any RDF format symbol, sxp, or inspect"],
86+
["--help", "-?", GetoptLong::NO_ARGUMENT, "print this message"],
87+
["--input-format", GetoptLong::REQUIRED_ARGUMENT, "Format of the input file, defaults to ttl"],
88+
["--info", GetoptLong::NO_ARGUMENT, "Show progress on execution"],
89+
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT, "Save output to file"],
90+
["--quiet", GetoptLong::NO_ARGUMENT, "Do not show parser output"],
91+
["--stream", GetoptLong::NO_ARGUMENT, "Use streaming writer"],
92+
["--template", GetoptLong::REQUIRED_ARGUMENT, "Haml template for writer"],
93+
["--uri", GetoptLong::REQUIRED_ARGUMENT, "Default base URI"],
94+
["--validate", GetoptLong::NO_ARGUMENT, "Run parser in strict validation mode"],
95+
["--verbose", GetoptLong::NO_ARGUMENT, "Verbose output"],
96+
]
97+
98+
def usage
99+
STDERR.puts %{
100+
RDF::RDFXML version #{RDF::RDFXML::VERSION}
101+
102+
Usage: #{$0} [options] file ...
103+
}.gsub(/^ /, '')
104+
width = OPT_ARGS.map do |o|
105+
l = o.first.length
106+
l += o[1].length + 2 if o[1].is_a?(String)
107+
l
108+
end.max
109+
OPT_ARGS.each do |o|
110+
s = " %-*s " % [width, (o[1].is_a?(String) ? "#{o[0,2].join(', ')}" : o[0])]
111+
s += o.last
112+
STDERR.puts s
113+
end
114+
exit(1)
115+
end
116+
117+
opts = GetoptLong.new(*OPT_ARGS.map {|o| o[0..-2]})
118+
76119
opts.each do |opt, arg|
77120
case opt
78-
when '--dbg' then logger.level = Logger::DEBUG
79-
when '--execute' then input = arg
80-
when '--format' then options[:output_format] = arg.to_sym
81-
when '--input-format' then options[:input_format] = arg.to_sym
82-
when '--output' then options[:output] = File.open(arg, "w")
121+
when '--debug' then logger.level = Logger::DEBUG
122+
when '--canonicalize' then parser_options[:canonicalize] = true
123+
when '--errors' then options[:errors] = true
124+
when '--execute' then input = arg
125+
when '--format' then options[:output_format] = arg.to_sym
126+
when "--help" then usage()
127+
when '--input-format' then options[:input_format] = arg.to_sym
128+
when '--output' then options[:output] = File.open(arg, "w")
129+
when '--rdfstar' then parser_options[:rdfstar] = true
83130
when '--quiet'
84-
options[:quiet] = true
131+
options[:quiet] = options[:quiet].to_i + 1
85132
logger.level = Logger::FATAL
86-
when '--template' then options[:haml] = arg.to_sym
87-
when '--uri' then options[:base_uri] = arg
88-
when '--validate' then options[:validate] = true
89-
when '--verbose' then options[:verbose] = true
90-
when '--version' then options[:version] = arg
133+
when '--template' then options[:haml] = arg.to_sym
134+
when '--uri' then parser_options[:base_uri] = writer_options[:base_uri] = arg
135+
when '--validate' then parser_options[:validate] = true
136+
when '--verbose' then options[:verbose] = true
137+
when '--version' then options[:version] = arg
91138
end
92139
end
93140

@@ -99,3 +146,4 @@ else
99146
run(Kernel.open(test_file), **options)
100147
end
101148
end
149+
puts

spec/spec_helper.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@
1616
end
1717
begin
1818
require 'simplecov'
19-
require 'coveralls'
19+
require 'simplecov-lcov'
20+
SimpleCov::Formatter::LcovFormatter.config do |config|
21+
#Coveralls is coverage by default/lcov. Send info results
22+
config.report_with_single_file = true
23+
config.single_report_path = 'coverage/lcov.info'
24+
end
25+
2026
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
2127
SimpleCov::Formatter::HTMLFormatter,
22-
Coveralls::SimpleCov::Formatter
28+
SimpleCov::Formatter::LcovFormatter
2329
])
2430
SimpleCov.start do
2531
add_filter "/spec/"

0 commit comments

Comments
 (0)