Skip to content

Commit

Permalink
Finish 3.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Feb 2, 2021
2 parents f6afa23 + 02ae27b commit 9e563ea
Show file tree
Hide file tree
Showing 14 changed files with 203 additions and 73 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
@@ -0,0 +1 @@
repo_token: T4Cj59vkwBh79F3pGpO8GAJ9pdMACx9b9
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,40 @@
# This workflow runs continuous CI across different versions of ruby on all branches and pull requests to develop.

name: CI
on:
push:
branches: [ '**' ]
pull_request:
branches: [ develop ]
workflow_dispatch:

jobs:
tests:
name: Ruby ${{ matrix.ruby }}
if: "contains(github.event.commits[0].message, '[ci skip]') == false"
runs-on: ubuntu-latest
env:
CI: true
strategy:
fail-fast: false
matrix:
ruby:
- 2.4
- 2.5
- 2.6
- 2.7
- 3.0
- ruby-head
- jruby
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Install dependencies
run: bundle install --jobs 4 --retry 3
- name: Run tests
run: bundle exec rspec spec

8 changes: 5 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -28,9 +28,11 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to manage devel
enough, be assured we will eventually add you in there.
* Do note that in order for us to merge any non-trivial changes (as a rule
of thumb, additions larger than about 15 lines of code), we need an
explicit [public domain dedication][PDD] on record from you.
explicit [public domain dedication][PDD] on record from you,
which you will be asked to agree to on the first commit to a repo within the organization.
Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.

[YARD]: https://yardoc.org/
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
[pr]: https://github.com/ruby-rdf/rdf-trig/compare/
[PDD]: https://unlicense.org/#unlicensing-contributions
[pr]: https://github.com/ruby-rdf/rdf/compare/
1 change: 0 additions & 1 deletion Gemfile
Expand Up @@ -8,7 +8,6 @@ gem 'ebnf', git: "https://github.com/dryruby/ebnf", branch: "devel

group :development do
gem "byebug", platforms: :mri
gem 'psych', platforms: [:mri, :rbx]
end

group :development, :test do
Expand Down
11 changes: 7 additions & 4 deletions README.md
Expand Up @@ -3,8 +3,9 @@
[TriG][] reader/writer for [RDF.rb][RDF.rb] .

[![Gem Version](https://badge.fury.io/rb/rdf-trig.png)](https://badge.fury.io/rb/rdf-trig)
[![Build Status](https://travis-ci.org/ruby-rdf/rdf-trig.png?branch=master)](https://travis-ci.org/ruby-rdf/rdf-trig)
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf-trig/badge.svg)](https://coveralls.io/r/ruby-rdf/rdf-trig)
[![Build Status](https://github.com/ruby-rdf/rdf-trig/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/rdf-trig/actions?query=workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/ruby-rdf/rdf-trig/badge.svg?branch=develop)](https://coveralls.io/github/ruby-rdf/rdf-trig?branch=develop)
[![Gitter chat](https://badges.gitter.im/ruby-rdf/rdf.png)](https://gitter.im/ruby-rdf/rdf)

## Description
This is a [Ruby][] implementation of a [TriG][] reader and writer for [RDF.rb][].
Expand Down Expand Up @@ -85,7 +86,9 @@ To install the latest official release of the `RDF::TriG` gem, do:
list in the the `README`. Alphabetical order applies.
* Do note that in order for us to merge any non-trivial changes (as a rule
of thumb, additions larger than about 15 lines of code), we need an
explicit [public domain dedication][PDD] on record from you.
explicit [public domain dedication][PDD] on record from you,
which you will be asked to agree to on the first commit to a repo within the organization.
Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.

## License
This is free and unencumbered public domain software. For more information,
Expand All @@ -97,7 +100,7 @@ A copy of the [TriG EBNF][] and derived parser files are included in the reposit
[RDF]: https://www.w3.org/RDF/
[YARD]: https://yardoc.org/
[YARD-GS]: https://rubydoc.info/docs/yard/file/docs/GettingStarted.md
[PDD]: https://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
[PDD]: https://unlicense.org/#unlicensing-contributions
[RDF.rb]: https://rubydoc.info/github/ruby-rdf/rdf/master/frames
[Backports]: https://rubygems.org/gems/backports
[TriG]: https://www.w3.org/TR/trig/
Expand Down
26 changes: 0 additions & 26 deletions Rakefile
Expand Up @@ -13,29 +13,3 @@ namespace :gem do
sh "gem push pkg/rdf-trig-#{File.read('VERSION').chomp}.gem"
end
end

desc 'Default: run specs.'
task :default => :spec
task :specs => :spec

require 'rspec/core/rake_task'
desc 'Run specifications'
RSpec::Core::RakeTask.new do |spec|
spec.rspec_opts = %w(--options spec/spec.opts) if File.exists?('spec/spec.opts')
end

desc "Run specs through RCov"
RSpec::Core::RakeTask.new("spec:rcov") do |spec|
spec.rcov = true
spec.rcov_opts = %q[--exclude "spec"]
end

desc "Generate HTML report specs"
RSpec::Core::RakeTask.new("doc:spec") do |spec|
spec.rspec_opts = ["--format", "html", "-o", "doc/spec.html"]
end

require 'yard'
namespace :doc do
YARD::Rake::YardocTask.new
end
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
3.1.1
3.1.2
59 changes: 29 additions & 30 deletions etc/doap.ttl
Expand Up @@ -7,39 +7,38 @@
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://github.com/ruby-rdf/rdf-trig> a doap:GitRepository;
dc:title "RDF::TriG";
doap:browse <https://github.com/ruby-rdf/rdf-trig> .
dc:title "RDF::TriG";
doap:browse <https://github.com/ruby-rdf/rdf-trig> .

<> a doap:Project, earl:TestSubject, earl:Software;
doap:blog <https://greggkellogg.net/> ;
doap:developer <https://greggkellogg.net/foaf#me>;
doap:documenter <https://greggkellogg.net/foaf#me>;
doap:maintainer <https://greggkellogg.net/foaf#me>;
doap:bug-database <https://github.com/ruby-rdf/rdf-trig/issues>;
doap:description "TriG reader/writer for RDF.rb";
doap:name "RDF::TriG";
doap:shortdesc "TriG reader/writer for Ruby."@en;
doap:programming-language "Ruby";
doap:repository <https://github.com/ruby-rdf/rdf-trig>;
doap:mailing-list <https://lists.w3.org/Archives/Public/public-rdf-ruby/>;
doap:implements <https://www.w3.org/TR/trig/> ;
doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
<http://dbpedia.org/resource/Ruby_(programming_language)>;
doap:homepage <https://github.com/ruby-rdf/rdf-trig>;
doap:license <https://unlicense.org/1.0/>;
foaf:maker <https://greggkellogg.net/foaf#me> ;
dc:date "2011-12-22"^^xsd:date;
dc:creator <https://greggkellogg.net/foaf#me>;
dc:description "TriG reader/writer for RDF.rb";
dc:isPartOf <https://rubygems.org/gems/rdf> .
<> a doap:Project, earl:TestSubject, earl:Software;
doap:name "RDF::TriG";
doap:shortdesc "TriG reader/writer for the RDF.rb library suite"@en;
doap:description "TriG reader/writer for RDF.rb";
doap:created "2011-12-22"^^xsd:date;
doap:blog <https://greggkellogg.net/> ;
doap:developer <https://greggkellogg.net/foaf#me>;
doap:documenter <https://greggkellogg.net/foaf#me>;
doap:maintainer <https://greggkellogg.net/foaf#me>;
doap:bug-database <https://github.com/ruby-rdf/rdf-trig/issues>;
doap:programming-language "Ruby";
doap:repository <https://github.com/ruby-rdf/rdf-trig>;
doap:mailing-list <https://lists.w3.org/Archives/Public/public-rdf-ruby/>;
doap:implements <https://www.w3.org/TR/trig/> ;
doap:category <http://dbpedia.org/resource/Resource_Description_Framework>,
<http://dbpedia.org/resource/Ruby_(programming_language)>;
doap:homepage <https://github.com/ruby-rdf/rdf-trig>;
doap:license <https://unlicense.org/1.0/>;
foaf:maker <https://greggkellogg.net/foaf#me> ;
dc:creator <https://greggkellogg.net/foaf#me>;
dc:isPartOf <https://rubygems.org/gems/rdf> .

<https://github.com/gkellogg> a foaf:OnlineAccount;
dc:created "2009-01-13T08:58:46-08:00"^^xsd:dateTime;
doap:homepage <https://greggkellogg.net/>;
foaf:accountName "gkellogg";
foaf:accountServiceHomepage <https://github.com/gkellogg>;
foaf:name "GitHub";
foaf:page <https://github.com/gkellogg> .
dc:created "2009-01-13T08:58:46-08:00"^^xsd:dateTime;
doap:homepage <https://greggkellogg.net/>;
foaf:accountName "gkellogg";
foaf:accountServiceHomepage <https://github.com/gkellogg>;
foaf:name "GitHub";
foaf:page <https://github.com/gkellogg> .

<https://greggkellogg.net/foaf#me> a foaf:Person;
foaf:mbox <mailto:gregg@greggkellogg.net>;
Expand Down
29 changes: 27 additions & 2 deletions lib/rdf/trig/reader.rb
Expand Up @@ -23,7 +23,15 @@ class Reader < RDF::Turtle::Reader
terminal(:STRING_LITERAL_SINGLE_QUOTE, STRING_LITERAL_SINGLE_QUOTE, unescape: true)

# String terminals
terminal(nil, %r([\{\}\(\),.;\[\]a]|\^\^|true|false))
terminal(nil, %r(
[\(\),.;\[\]Aa]
| \^\^
| \{\|
| \|\}
| [\{\}]
| true|false
| <<|>>
)x)

terminal(:GRAPH, /graph/i)
terminal(:PREFIX, PREFIX)
Expand Down Expand Up @@ -112,7 +120,7 @@ def read_block
read_triplesOrGraph || error("Expected triplesOrGraph", production: :block, token: @lexer.first)
when '{'
read_wrappedGraph || error("Expected wrappedGraph", production: :block, token: @lexer.first)
when '(', '['
when '(', '[', '<<'
read_triples2 || error("Expected collection or blankNodePropertyList", production: :block, token: @lexer.first)
when nil
# End of input
Expand Down Expand Up @@ -183,6 +191,23 @@ def read_triples2
end
true
end
when '<<'
prod(:triples2) do
subject = read_embTriple || error("Failed to parse embedded triple", production: :triples2, token: @lexer.first)
token = @lexer.first
case token && (token.type || token.value)
when 'a', :IRIREF, :PNAME_LN, :PNAME_NS then read_predicateObjectList(subject)
else error("Expected predicateObjectList after collection subject", production: :triples2, token: token)
end
if !@recovering || @lexer.first === '.'
# If recovering, we will have eaten the closing '.'
token = @lexer.shift
unless token && token.value == '.'
error("Expected '.' following triple", production: :triples2, token: token)
end
end
true
end
end
end

Expand Down
7 changes: 3 additions & 4 deletions rdf-trig.gemspec
Expand Up @@ -21,15 +21,14 @@ Gem::Specification.new do |gem|
gem.required_ruby_version = '>= 2.4'
gem.requirements = []
gem.add_runtime_dependency 'rdf', '~> 3.1'
gem.add_runtime_dependency 'ebnf', '~> 2.0'
gem.add_runtime_dependency 'ebnf', '~> 2.1'
gem.add_runtime_dependency 'rdf-turtle', '~> 3.1'
gem.add_development_dependency 'json-ld', '~> 3.1'
gem.add_development_dependency 'rspec', '~> 3.9'
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 'yard' , '~> 0.9.20'
gem.add_development_dependency 'yard' , '~> 0.9'
gem.add_development_dependency 'rdf-spec', '~> 3.1'
gem.add_development_dependency 'rake', '~> 13.0'

gem.post_install_message = nil
end
2 changes: 2 additions & 0 deletions script/parse
Expand Up @@ -95,6 +95,7 @@ opts = GetoptLong.new(
["--profile", GetoptLong::NO_ARGUMENT],
["--progress", GetoptLong::NO_ARGUMENT],
["--quiet", GetoptLong::NO_ARGUMENT],
["--rdfstar", GetoptLong::NO_ARGUMENT],
["--validate", GetoptLong::NO_ARGUMENT],
["--verbose", GetoptLong::NO_ARGUMENT]
)
Expand All @@ -115,6 +116,7 @@ opts.each do |opt, arg|
options[:quiet] = options[:quiet].to_i + 1
logger.level = Logger::FATAL
when '--stream' then writer_options[:stream] = true
when '--rdfstar' then parser_options[:rdfstar] = true
when '--validate' then parser_options[:validate] = true
when '--verbose' then $verbose = true
end
Expand Down
4 changes: 2 additions & 2 deletions spec/reader_spec.rb
Expand Up @@ -710,7 +710,7 @@
%(GRAPH <g> <s> <p> <o> .) => %r(Expected wrappedGraph),
%(GRAPH <s> <p> <o> .) => %r(Expected wrappedGraph),
%(GRAPH <g1> <g2> {<s> <p> <o>}) => %r(Expected wrappedGraph),
%(GRAPH <g1> {<s> <p> <o>) => %r(Expected '}' following triple),
%(GRAPH <g1> {<s> <p> <o>) => RDF::ReaderError,
%(GRAPH <g> {
<s> <p> <o> .
GRAPH <g1> { <s1> <p1> <o1>}
Expand All @@ -723,7 +723,7 @@
}) => RDF::ReaderError,
%(GRAPH () { :s :p :o }) => %r(Expected label or subject),
%(GRAPH (1 2) { :s :p :o }) => %r(Expected label or subject),
%(<a> <b> <c>) => %r(Expected '.' following triple),
%(<a> <b> <c>) => RDF::ReaderError,
%([:p1 :o1] {:s :p :o}) => %r(Expected '.' following triple),
%((123) .) => %r(Expected predicateObjectList after collection subject),
}.each_pair do |trig, error|
Expand Down
52 changes: 52 additions & 0 deletions spec/star_spec.rb
@@ -0,0 +1,52 @@
$:.unshift "."
require 'spec_helper'

describe RDF::TriG::Reader do
# W3C Turtle Test suite from http://w3c.github.io/rdf-tests/turtle/manifest.ttl
describe "rdfstar turtle tests" do
require 'suite_helper'

%w(turtle/syntax turtle/eval).each do |man|
Fixtures::SuiteTest::Manifest.open("https://w3c.github.io/rdf-star/tests/#{man}/manifest.ttl") do |m|
describe [m.label, m.comment].compact.join(': ') do
m.entries.each do |t|
specify "#{t.name}: #{t.comment}" do
t.logger = RDF::Spec.logger
t.logger.info t.inspect
t.logger.info "source:\n#{t.input}"

reader = RDF::TriG::Reader.new(t.input,
base_uri: t.base,
canonicalize: false,
validate: true,
rdfstar: true,
logger: t.logger)

graph = RDF::Repository.new

if t.positive_test?
begin
graph << reader
rescue Exception => e
expect(e.message).to produce("Not exception #{e.inspect}", t)
end

if t.evaluate?
output_graph = RDF::Repository.load(t.result, format: :ntriples, rdfstar: true, base_uri: t.base)
expect(graph).to be_equivalent_graph(output_graph, t)
else
expect(graph).to be_a(RDF::Enumerable)
end
else
expect {
graph << reader
expect(graph.dump(:ntriples)).to produce("not this", t)
}.to raise_error(RDF::ReaderError)
end
end
end
end
end
end
end
end unless ENV['CI']

0 comments on commit 9e563ea

Please sign in to comment.