rdf 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/AUTHORS CHANGED
@@ -1 +1,2 @@
1
1
  * Arto Bendiken <arto.bendiken@gmail.com>
2
+ * Ben Lavender <blavender@gmail.com>
data/README CHANGED
@@ -134,10 +134,12 @@ Resources
134
134
  * <http://gemcutter.org/gems/rdf>
135
135
  * <http://rubyforge.org/projects/rdf/>
136
136
  * <http://raa.ruby-lang.org/project/rdf/>
137
+ * <http://www.ohloh.net/p/rdf>
137
138
 
138
- See also
139
+ See Also
139
140
  --------
140
141
 
142
+ * [DataMapper RDF.rb Adapter](http://dm-rdf.rubyforge.org/)
141
143
  * [RDFS.rb](http://rdfs.rubyforge.org/)
142
144
  * [RDFize](http://rdfize.rubyforge.org/)
143
145
  * [RDFbus](http://rdfbus.rubyforge.org/)
@@ -147,6 +149,7 @@ Author
147
149
  ------
148
150
 
149
151
  * [Arto Bendiken](mailto:arto.bendiken@gmail.com) - <http://ar.to/>
152
+ * [Ben Lavender](mailto:blavender@gmail.com) - <http://bhuga.net/>
150
153
 
151
154
  License
152
155
  -------
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
data/etc/doap.nt ADDED
@@ -0,0 +1,24 @@
1
+ <http://ar.to/#self> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
2
+ <http://ar.to/#self> <http://xmlns.com/foaf/0.1/made> <http://gemcutter.org/gems/rdf> .
3
+ <http://ar.to/#self> <http://xmlns.com/foaf/0.1/mbox> <mailto:arto.bendiken@gmail.com> .
4
+ <http://ar.to/#self> <http://xmlns.com/foaf/0.1/name> "Arto Bendiken" .
5
+ <http://bhuga.net/#ben> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
6
+ <http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/mbox> <mailto:blavender@gmail.com> .
7
+ <http://bhuga.net/#ben> <http://xmlns.com/foaf/0.1/name> "Ben Lavender" .
8
+ <http://gemcutter.org/gems/rdf> <http://purl.org/dc/terms/creator> <http://ar.to/#self> .
9
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#blog> <http://ar.to/> .
10
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#bug-database> <http://github.com/bendiken/rdf/issues> .
11
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#created> "2007-10-23" .
12
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#description> "RDF.rb is a pure-Ruby library for working with Resource Description Framework (RDF) data."@en .
13
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://ar.to/#self> .
14
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#developer> <http://bhuga.net/#ben> .
15
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#documenter> <http://ar.to/#self> .
16
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#download-page> <http://rubyforge.org/projects/rdf/> .
17
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#homepage> <http://rdf.rubyforge.org/> .
18
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#license> <http://creativecommons.org/licenses/publicdomain/> .
19
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#maintainer> <http://ar.to/#self> .
20
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#name> "RDF.rb" .
21
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#platform> "Ruby" .
22
+ <http://gemcutter.org/gems/rdf> <http://usefulinc.com/ns/doap#shortdesc> "A Ruby library for working with Resource Description Framework (RDF) data."@en .
23
+ <http://gemcutter.org/gems/rdf> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://usefulinc.com/ns/doap#Project> .
24
+ <http://gemcutter.org/gems/rdf> <http://xmlns.com/foaf/0.1/maker> <http://ar.to/#self> .
data/lib/rdf.rb CHANGED
@@ -2,7 +2,12 @@ require 'rdf/version'
2
2
 
3
3
  module RDF
4
4
  # RDF mixins
5
- autoload :Enumerable, 'rdf/enumerable'
5
+ autoload :Durable, 'rdf/mixin/durable'
6
+ autoload :Enumerable, 'rdf/mixin/enumerable'
7
+ autoload :Mutable, 'rdf/mixin/mutable'
8
+ autoload :Queryable, 'rdf/mixin/queryable'
9
+ autoload :Readable, 'rdf/mixin/readable'
10
+ autoload :Writable, 'rdf/mixin/writable'
6
11
 
7
12
  # RDF objects
8
13
  autoload :Graph, 'rdf/model/graph'
@@ -0,0 +1,29 @@
1
+ module RDF
2
+ ##
3
+ module Durable
4
+ ##
5
+ # Returns `true` if `self` is durable.
6
+ #
7
+ # @return [Boolean]
8
+ # @see #nondurable?
9
+ def durable?
10
+ true
11
+ end
12
+
13
+ alias_method :persistent?, :durable?
14
+
15
+ ##
16
+ # Returns `true` if `self` is nondurable.
17
+ #
18
+ # @return [Boolean]
19
+ # @see #durable?
20
+ def nondurable?
21
+ !durable?
22
+ end
23
+
24
+ alias_method :ephemeral?, :nondurable?
25
+ alias_method :nonpersistent?, :nondurable?
26
+ alias_method :transient?, :nondurable?
27
+ alias_method :volatile?, :nondurable?
28
+ end
29
+ end
File without changes
@@ -0,0 +1,193 @@
1
+ module RDF
2
+ ##
3
+ # Classes that include this module must implement the methods
4
+ # {#insert_statement}, {#delete_statement} and {#each_statement}.
5
+ #
6
+ # @see RDF::Graph
7
+ # @see RDF::Repository
8
+ module Mutable
9
+ include RDF::Readable
10
+ include RDF::Writable
11
+
12
+ ##
13
+ # Returns `true` if `self` is mutable.
14
+ #
15
+ # @return [Boolean]
16
+ # @see #immutable?
17
+ def mutable?
18
+ writable?
19
+ end
20
+
21
+ ##
22
+ # Returns `true` if `self` is immutable.
23
+ #
24
+ # @return [Boolean]
25
+ # @see #mutable?
26
+ def immutable?
27
+ !mutable?
28
+ end
29
+
30
+ ##
31
+ # Loads RDF statements from the given file into `self`.
32
+ #
33
+ # @param [String, #to_s] filename
34
+ # @param [Hash{Symbol => Object}] options
35
+ # @return [Integer] the number of inserted RDF statements
36
+ def load(filename, options = {})
37
+ raise TypeError.new("#{self} is immutable") if immutable?
38
+
39
+ count = 0
40
+ Reader.open(filename, options) do |reader|
41
+ reader.each_statement do |statement|
42
+ insert_statement(statement)
43
+ count += 1
44
+ end
45
+ end
46
+ count
47
+ end
48
+
49
+ alias_method :load!, :load
50
+
51
+ ##
52
+ # Inserts an RDF statement into `self`.
53
+ #
54
+ # @param [RDF::Statement, Array<RDF::Value>, #to_a] statement
55
+ # @return [Mutable]
56
+ def <<(statement)
57
+ raise TypeError.new("#{self} is immutable") if immutable?
58
+
59
+ insert_statement(create_statement(statement))
60
+ self
61
+ end
62
+
63
+ ##
64
+ # Inserts RDF statements into `self`.
65
+ #
66
+ # @param [Enumerable<RDF::Statement>] statements
67
+ # @raise [TypeError] if `self` is immutable
68
+ # @return [Mutable]
69
+ def insert(*statements)
70
+ raise TypeError.new("#{self} is immutable") if immutable?
71
+
72
+ statements.each do |statement|
73
+ if (statement = create_statement(statement)).valid?
74
+ insert_statement(statement)
75
+ else
76
+ raise ArgumentError.new # FIXME
77
+ end
78
+ end
79
+ self
80
+ end
81
+
82
+ alias_method :insert!, :insert
83
+
84
+ ##
85
+ # Deletes RDF statements from `self`.
86
+ #
87
+ # @param [Enumerable<Statement>] statements
88
+ # @raise [TypeError] if `self` is immutable
89
+ # @return [Mutable]
90
+ def delete(*statements)
91
+ raise TypeError.new("#{self} is immutable") if immutable?
92
+
93
+ statements.each do |statement|
94
+ if (statement = create_statement(statement)).valid?
95
+ delete_statement(statement)
96
+ else
97
+ query(statement) do |statement|
98
+ delete_statement(statement)
99
+ end
100
+ end
101
+ end
102
+ self
103
+ end
104
+
105
+ alias_method :delete!, :delete
106
+
107
+ ##
108
+ # Updates RDF statements in `self`.
109
+ #
110
+ # `#update([subject, predicate, object])` is equivalent to
111
+ # `#delete([subject, predicate, nil])` followed by
112
+ # `#insert([subject, predicate, object])` unless `object` is `nil`.
113
+ #
114
+ # @param [Enumerable<RDF::Statement>] statements
115
+ # @raise [TypeError] if `self` is immutable
116
+ # @return [Mutable]
117
+ def update(*statements)
118
+ raise TypeError.new("#{self} is immutable") if immutable?
119
+
120
+ statements.each do |statement|
121
+ if (statement = create_statement(statement))
122
+ delete([statement.subject, statement.predicate, nil])
123
+ insert(statement) if statement.has_object?
124
+ end
125
+ end
126
+ end
127
+
128
+ alias_method :update!, :update
129
+
130
+ ##
131
+ # Deletes all RDF statements from `self`.
132
+ #
133
+ # @return [Mutable]
134
+ def clear
135
+ raise TypeError.new("#{self} is immutable") if immutable?
136
+
137
+ if respond_to?(:clear_statements)
138
+ clear_statements
139
+ else
140
+ each_statement do |statement|
141
+ delete_statement(statement)
142
+ end
143
+ end
144
+ self
145
+ end
146
+
147
+ alias_method :clear!, :clear
148
+
149
+ ##
150
+ # Transforms various input into an `RDF::Statement` instance.
151
+ #
152
+ # @param [RDF::Statement, Hash, Array, #to_a] statement
153
+ # @return [RDF::Statement]
154
+ def create_statement(statement)
155
+ case statement
156
+ when Statement then statement
157
+ when Hash then Statement.new(statement)
158
+ when Array then Statement.new(*statement)
159
+ else raise ArgumentError.new # FIXME
160
+ end
161
+ end
162
+
163
+ ##
164
+ # Inserts an RDF statement into the underlying storage.
165
+ #
166
+ # Subclasses of {RDF::Repository} must implement this method (except in
167
+ # case they are immutable).
168
+ #
169
+ # @param [RDF::Statement] statement
170
+ # @return [void]
171
+ # @abstract
172
+ def insert_statement(statement)
173
+ raise NotImplementedError
174
+ end
175
+
176
+ ##
177
+ # Deletes an RDF statement from the underlying storage.
178
+ #
179
+ # Subclasses of {RDF::Repository} must implement this method (except in
180
+ # case they are immutable).
181
+ #
182
+ # @param [RDF::Statement] statement
183
+ # @return [void]
184
+ # @abstract
185
+ def delete_statement(statement)
186
+ raise NotImplementedError
187
+ end
188
+
189
+ protected :create_statement
190
+ protected :insert_statement
191
+ protected :delete_statement
192
+ end
193
+ end
@@ -0,0 +1,39 @@
1
+ module RDF
2
+ ##
3
+ # An RDF query mixin.
4
+ #
5
+ # Classes that include this module must implement an `#each` method that
6
+ # yields {RDF::Statement RDF statements}.
7
+ #
8
+ # @see RDF::Graph
9
+ # @see RDF::Repository
10
+ module Queryable
11
+ include ::Enumerable
12
+
13
+ ##
14
+ # Queries `self` for RDF statements matching the given pattern.
15
+ #
16
+ # @param [Query, Statement, Array(Value)] pattern
17
+ # @yield [statement]
18
+ # @yieldparam [Statement]
19
+ # @return [Array<Statement>, nil]
20
+ def query(pattern, &block)
21
+ raise TypeError.new("#{self} is not readable") if respond_to?(:readable) && !readable?
22
+
23
+ case pattern
24
+ when Query
25
+ pattern.execute(self, &block)
26
+ when Array
27
+ query(Statement.new(*pattern), &block)
28
+ when Statement
29
+ if block_given?
30
+ find_all { |statement| pattern === statement }.each(&block)
31
+ else
32
+ find_all { |statement| pattern === statement }
33
+ end
34
+ else
35
+ raise ArgumentError.new("expected RDF::Query or RDF::Pattern, got #{pattern.inspect}")
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,13 @@
1
+ module RDF
2
+ ##
3
+ module Readable
4
+ ##
5
+ # Returns `true` if `self` is readable.
6
+ #
7
+ # @return [Boolean]
8
+ # @see RDF::Writable#writable?
9
+ def readable?
10
+ true
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module RDF
2
+ ##
3
+ module Writable
4
+ ##
5
+ # Returns `true` if `self` is writable.
6
+ #
7
+ # @return [Boolean]
8
+ # @see RDF::Readable#readable?
9
+ def writable?
10
+ true
11
+ end
12
+ end
13
+ end
@@ -3,6 +3,7 @@ module RDF
3
3
  # An RDF graph.
4
4
  class Graph < Resource
5
5
  include RDF::Enumerable
6
+ include RDF::Queryable
6
7
 
7
8
  # @return [URI]
8
9
  attr_accessor :uri
@@ -16,6 +17,7 @@ module RDF
16
17
  # @yieldparam [Graph]
17
18
  def initialize(uri = nil, options = {}, &block)
18
19
  @uri, @options = uri, options
20
+ @data = []
19
21
 
20
22
  if block_given?
21
23
  case block.arity
@@ -55,7 +57,15 @@ module RDF
55
57
 
56
58
  ##
57
59
  # @return [Resource]
58
- def context() uri end
60
+ def context
61
+ uri
62
+ end
63
+
64
+ ##
65
+ # @return [Array<Resource>]
66
+ def contexts
67
+ named? ? [uri] : []
68
+ end
59
69
 
60
70
  ##
61
71
  # @param [Statement, Array(Value)]
@@ -42,15 +42,24 @@ module RDF
42
42
  #
43
43
  class Repository
44
44
  include RDF::Enumerable
45
+ include RDF::Durable
46
+ include RDF::Mutable
47
+ include RDF::Queryable
45
48
 
49
+ ##
50
+ # Returns the {URI} of this repository.
51
+ #
46
52
  # @return [URI]
47
53
  attr_reader :uri
48
54
 
55
+ ##
56
+ # Returns the title of this repository.
57
+ #
49
58
  # @return [String]
50
59
  attr_reader :title
51
60
 
52
61
  ##
53
- # Loads an N-Triples file as a transient in-memory repository.
62
+ # Loads an RDF file as a transient in-memory repository.
54
63
  #
55
64
  # @param [String] filename
56
65
  # @yield [repository]
@@ -70,12 +79,23 @@ module RDF
70
79
  end
71
80
 
72
81
  ##
82
+ # Initializes this repository instance.
83
+ #
84
+ # @param [Hash{Symbol => Object}] options
85
+ # @option options [URI, #to_s] :uri (nil)
86
+ # @option options [String, #to_s] :title (nil)
73
87
  # @yield [repository]
74
- # @yieldparam [Repository]
88
+ # @yieldparam [Repository] repository
75
89
  def initialize(options = {}, &block)
76
- @uri = options.delete(:uri)
77
- @title = options.delete(:title)
78
- @data, @options = [], options
90
+ @uri = options.delete(:uri)
91
+ @title = options.delete(:title)
92
+ @options = options
93
+
94
+ # Provide a default in-memory implementation:
95
+ if self.class.equal?(RDF::Repository)
96
+ @data = []
97
+ send(:extend, Implementation)
98
+ end
79
99
 
80
100
  if block_given?
81
101
  case block.arity
@@ -86,251 +106,96 @@ module RDF
86
106
  end
87
107
 
88
108
  ##
89
- # Returns `true` if the repository is transient.
90
- #
91
- # @return [Boolean]
92
- # @see #persistent?
93
- def transient?
94
- !persistent?
95
- end
96
-
97
- ##
98
- # Returns `true` if the repository is persistent.
99
- #
100
- # @return [Boolean]
101
- # @see #transient?
102
- # @abstract
103
- def persistent?
104
- false # NOTE: override this in any persistent subclasses
105
- end
106
-
107
- ##
108
- # Returns `true` if the repository is readable.
109
- #
110
- # @return [Boolean]
111
- def readable?
112
- true
113
- end
114
-
115
- ##
116
- # Returns `true` if the repository is mutable.
117
- #
118
- # @return [Boolean]
119
- # @see #immutable?
120
- # @see #immutable!
121
- def mutable?
122
- !immutable?
123
- end
124
-
125
- alias_method :writable?, :mutable?
126
-
127
- ##
128
- # Returns `true` if the repository is immutable.
129
- #
130
- # @return [Boolean]
131
- # @see #mutable?
132
- # @see #immutable!
133
- def immutable?
134
- @options[:mutable] == false
135
- end
136
-
137
- ##
138
- # Makes the repository contents immutable.
109
+ # Outputs a developer-friendly representation of this repository to
110
+ # `stderr`.
139
111
  #
140
112
  # @return [void]
141
- # @see #mutable?
142
- # @see #immutable?
143
- def immutable!
144
- @options[:mutable] = true
145
- end
146
-
147
- ##
148
- # Returns `true` if the repository contains no RDF statements.
149
- #
150
- # @return [Boolean]
151
- def empty?
152
- @data.empty?
153
- end
154
-
155
- ##
156
- # Returns the number of RDF statements in the repository.
157
- #
158
- # @return [Integer]
159
- def size
160
- @data.size
161
- end
162
-
163
- alias_method :count, :size
164
-
165
- ##
166
- # Returns `true` if this repository contains the given RDF `statement`.
167
- #
168
- # @param [Statement] statement
169
- # @return [Boolean]
170
- def has_statement?(statement)
171
- @data.include?(statement)
172
- end
173
-
174
- alias_method :include?, :has_statement?
175
-
176
- ##
177
- # Enumerates each RDF statement in the repository.
178
- #
179
- # @yield [statement]
180
- # @yieldparam [Statement]
181
- # @return [Enumerator]
182
- def each(&block)
183
- @data.each(&block)
113
+ def inspect!
114
+ each_statement { |statement| statement.inspect! }
115
+ nil
184
116
  end
185
117
 
186
118
  ##
187
- # Queries the repository for RDF statements matching the given pattern.
188
- #
189
- # @param [Query, Statement, Array(Value)] pattern
190
- # @yield [statement]
191
- # @yieldparam [Statement]
192
- # @return [Array<Statement>, nil]
193
- def query(pattern, &block)
194
- raise TypeError.new("repository is not readable") unless readable?
195
- case pattern
196
- when Query
197
- pattern.execute(self, &block)
198
- when Array
199
- query(Statement.new(*pattern), &block)
200
- when Statement
201
- if block_given?
202
- # TODO: yield any found statements
203
- nil
204
- else
205
- find_all { |statement| pattern === statement }
206
- end
119
+ # @see RDF::Repository
120
+ module Implementation
121
+ ##
122
+ # Returns `false` to indicate that this repository is nondurable.
123
+ #
124
+ # @return [Boolean]
125
+ # @see RDF::Durable#durable?
126
+ def durable?
127
+ false
207
128
  end
208
- end
209
129
 
210
- ##
211
- # Loads RDF statements from the given N-Triples file into the repository.
212
- #
213
- # @param [String] filename
214
- # @return [Integer] the number of inserted RDF statements
215
- def load(filename, options = {})
216
- raise TypeError.new("repository is immutable") if immutable?
217
- count = 0
218
- Reader.open(filename, options) do |reader|
219
- reader.each_statement do |statement|
220
- insert_statement(statement)
221
- count += 1
222
- end
130
+ ##
131
+ # Enumerates each RDF statement in this repository.
132
+ #
133
+ # @yield [statement]
134
+ # @yieldparam [Statement]
135
+ # @return [Enumerator]
136
+ # @see RDF::Enumerable#each_statement
137
+ def each(&block)
138
+ @data.each(&block)
223
139
  end
224
- count
225
- end
226
140
 
227
- ##
228
- # Inserts an RDF statement into the repository.
229
- #
230
- # @param [Statement, Array(Value), #to_a] statement
231
- # @return [Repository]
232
- def <<(statement)
233
- raise TypeError.new("repository is immutable") if immutable?
234
- case statement
235
- when Statement then insert_statement(statement)
236
- else insert_statement(Statement.new(*statement.to_a))
141
+ ##
142
+ # Returns `true` if this repository contains no RDF statements.
143
+ #
144
+ # @return [Boolean]
145
+ # @see RDF::Enumerable#empty?
146
+ def empty?
147
+ @data.empty?
237
148
  end
238
- self
239
- end
240
149
 
241
- ##
242
- # Updates RDF statements in the repository.
243
- #
244
- # @param [Array<Statement>] statements
245
- # @raise [TypeError] if the repository is immutable
246
- # @return [Repository]
247
- def update(*statements)
248
- raise TypeError.new("repository is immutable") if immutable?
249
- statements.each do |statement|
250
- if (statement = create_statement(statement))
251
- delete([statement.subject, statement.predicate, nil])
252
- insert(statement) if statement.has_object?
253
- end
254
- end
255
- end
256
-
257
- ##
258
- # Inserts RDF statements into the repository.
259
- #
260
- # @param [Array<Statement>] statements
261
- # @raise [TypeError] if the repository is immutable
262
- # @return [Repository]
263
- def insert(*statements)
264
- raise TypeError.new("repository is immutable") if immutable?
265
- statements.each do |statement|
266
- if (statement = create_statement(statement)).valid?
267
- insert_statement(statement)
268
- else
269
- raise ArgumentError.new # FIXME
270
- end
150
+ ##
151
+ # Returns the number of RDF statements in this repository.
152
+ #
153
+ # @return [Integer]
154
+ # @see RDF::Enumerable#count
155
+ def count
156
+ @data.size
271
157
  end
272
- self
273
- end
274
158
 
275
- ##
276
- # Deletes RDF statements from the repository.
277
- #
278
- # @param [Array<Statement>] statements
279
- # @raise [TypeError] if the repository is immutable
280
- # @return [Repository]
281
- def delete(*statements)
282
- raise TypeError.new("repository is immutable") if immutable?
283
- statements.each do |statement|
284
- if (statement = create_statement(statement)).valid?
285
- delete_statement(statement)
286
- else
287
- query(statement).each do |statement|
288
- delete_statement(statement)
289
- end
290
- end
159
+ ##
160
+ # Returns `true` if this repository contains the given RDF statement.
161
+ #
162
+ # @param [Statement] statement
163
+ # @return [Boolean]
164
+ # @see RDF::Enumerable#has_statement?
165
+ def has_statement?(statement)
166
+ @data.include?(statement)
291
167
  end
292
- self
293
- end
294
-
295
- ##
296
- # Deletes all RDF statements from this repository.
297
- #
298
- # @return [Repository]
299
- def clear
300
- @data.clear
301
- self
302
- end
303
-
304
- alias_method :clear!, :clear
305
-
306
- ##
307
- # Outputs a developer-friendly representation of this repository to
308
- # `stderr`.
309
- #
310
- # @return [void]
311
- def inspect!
312
- each_statement { |statement| statement.inspect! }
313
- nil
314
- end
315
-
316
- protected
317
168
 
169
+ ##
170
+ # Inserts an RDF statement into the underlying storage.
171
+ #
172
+ # @param [RDF::Statement] statement
173
+ # @return [void]
318
174
  def insert_statement(statement)
319
175
  @data.push(statement) unless @data.include?(statement)
320
176
  end
321
177
 
178
+ ##
179
+ # Deletes an RDF statement from the underlying storage.
180
+ #
181
+ # @param [RDF::Statement] statement
182
+ # @return [void]
322
183
  def delete_statement(statement)
323
184
  @data.delete(statement)
324
185
  end
325
186
 
326
- def create_statement(statement)
327
- case statement
328
- when Statement then statement
329
- when Hash then Statement.new(statement)
330
- when Array then Statement.new(*statement)
331
- else raise ArgumentError.new # FIXME
332
- end
187
+ ##
188
+ # Deletes all RDF statements from this repository.
189
+ #
190
+ # @return [Repository]
191
+ # @see RDF::Mutable#clear
192
+ def clear_statements
193
+ @data.clear
333
194
  end
334
195
 
335
- end
336
- end
196
+ protected :insert_statement
197
+ protected :delete_statement
198
+ protected :clear_statements
199
+ end # module Implementation
200
+ end # class Repository
201
+ end # module RDF