rdf-turtle 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
OSZAR »