rdf 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/AUTHORS +1 -1
  2. data/VERSION +1 -1
  3. data/lib/rdf.rb +25 -22
  4. data/lib/rdf/enumerable.rb +554 -0
  5. data/lib/rdf/format.rb +239 -41
  6. data/lib/rdf/model/graph.rb +82 -0
  7. data/lib/rdf/{literal.rb → model/literal.rb} +47 -4
  8. data/lib/rdf/{node.rb → model/node.rb} +0 -0
  9. data/lib/rdf/{resource.rb → model/resource.rb} +0 -0
  10. data/lib/rdf/{statement.rb → model/statement.rb} +12 -0
  11. data/lib/rdf/{uri.rb → model/uri.rb} +20 -7
  12. data/lib/rdf/model/value.rb +135 -0
  13. data/lib/rdf/ntriples.rb +35 -2
  14. data/lib/rdf/ntriples/format.rb +4 -4
  15. data/lib/rdf/ntriples/reader.rb +2 -2
  16. data/lib/rdf/ntriples/writer.rb +26 -19
  17. data/lib/rdf/query.rb +4 -4
  18. data/lib/rdf/query/pattern.rb +3 -3
  19. data/lib/rdf/query/solution.rb +2 -2
  20. data/lib/rdf/query/variable.rb +3 -3
  21. data/lib/rdf/reader.rb +85 -16
  22. data/lib/rdf/repository.rb +104 -12
  23. data/lib/rdf/version.rb +1 -1
  24. data/lib/rdf/vocab.rb +171 -0
  25. data/lib/rdf/vocab/cc.rb +18 -0
  26. data/lib/rdf/vocab/dc.rb +63 -0
  27. data/lib/rdf/vocab/doap.rb +45 -0
  28. data/lib/rdf/vocab/exif.rb +168 -0
  29. data/lib/rdf/vocab/foaf.rb +69 -0
  30. data/lib/rdf/vocab/http.rb +26 -0
  31. data/lib/rdf/vocab/owl.rb +59 -0
  32. data/lib/rdf/{vocabulary → vocab}/rdf.rb +7 -1
  33. data/lib/rdf/vocab/rdfs.rb +17 -0
  34. data/lib/rdf/{vocabulary → vocab}/rss.rb +6 -1
  35. data/lib/rdf/vocab/sioc.rb +93 -0
  36. data/lib/rdf/vocab/skos.rb +36 -0
  37. data/lib/rdf/vocab/wot.rb +21 -0
  38. data/lib/rdf/vocab/xhtml.rb +9 -0
  39. data/lib/rdf/vocab/xsd.rb +58 -0
  40. data/lib/rdf/writer.rb +123 -16
  41. metadata +26 -27
  42. data/lib/rdf/graph.rb +0 -197
  43. data/lib/rdf/reader/ntriples.rb +0 -5
  44. data/lib/rdf/value.rb +0 -76
  45. data/lib/rdf/vocabulary.rb +0 -133
  46. data/lib/rdf/vocabulary/cc.rb +0 -9
  47. data/lib/rdf/vocabulary/dc.rb +0 -9
  48. data/lib/rdf/vocabulary/doap.rb +0 -9
  49. data/lib/rdf/vocabulary/exif.rb +0 -9
  50. data/lib/rdf/vocabulary/foaf.rb +0 -9
  51. data/lib/rdf/vocabulary/http.rb +0 -9
  52. data/lib/rdf/vocabulary/owl.rb +0 -9
  53. data/lib/rdf/vocabulary/rdfs.rb +0 -9
  54. data/lib/rdf/vocabulary/sioc.rb +0 -9
  55. data/lib/rdf/vocabulary/skos.rb +0 -9
  56. data/lib/rdf/vocabulary/wot.rb +0 -9
  57. data/lib/rdf/vocabulary/xhtml.rb +0 -9
  58. data/lib/rdf/vocabulary/xsd.rb +0 -9
  59. data/lib/rdf/writer/ntriples.rb +0 -5
@@ -1,5 +0,0 @@
1
- module RDF
2
- class Reader
3
- NTriples = RDF::NTriples::Reader # @deprecated
4
- end
5
- end
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
@@ -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
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # Creative Commons (CC) vocabulary.
4
- #
5
- # @see http://creativecommons.org/ns
6
- class CC < Vocabulary("http://creativecommons.org/ns#")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # Dublin Core (DC) vocabulary.
4
- #
5
- # @see http://dublincore.org/schemas/rdfs/
6
- class DC < Vocabulary("http://purl.org/dc/terms/")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # Description of a Project (DOAP) vocabulary.
4
- #
5
- # @see http://trac.usefulinc.com/doap
6
- class DOAP < Vocabulary("http://usefulinc.com/ns/doap#")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # Exchangeable Image File Format (EXIF) vocabulary.
4
- #
5
- # @see http://www.w3.org/2003/12/exif/
6
- class EXIF < Vocabulary("http://www.w3.org/2003/12/exif/ns#")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # Friend of a Friend (FOAF) vocabulary.
4
- #
5
- # @see http://xmlns.com/foaf/spec/
6
- class FOAF < Vocabulary("http://xmlns.com/foaf/0.1/")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # Hypertext Transfer Protocol (HTTP) vocabulary.
4
- #
5
- # @see http://www.w3.org/2006/http
6
- class HTTP < Vocabulary("http://www.w3.org/2006/http#")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # Web Ontology Language (OWL) vocabulary.
4
- #
5
- # @see http://www.w3.org/TR/owl-overview/
6
- class OWL < Vocabulary("http://www.w3.org/2002/07/owl#")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # RDF Schema (RDFS) vocabulary.
4
- #
5
- # @see http://www.w3.org/TR/rdf-schema/
6
- class RDFS < Vocabulary("http://www.w3.org/2000/01/rdf-schema#")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # Semantically-Interlinked Online Communities (SIOC) vocabulary.
4
- #
5
- # @see http://rdfs.org/sioc/spec/
6
- class SIOC < Vocabulary("http://rdfs.org/sioc/ns#")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # Simple Knowledge Organization System (SKOS) vocabulary.
4
- #
5
- # @see http://www.w3.org/TR/skos-reference/skos.html
6
- class SKOS < Vocabulary("http://www.w3.org/2004/02/skos/core#")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # Web of Trust (WOT) vocabulary.
4
- #
5
- # @see http://xmlns.com/wot/0.1/
6
- class WOT < Vocabulary("http://xmlns.com/wot/0.1/")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # Extensible HyperText Markup Language (XHTML) vocabulary.
4
- #
5
- # @see http://www.w3.org/1999/xhtml/vocab/
6
- class XHTML < Vocabulary("http://www.w3.org/1999/xhtml/vocab#")
7
- # TODO
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module RDF
2
- ##
3
- # XML Schema (XSD) vocabulary.
4
- #
5
- # @see http://www.w3.org/XML/Schema
6
- class XSD < Vocabulary("http://www.w3.org/2001/XMLSchema#")
7
- # TODO
8
- end
9
- end
@@ -1,5 +0,0 @@
1
- module RDF
2
- class Writer
3
- NTriples = RDF::NTriples::Writer # @deprecated
4
- end
5
- end