rdf-turtle 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History +4 -0
- data/README.markdown +2 -2
- data/VERSION +1 -1
- data/lib/rdf/ll1/lexer.rb +19 -4
- data/lib/rdf/ll1/parser.rb +126 -75
- data/lib/rdf/turtle.rb +0 -2
- data/lib/rdf/turtle/format.rb +3 -2
- data/lib/rdf/turtle/meta.rb +553 -126
- data/lib/rdf/turtle/reader.rb +26 -26
- data/lib/rdf/turtle/terminals.rb +20 -10
- data/lib/rdf/turtle/writer.rb +41 -36
- metadata +41 -19
- data/lib/rdf/turtle/patches.rb +0 -38
data/lib/rdf/turtle/patches.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'rdf'
|
2
|
-
|
3
|
-
module RDF
|
4
|
-
class List
|
5
|
-
##
|
6
|
-
# Validate the list ensuring that
|
7
|
-
# * rdf:rest values are all BNodes are nil
|
8
|
-
# * rdf:type, if it exists, is rdf:List
|
9
|
-
# * each subject has no properties other than single-valued rdf:first, rdf:rest
|
10
|
-
# other than for the first node in the list
|
11
|
-
# @return [Boolean]
|
12
|
-
def valid?
|
13
|
-
li = subject
|
14
|
-
while li != RDF.nil do
|
15
|
-
rest = nil
|
16
|
-
firsts = rests = 0
|
17
|
-
@graph.query(:subject => li) do |st|
|
18
|
-
case st.predicate
|
19
|
-
when RDF.type
|
20
|
-
# Be tollerant about rdf:type entries, as some OWL vocabularies use it excessively
|
21
|
-
when RDF.first
|
22
|
-
firsts += 1
|
23
|
-
when RDF.rest
|
24
|
-
rest = st.object
|
25
|
-
return false unless rest.node? || rest == RDF.nil
|
26
|
-
rests += 1
|
27
|
-
else
|
28
|
-
# First node may have other properties
|
29
|
-
return false unless li == subject
|
30
|
-
end
|
31
|
-
end
|
32
|
-
return false unless firsts == 1 && rests == 1
|
33
|
-
li = rest
|
34
|
-
end
|
35
|
-
true
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|