rdf 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -1
- data/VERSION +1 -1
- data/lib/rdf.rb +25 -22
- data/lib/rdf/enumerable.rb +554 -0
- data/lib/rdf/format.rb +239 -41
- data/lib/rdf/model/graph.rb +82 -0
- data/lib/rdf/{literal.rb → model/literal.rb} +47 -4
- data/lib/rdf/{node.rb → model/node.rb} +0 -0
- data/lib/rdf/{resource.rb → model/resource.rb} +0 -0
- data/lib/rdf/{statement.rb → model/statement.rb} +12 -0
- data/lib/rdf/{uri.rb → model/uri.rb} +20 -7
- data/lib/rdf/model/value.rb +135 -0
- data/lib/rdf/ntriples.rb +35 -2
- data/lib/rdf/ntriples/format.rb +4 -4
- data/lib/rdf/ntriples/reader.rb +2 -2
- data/lib/rdf/ntriples/writer.rb +26 -19
- data/lib/rdf/query.rb +4 -4
- data/lib/rdf/query/pattern.rb +3 -3
- data/lib/rdf/query/solution.rb +2 -2
- data/lib/rdf/query/variable.rb +3 -3
- data/lib/rdf/reader.rb +85 -16
- data/lib/rdf/repository.rb +104 -12
- data/lib/rdf/version.rb +1 -1
- data/lib/rdf/vocab.rb +171 -0
- data/lib/rdf/vocab/cc.rb +18 -0
- data/lib/rdf/vocab/dc.rb +63 -0
- data/lib/rdf/vocab/doap.rb +45 -0
- data/lib/rdf/vocab/exif.rb +168 -0
- data/lib/rdf/vocab/foaf.rb +69 -0
- data/lib/rdf/vocab/http.rb +26 -0
- data/lib/rdf/vocab/owl.rb +59 -0
- data/lib/rdf/{vocabulary → vocab}/rdf.rb +7 -1
- data/lib/rdf/vocab/rdfs.rb +17 -0
- data/lib/rdf/{vocabulary → vocab}/rss.rb +6 -1
- data/lib/rdf/vocab/sioc.rb +93 -0
- data/lib/rdf/vocab/skos.rb +36 -0
- data/lib/rdf/vocab/wot.rb +21 -0
- data/lib/rdf/vocab/xhtml.rb +9 -0
- data/lib/rdf/vocab/xsd.rb +58 -0
- data/lib/rdf/writer.rb +123 -16
- metadata +26 -27
- data/lib/rdf/graph.rb +0 -197
- data/lib/rdf/reader/ntriples.rb +0 -5
- data/lib/rdf/value.rb +0 -76
- data/lib/rdf/vocabulary.rb +0 -133
- data/lib/rdf/vocabulary/cc.rb +0 -9
- data/lib/rdf/vocabulary/dc.rb +0 -9
- data/lib/rdf/vocabulary/doap.rb +0 -9
- data/lib/rdf/vocabulary/exif.rb +0 -9
- data/lib/rdf/vocabulary/foaf.rb +0 -9
- data/lib/rdf/vocabulary/http.rb +0 -9
- data/lib/rdf/vocabulary/owl.rb +0 -9
- data/lib/rdf/vocabulary/rdfs.rb +0 -9
- data/lib/rdf/vocabulary/sioc.rb +0 -9
- data/lib/rdf/vocabulary/skos.rb +0 -9
- data/lib/rdf/vocabulary/wot.rb +0 -9
- data/lib/rdf/vocabulary/xhtml.rb +0 -9
- data/lib/rdf/vocabulary/xsd.rb +0 -9
- data/lib/rdf/writer/ntriples.rb +0 -5
data/lib/rdf/reader/ntriples.rb
DELETED
data/lib/rdf/value.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
module RDF
|
2
|
-
##
|
3
|
-
# An RDF value.
|
4
|
-
#
|
5
|
-
# @abstract
|
6
|
-
# @see Graph
|
7
|
-
# @see Literal
|
8
|
-
# @see Node
|
9
|
-
# @see Resource
|
10
|
-
# @see Statement
|
11
|
-
# @see URI
|
12
|
-
class Value
|
13
|
-
# Prevent the instantiation of this class.
|
14
|
-
private_class_method :new
|
15
|
-
|
16
|
-
##
|
17
|
-
# Returns `true` if this value is a graph.
|
18
|
-
#
|
19
|
-
# @return [Boolean]
|
20
|
-
def graph?
|
21
|
-
false
|
22
|
-
end
|
23
|
-
|
24
|
-
##
|
25
|
-
# Returns `true` if this value is a literal.
|
26
|
-
#
|
27
|
-
# @return [Boolean]
|
28
|
-
def literal?
|
29
|
-
false
|
30
|
-
end
|
31
|
-
|
32
|
-
##
|
33
|
-
# Returns `true` if this value is a blank node.
|
34
|
-
#
|
35
|
-
# @return [Boolean]
|
36
|
-
def node?
|
37
|
-
false
|
38
|
-
end
|
39
|
-
|
40
|
-
##
|
41
|
-
# Returns `true` if this value is a URI.
|
42
|
-
#
|
43
|
-
# @return [Boolean]
|
44
|
-
def uri?
|
45
|
-
false
|
46
|
-
end
|
47
|
-
|
48
|
-
alias_method :iri?, :uri?
|
49
|
-
|
50
|
-
##
|
51
|
-
# Compares this value to `other` for sorting purposes.
|
52
|
-
#
|
53
|
-
# @param [Object] other
|
54
|
-
# @return [Integer] -1, 0, 1
|
55
|
-
def <=>(other)
|
56
|
-
self.to_s <=> other.to_s
|
57
|
-
end
|
58
|
-
|
59
|
-
##
|
60
|
-
# Returns a developer-readable representation of this value.
|
61
|
-
#
|
62
|
-
# @return [String]
|
63
|
-
def inspect
|
64
|
-
sprintf("#<%s:%#0x(%s)>", self.class.name, object_id, to_s)
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def self.inherited(child) #:nodoc:
|
70
|
-
# Enable the instantiation of any subclasses.
|
71
|
-
child.send(:public_class_method, :new)
|
72
|
-
super
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
data/lib/rdf/vocabulary.rb
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
module RDF
|
2
|
-
##
|
3
|
-
# An RDF vocabulary.
|
4
|
-
#
|
5
|
-
# @example Using pre-defined RDF vocabularies
|
6
|
-
# include RDF
|
7
|
-
# DC.title #=> RDF::URI("http://purl.org/dc/terms/title")
|
8
|
-
# FOAF.knows #=> RDF::URI("http://xmlns.com/foaf/0.1/knows")
|
9
|
-
# RDFS.seeAlso #=> RDF::URI("http://www.w3.org/2000/01/rdf-schema#seeAlso")
|
10
|
-
# RSS.title #=> RDF::URI("http://purl.org/rss/1.0/title")
|
11
|
-
# OWL.sameAs #=> RDF::URI("http://www.w3.org/2002/07/owl#sameAs")
|
12
|
-
# XSD.dateTime #=> RDF::URI("http://www.w3.org/2001/XMLSchema#dateTime")
|
13
|
-
#
|
14
|
-
# @example Using ad-hoc RDF vocabularies
|
15
|
-
# foaf = RDF::Vocabulary.new("http://xmlns.com/foaf/0.1/")
|
16
|
-
# foaf.knows #=> RDF::URI("http://xmlns.com/foaf/0.1/knows")
|
17
|
-
# foaf[:name] #=> RDF::URI("http://xmlns.com/foaf/0.1/name")
|
18
|
-
# foaf['mbox'] #=> RDF::URI("http://xmlns.com/foaf/0.1/mbox")
|
19
|
-
#
|
20
|
-
# @see http://www.w3.org/TR/curie/
|
21
|
-
class Vocabulary
|
22
|
-
##
|
23
|
-
# @return [String]
|
24
|
-
def self.inspect
|
25
|
-
if self == Vocabulary
|
26
|
-
self.to_s
|
27
|
-
else
|
28
|
-
sprintf("%s(%s)", superclass.to_s, to_s)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
##
|
33
|
-
# @return [URI]
|
34
|
-
def self.to_uri
|
35
|
-
RDF::URI.parse(to_s)
|
36
|
-
end
|
37
|
-
|
38
|
-
##
|
39
|
-
# @return [String]
|
40
|
-
def self.to_s
|
41
|
-
@@uris.has_key?(self) ? @@uris[self].to_s : super
|
42
|
-
end
|
43
|
-
|
44
|
-
##
|
45
|
-
# @param [#to_s] property
|
46
|
-
# @return [URI]
|
47
|
-
def self.[](property)
|
48
|
-
RDF::URI.parse([to_s, property.to_s].join(''))
|
49
|
-
end
|
50
|
-
|
51
|
-
##
|
52
|
-
# @param [Symbol]
|
53
|
-
# @return [void]
|
54
|
-
def self.property(symbol) end # TODO
|
55
|
-
|
56
|
-
##
|
57
|
-
# @param [URI, String]
|
58
|
-
def initialize(uri)
|
59
|
-
case uri
|
60
|
-
when RDF::URI then @uri = uri.to_s
|
61
|
-
else @uri = RDF::URI.parse(uri.to_s) ? uri.to_s : nil
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
##
|
66
|
-
# @return [String]
|
67
|
-
def inspect
|
68
|
-
sprintf("#<%s:%#0x(%s)>", self.class.name, object_id, to_s)
|
69
|
-
end
|
70
|
-
|
71
|
-
##
|
72
|
-
# @return [URI]
|
73
|
-
def to_uri
|
74
|
-
RDF::URI.parse(to_s)
|
75
|
-
end
|
76
|
-
|
77
|
-
##
|
78
|
-
# @return [String]
|
79
|
-
def to_s() @uri.to_s end
|
80
|
-
|
81
|
-
##
|
82
|
-
# @param [#to_s] property
|
83
|
-
# @return [URI]
|
84
|
-
def [](property)
|
85
|
-
RDF::URI.parse([to_s, property.to_s].join(''))
|
86
|
-
end
|
87
|
-
|
88
|
-
protected
|
89
|
-
@@uris = {}
|
90
|
-
@@uri = nil
|
91
|
-
|
92
|
-
##
|
93
|
-
# @private
|
94
|
-
def self.create(uri) #:nodoc:
|
95
|
-
@@uri = uri
|
96
|
-
self
|
97
|
-
end
|
98
|
-
|
99
|
-
##
|
100
|
-
# @private
|
101
|
-
def self.inherited(subclass) #:nodoc:
|
102
|
-
unless @@uri.nil?
|
103
|
-
subclass.send(:private_class_method, :new)
|
104
|
-
@@uris[subclass] = @@uri
|
105
|
-
@@uri = nil
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def self.method_missing(property, *args, &block)
|
110
|
-
if args.empty? && @@uris.has_key?(self)
|
111
|
-
self[property]
|
112
|
-
else
|
113
|
-
super
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
def method_missing(property, *args, &block)
|
118
|
-
if args.empty?
|
119
|
-
self[property]
|
120
|
-
else
|
121
|
-
raise ArgumentError.new("wrong number of arguments (#{args.size} for 0)")
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
##
|
128
|
-
# @param [String] uri
|
129
|
-
# @return [Class]
|
130
|
-
def self.Vocabulary(uri)
|
131
|
-
Vocabulary.create(uri)
|
132
|
-
end
|
133
|
-
end
|
data/lib/rdf/vocabulary/cc.rb
DELETED
data/lib/rdf/vocabulary/dc.rb
DELETED
data/lib/rdf/vocabulary/doap.rb
DELETED
data/lib/rdf/vocabulary/exif.rb
DELETED
data/lib/rdf/vocabulary/foaf.rb
DELETED
data/lib/rdf/vocabulary/http.rb
DELETED
data/lib/rdf/vocabulary/owl.rb
DELETED
data/lib/rdf/vocabulary/rdfs.rb
DELETED
data/lib/rdf/vocabulary/sioc.rb
DELETED
data/lib/rdf/vocabulary/skos.rb
DELETED
data/lib/rdf/vocabulary/wot.rb
DELETED
data/lib/rdf/vocabulary/xhtml.rb
DELETED
data/lib/rdf/vocabulary/xsd.rb
DELETED