Skip to content

Commit 4b8beaf

Browse files
committed
Finish 0.5.1
2 parents 9dee491 + 52eed80 commit 4b8beaf

File tree

21 files changed

+384
-88
lines changed

21 files changed

+384
-88
lines changed

.travis.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ before_install:
1111
env:
1212
- CI=true
1313
rvm:
14-
- 2.2.6
15-
- 2.3.3
16-
- 2.4.0
17-
- jruby
18-
- rbx
14+
- 2.2
15+
- 2.3
16+
- 2.4
17+
- jruby-9
18+
- rbx-3
1919
cache: bundler
2020
sudo: false
2121
matrix:
2222
allow_failures:
23-
- rvm: jruby
24-
- rvm: rbx
23+
- rvm: jruby-9
24+
- rvm: rbx-3
25+
dist: trusty

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,20 @@ The `#initialize` method is called when {ShEx::Algebra::Schema#execute} starts a
164164

165165
To make sure your extension is found, make sure to require it before the shape is executed.
166166

167+
## Command Line
168+
When the `linkeddata` gem is installed, RDF.rb includes a `rdf` executable which acts as a wrapper to perform a number of different
169+
operations on RDF files, including ShEx. The commands specific to ShEx is
170+
171+
* `shex`: Validate repository given shape
172+
173+
Using this command requires either a `shex-input` where the ShEx schema is URI encoded, or `shex`, which references a URI or file path to the schema. Other required options are `shape` and `focus`.
174+
175+
Example usage:
176+
177+
rdf shex https://raw.githubusercontent.com/ruby-rdf/shex/develop/etc/doap.ttl \
178+
--schema https://raw.githubusercontent.com/ruby-rdf/shex/develop/etc/doap.shex \
179+
--focus http://rubygems.org/gems/shex
180+
167181
## Documentation
168182

169183
<http://rubydoc.info/github/ruby-rdf/shex>

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.0
1+
0.5.1

etc/doap.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"@context": "http://www.w3.org/ns/shex.jsonld",
33
"type": "Schema",
4+
"start": "http://rubygems.org/gems/shex/DOAP",
45
"shapes": [
56
{
7+
"id": "http://rubygems.org/gems/shex/DOAP",
68
"type": "Shape",
7-
"id": "TestShape",
89
"extra": [
910
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
1011
],
@@ -17,9 +18,7 @@
1718
"valueExpr": {
1819
"type": "NodeConstraint",
1920
"values": [
20-
{
21-
"uri": "http://usefulinc.com/ns/doap#Project"
22-
}
21+
"http://usefulinc.com/ns/doap#Project"
2322
]
2423
}
2524
},
@@ -98,15 +97,12 @@
9897
"valueExpr": {
9998
"type": "NodeConstraint",
10099
"values": [
101-
{
102-
"uri": "http://shex.io/shex-semantics/"
103-
}
100+
"http://shex.io/shex-semantics/"
104101
]
105102
}
106103
}
107104
]
108105
}
109106
}
110107
]
111-
}
112-
108+
}

etc/doap.shex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
BASE <http://rubygems.org/gems/shex/>
12
PREFIX doap: <http://usefulinc.com/ns/doap#>
23
PREFIX dc: <http://purl.org/dc/terms/>
3-
<TestShape> EXTRA a {
4+
5+
start=@<DOAP>
6+
7+
<DOAP> EXTRA a {
48
a [doap:Project];
59

610
# May have either or both of doap:name/doap:description or dc:title/dc:description

etc/doap.ttl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@base <http://rubygems.org/gems/shex> .
12
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
23
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
34
@prefix dc: <http://purl.org/dc/terms/> .

examples/lang_stem.shex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PREFIX my: <http://my.example/>
2+
3+
my:IssueShape {
4+
my:status [@en~ @fr];
5+
}

lib/shex.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44
# @see http://shex.io/shex-semantics/#shexc
55
module ShEx
6+
require 'shex/format'
67
autoload :Algebra, 'shex/algebra'
78
autoload :Meta, 'shex/meta'
89
autoload :Parser, 'shex/parser'

lib/shex/algebra.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module Algebra
1313
autoload :External, 'shex/algebra/external'
1414
autoload :IriStem, 'shex/algebra/stem'
1515
autoload :IriStemRange, 'shex/algebra/stem_range'
16+
autoload :Language, 'shex/algebra/language'
1617
autoload :LanguageStem, 'shex/algebra/stem'
1718
autoload :LanguageStemRange,'shex/algebra/stem_range'
1819
autoload :LiteralStem, 'shex/algebra/stem'
@@ -56,6 +57,7 @@ def self.from_shexj(operator, options = {})
5657
when 'EachOf' then EachOf
5758
when 'IriStem' then IriStem
5859
when 'IriStemRange' then IriStemRange
60+
when 'Language' then Language
5961
when 'LanguageStem' then LanguageStem
6062
when 'LanguageStemRange' then LanguageStemRange
6163
when 'LiteralStem' then LiteralStem

lib/shex/algebra/language.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module ShEx::Algebra
2+
##
3+
class Language < Operator::Unary
4+
NAME = :language
5+
6+
##
7+
# matches any literal having a language tag that matches value
8+
def match?(value, depth: 0)
9+
status "", depth: depth
10+
if case expr = operands.first
11+
when RDF::Literal then value.language == expr.to_s.to_sym
12+
else false
13+
end
14+
status "matched #{value}", depth: depth
15+
true
16+
else
17+
status "not matched #{value}", depth: depth
18+
false
19+
end
20+
end
21+
end
22+
end

0 commit comments

Comments
 (0)