Skip to content

Commit

Permalink
Finish 0.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Aug 21, 2017
2 parents 7aec907 + 1908499 commit 3381139
Show file tree
Hide file tree
Showing 11 changed files with 840 additions and 26 deletions.
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ script: "bundle exec rspec spec"
env:
- CI=true
rvm:
- 2.2.6
- 2.3.3
- 2.4.0
- jruby
- 2.2
- 2.3
- 2.4
- jruby-9
- rbx-3
cache: bundler
sudo: false
matrix:
allow_failures:
- rvm: jruby
- rvm: jruby-9
- rvm: rbx-3
dist: trusty
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ group :development, :test do
gem 'ebnf', github: "gkellogg/ebnf", branch: "develop"
gem 'json-ld', github: "ruby-rdf/json-ld", branch: "develop"
gem 'rdf-isomorphic', github: "ruby-rdf/rdf-isomorphic", branch: "develop"
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 'sxp', github: "dryruby/sxp.rb", branch: "develop"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
[SPARQL Query]: http://www.w3.org/TR/2013/REC-sparql11-query-20130321/
[SPARQL Entailment]:http://www.w3.org/TR/sparql11-entailment/
[RDF 1.1]: http://www.w3.org/TR/rdf11-concepts
[RDF.rb]: http://rdf.rubyforge.org/
[RDF.rb]: http://www.rubydoc.info/github/ruby-rdf/rdf/
[RDF Schema]: http://www.w3.org/TR/rdf-schema/
[Rack]: http://rack.rubyforge.org/
[Rack]: https://rack.github.io/
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.2
0.4.3
25 changes: 25 additions & 0 deletions examples/gs1-langString.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

<!DOCTYPE html>
<html>
<head>
<script type="application/ld+json">
{
"@context": {
"gs1": "http://gs1.org/voc/",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"@vocab": "http://gs1.org/voc/"
},
"@type": "gs1:Organization",
"@id": "http://www.gs1.dk/id/gln/5790000713882",
"organizationName": [
{
"@value": "GS1 Denmark",
"@language": "en"
}
]
}
</script>
</head>
<body>
</body>
</html>
767 changes: 767 additions & 0 deletions examples/gs1.html

Large diffs are not rendered by default.

24 changes: 11 additions & 13 deletions lib/rdf/reasoner/format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,31 @@ class Format < RDF::Format
def self.cli_commands
{
entail: {
description: "Perform RDFS entailment to expand the repository based on referenced built-in vocabuaries",
help: "entail",
description: "Add entailed triples to repository",
help: "entail\nPerform RDFS, OWL and schema.org entailment to expand the repository based on referenced built-in vocabuaries",
control: :button, # Treats this like a separate control in the HTML UI
parse: true,
lambda: ->(argv, opts) do
RDF::Reasoner.apply(:rdfs, :owl, :schema)
start, stmt_cnt = Time.now, RDF::CLI.repository.count
RDF::CLI.repository.entail!
secs, new_cnt = (Time.new - start), (RDF::CLI.repository.count - stmt_cnt)
$stdout.puts "\nEntailed #{new_cnt} new statements in #{secs} seconds."
opts[:logger].info "\nEntailed #{new_cnt} new statements in #{secs} seconds."
end
},
lint: {
description: "Lint the repository using built-in vocabularies",
help: "lint",
description: "Lint the repository",
help: "lint\nLint the repository using built-in vocabularies",
parse: true,
option_use: {output_format: :disabled},
lambda: ->(argv, opts) do
RDF::Reasoner.apply(:rdfs, :owl, :schema)
start = Time.now
messages = RDF::CLI.repository.lint
# Messages added to opts for appropriate display
opts[:messages].merge!(RDF::CLI.repository.lint)
opts[:output].puts "Linter responded with #{opts[:messages].empty? ? 'no' : ''} messages."
secs = Time.new - start
messages.each do |kind, term_messages|
term_messages.each do |term, messages|
$stdout.puts "#{kind} #{term}"
messages.each {|m| $stdout.puts " #{m}"}
end
end
$stdout.puts "\nLinted in #{secs} seconds."
opts[:logger].info "\nLinted in #{secs} seconds."
end
}
}
Expand Down
3 changes: 3 additions & 0 deletions lib/rdf/reasoner/rdfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ def range_compatible_rdfs?(resource, queryable, options = {})
ranges.all? do |range|
if [RDF::RDFS.Literal, RDF.XMLLiteral, RDF.HTML].include?(range)
true # Don't bother checking for validity
elsif range == RDF.langString
# Value must have a language
resource.has_language?
elsif range.start_with?(RDF::XSD)
# XSD types are valid if the datatype matches, or they are plain and valid according to the grammar of the range
resource.datatype == range ||
Expand Down
2 changes: 1 addition & 1 deletion rdf-reasoner.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |gem|

gem.required_ruby_version = '>= 2.2.2'
gem.requirements = []
gem.add_runtime_dependency 'rdf', '~> 2.2'
gem.add_runtime_dependency 'rdf', '~> 2.2', '>= 2.2.8'
gem.add_runtime_dependency 'rdf-vocab', '~> 2.2'
gem.add_runtime_dependency 'rdf-xsd', '~> 2.1'

Expand Down
6 changes: 2 additions & 4 deletions spec/format_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@
describe ".cli_commands" do
require 'rdf/cli'
let(:ttl) {File.expand_path("../../etc/doap.ttl", __FILE__)}
let(:capture) {StringIO.new}

it "entails" do
expect {RDF::CLI.exec(["entail", "serialize", ttl], format: :ttl, output: capture)}.to write.to(:output)
expect(capture.string).not_to be_empty
expect {RDF::CLI.exec(["entail", "serialize", ttl], format: :ttl)}.to write.to(:output)
end

it "lints" do
expect {RDF::CLI.exec(["lint", ttl], format: :ttl)}.to write(/Linted in .* seconds/).to(:output)
expect {RDF::CLI.exec(["lint", ttl], format: :ttl)}.to write(/Linter responded with no messages/).to(:output)
end
end
end
19 changes: 19 additions & 0 deletions spec/rdfs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,25 @@
end
end
end

context "GS1" do
{
"langString" => %(
<foo> gs1:organizationName "GS1 Denmark"@en .
),
}.each do |name, input|
it name do
input = %(
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix gs1: <http://gs1.org/voc/> .
) + input
graph = RDF::Graph.new << RDF::Turtle::Reader.new(input)
statement = graph.to_a.reject {|s| s.predicate == RDF.type}.first
expect(RDF::Vocabulary.find_term(statement.predicate)).to be_range_compatible(statement.object, graph)
end
end
end
end

it "uses supplied types" do
Expand Down

0 comments on commit 3381139

Please sign in to comment.