Skip to content

Commit

Permalink
Finish 0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Feb 16, 2021
2 parents 872e812 + 83e2835 commit 23a6b4b
Show file tree
Hide file tree
Showing 14 changed files with 184 additions and 67 deletions.
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
repo_token: 5dBrPdCfXwVQ74ngZ0JjaCm1RLqSRmK6R
39 changes: 39 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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
- 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
Original file line number Diff line number Diff line change
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-reasoner/compare/
[PDD]: https://unlicense.org/#unlicensing-contributions
[pr]: https://github.com/ruby-rdf/rdf/compare/
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ source "https://rubygems.org"
gemspec

gem "rdf", github: "ruby-rdf/rdf", branch: "develop"
gem "rdf-vocab", github: "ruby-rdf/rdf-vocab", branch: "develop"
gem 'rdf-xsd', github: "ruby-rdf/rdf-xsd", branch: "develop"

group :development, :test do
Expand All @@ -14,6 +13,7 @@ group :development, :test do
gem "rdf-rdfa", github: "ruby-rdf/rdf-rdfa", branch: "develop"
gem "rdf-spec", github: "ruby-rdf/rdf-spec", branch: "develop"
gem 'rdf-turtle', github: "ruby-rdf/rdf-turtle", branch: "develop"
gem "rdf-vocab", github: "ruby-rdf/rdf-vocab", branch: "develop"
gem 'sxp', github: "dryruby/sxp.rb", branch: "develop"
gem 'rake'
gem 'simplecov', require: false
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# rdf-reasoner
# RDF::Reasoner

A partial RDFS/OWL/schema.org reasoner for [RDF.rb][].

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

## Description

Reasons over RDFS/OWL vocabularies and schema.org to generate statements which are entailed based on base RDFS/OWL rules along with vocabulary information. It can also be used to ask specific questions, such as if a given object is consistent with the vocabulary ruleset. This can be used to implement [SPARQL Entailment][] Regimes and [RDF Schema][] entailment.

Expand Down Expand Up @@ -136,7 +145,9 @@ The `rdf` command-line interface is extended with `entail` and `lint` commands.
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

Expand All @@ -147,7 +158,7 @@ see <https://unlicense.org/> or the accompanying {file:UNLICENSE} file.
[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
[SPARQL]: https://en.wikipedia.org/wiki/SPARQL
[SPARQL Query]: https://www.w3.org/TR/2013/REC-sparql11-query-20130321/
[SPARQL Entailment]:https://www.w3.org/TR/sparql11-entailment/
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.2
0.7.0
9 changes: 0 additions & 9 deletions etc/doap.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@
doap:maintainer <https://greggkellogg.net/foaf#me> ;
doap:documenter <https://greggkellogg.net/foaf#me> ;
foaf:maker <https://greggkellogg.net/foaf#me> ;
dc:title "RDF::Reasoner" ;
dc:description """
Reasons over RDFS/OWL vocabularies to generate statements which are
entailed based on base RDFS/OWL rules along with vocabulary information. It
can also be used to ask specific questions, such as if a given object is
consistent with the vocabulary ruleset. This can be used to implement
SPARQL Entailment Regimes.
"""@en ;
dc:date "2014-06-01"^^xsd:date ;
dc:creator <https://greggkellogg.net/foaf#me> ;
dc:isPartOf <https://rubygems.org/gems/rdf> .

Expand Down
1 change: 0 additions & 1 deletion lib/rdf/reasoner.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'rdf'
require 'rdf/reasoner/extensions'
require 'rdf/vocab'

module RDF
##
Expand Down
4 changes: 2 additions & 2 deletions lib/rdf/reasoner/extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def lint
# Must be a defined term, not in RDF or RDFS vocabularies
if term && term.class?
# Warn against using a deprecated term
superseded = term.attributes[:'schema:supersededBy']
superseded = term.properties[:'http://schema.org/supersededBy']
superseded = superseded.pname if superseded.respond_to?(:pname)
(messages[:class] ||= {})[pname] = ["Term is superseded by #{superseded}"] if superseded
else
Expand All @@ -266,7 +266,7 @@ def lint
# Must be a defined property
if term.respond_to?(:property?) && term.property?
# Warn against using a deprecated term
superseded = term.attributes[:'schema:supersededBy']
superseded = term.properties[:'http://schema.org/supersededBy']
superseded = superseded.pname if superseded.respond_to?(:pname)
(messages[:property] ||= {})[pname] = ["Term is superseded by #{superseded}"] if superseded
else
Expand Down
28 changes: 14 additions & 14 deletions lib/rdf/reasoner/rdfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,40 +290,40 @@ def range_compatible_rdfs?(resource, queryable, options = {})
# XSD types are valid if the datatype matches, or they are plain and valid according to the grammar of the range
resource.datatype == range ||
resource.plain? && RDF::Literal.new(resource.value, datatype: range).valid?
elsif range.start_with?(RDF::Vocab::OGC)
elsif range.start_with?("http://ogp.me/ns/class#")
case range
when RDF::Vocab::OGC.boolean_str
[RDF::Vocab::OGC.boolean_str, RDF::XSD.boolean].include?(resource.datatype) ||
when RDF::URI("http://ogp.me/ns/class#boolean_str")
[RDF::URI("http://ogp.me/ns/class#boolean_str"), RDF::XSD.boolean].include?(resource.datatype) ||
resource.plain? && RDF::Literal::Boolean.new(resource.value).valid?
when RDF::Vocab::OGC.date_time_str
when RDF::URI("http://ogp.me/ns/class#date_time_str")
# Schema.org date based on ISO 8601, mapped to appropriate XSD types for validation
case resource
when RDF::Literal::Date, RDF::Literal::Time, RDF::Literal::DateTime, RDF::Literal::Duration
resource.valid?
else
ISO_8601.match(resource.value)
end
when RDF::Vocab::OGC.determiner_str
when RDF::URI("http://ogp.me/ns/class#determiner_str")
# The lexical space: "", "the", "a", "an", and "auto".
resource.plain? && (%w(the a an auto) + [""]).include?(resource.value)
when RDF::Vocab::OGC.float_str
when RDF::URI("http://ogp.me/ns/class#float_str")
# A string representation of a 64-bit signed floating point number. Example lexical values include "1.234", "-1.234", "1.2e3", "-1.2e3", and "7E-10".
[RDF::Vocab::OGC.float_str, RDF::Literal::Double, RDF::Literal::Float].include?(resource.datatype) ||
[RDF::URI("http://ogp.me/ns/class#float_str"), RDF::Literal::Double, RDF::Literal::Float].include?(resource.datatype) ||
resource.plain? && RDF::Literal::Double.new(resource.value).valid?
when RDF::Vocab::OGC.integer_str
when RDF::URI("http://ogp.me/ns/class#integer_str")
resource.is_a?(RDF::Literal::Integer) ||
[RDF::Vocab::OGC.integer_str].include?(resource.datatype) ||
[RDF::URI("http://ogp.me/ns/class#integer_str")].include?(resource.datatype) ||
resource.plain? && RDF::Literal::Integer.new(resource.value).valid?
when RDF::Vocab::OGC.mime_type_str
when RDF::URI("http://ogp.me/ns/class#mime_type_str")
# Valid mime type strings \(e.g., "application/mp3"\).
[RDF::Vocab::OGC.mime_type_str].include?(resource.datatype) ||
[RDF::URI("http://ogp.me/ns/class#mime_type_str")].include?(resource.datatype) ||
resource.plain? && resource.value =~ %r(^[\w\-\+]+/[\w\-\+]+$)
when RDF::Vocab::OGC.string
when RDF::URI("http://ogp.me/ns/class#string")
resource.plain?
when RDF::Vocab::OGC.url
when RDF::URI("http://ogp.me/ns/class#url")
# A string of Unicode characters forming a valid URL having the http or https scheme.
u = RDF::URI(resource.value)
resource.datatype == RDF::Vocab::OGC.url ||
resource.datatype == RDF::URI("http://ogp.me/ns/class#url") ||
resource.datatype == RDF::XSD.anyURI ||
resource.simple? && u.valid? && u.scheme.to_s =~ /^https?$/
else
Expand Down
Loading

0 comments on commit 23a6b4b

Please sign in to comment.