rdf-sesame 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -10,12 +10,13 @@ This is a Sesame 2.0 adapter for [RDF.rb](http://rdf.rubyforge.org/).
10
10
  Documentation
11
11
  -------------
12
12
 
13
- * <http://rdf.rubyforge.org/>
13
+ * [`RDF::Sesame`](http://rdf.rubyforge.org/RDF/Sesame.html)
14
14
 
15
15
  Dependencies
16
16
  ------------
17
17
 
18
18
  * [RDF.rb](http://rdf.rubyforge.org/) (>= 0.0.6)
19
+ * [JSON](http://flori.github.com/json/) (>= 1.2.0)
19
20
 
20
21
  Installation
21
22
  ------------
@@ -45,5 +46,5 @@ Author
45
46
  License
46
47
  -------
47
48
 
48
- RDF::Sesame is free and unencumbered public domain software. For more
49
+ `RDF::Sesame` is free and unencumbered public domain software. For more
49
50
  information, see <http://unlicense.org/> or the accompanying UNLICENSE file.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
@@ -1,12 +1,45 @@
1
- module RDF module Sesame
1
+ require 'net/http'
2
+
3
+ module RDF::Sesame
2
4
  ##
3
- # A connection to a Sesame 2.0 HTTP server.
5
+ # A connection to a Sesame 2.0-compatible HTTP server.
6
+ #
7
+ # Instances of this class represent HTTP connections to a Sesame server,
8
+ # abstracting away the protocol and transport-level details of how the
9
+ # connection is actually established and how requests and responses are
10
+ # implemented and performed.
11
+ #
12
+ # Currently, connections are internally implemented using
13
+ # [`Net::HTTP`](http://ruby-doc.org/core/classes/Net/HTTP.html) from
14
+ # Ruby's standard library, and connections are always transient, i.e. they
15
+ # do not persist from one request to the next and must always be reopened
16
+ # when used. A future improvement would be to support persistent
17
+ # `Keep-Alive` connections.
18
+ #
19
+ # Connections are at any one time in one of the two states of {#close
20
+ # closed} or {#open open} (see {#open?}). You do not generally need to
21
+ # call {#close} explicitly.
4
22
  #
5
- # @example Connecting to a Sesame server
23
+ # @example Opening a connection to a Sesame server (1)
6
24
  # url = RDF::URI.new("http://localhost:8080/openrdf-sesame")
7
25
  # conn = RDF::Sesame::Connection.open(url)
26
+ # ...
27
+ # conn.close
8
28
  #
9
- # @see http://www.openrdf.org/doc/sesame2/system/ch08.html
29
+ # @example Opening a connection to a Sesame server (2)
30
+ # RDF::Sesame::Connection.open(url) do |conn|
31
+ # ...
32
+ # end
33
+ #
34
+ # @example Performing an HTTP GET on a Sesame server
35
+ # RDF::Sesame::Connection.open(url) do |conn|
36
+ # conn.get("/openrdf-sesame/protocol") do |response|
37
+ # version = response.body.to_i
38
+ # end
39
+ # end
40
+ #
41
+ # @see RDF::Sesame
42
+ # @see http://ruby-doc.org/core/classes/Net/HTTP.html
10
43
  class Connection
11
44
  # @return [RDF::URI]
12
45
  attr_reader :url
@@ -14,6 +47,9 @@ module RDF module Sesame
14
47
  # @return [Hash{Symbol => Object}]
15
48
  attr_reader :options
16
49
 
50
+ # @return [Hash{String => String}]
51
+ attr_reader :headers
52
+
17
53
  # @return [Boolean]
18
54
  attr_reader :connected
19
55
  alias_method :connected?, :connected
@@ -22,14 +58,14 @@ module RDF module Sesame
22
58
  ##
23
59
  # Opens a connection to a Sesame server.
24
60
  #
25
- # @param [RDF::URI] url
61
+ # @param [RDF::URI, #to_s] url
26
62
  # @param [Hash{Symbol => Object}] options
27
63
  # @yield [connection]
28
64
  # @yieldparam [Connection]
29
65
  # @return [Connection]
30
66
  def self.open(url, options = {}, &block)
31
67
  self.new(url, options) do |conn|
32
- if conn.open && block_given?
68
+ if conn.open(options) && block_given?
33
69
  case block.arity
34
70
  when 1 then block.call(conn)
35
71
  else conn.instance_eval(&block)
@@ -41,12 +77,25 @@ module RDF module Sesame
41
77
  end
42
78
 
43
79
  ##
44
- # @param [RDF::URI] url
80
+ # Initializes this connection.
81
+ #
82
+ # @param [RDF::URI, #to_s] url
45
83
  # @param [Hash{Symbol => Object}] options
46
84
  # @yield [connection]
47
85
  # @yieldparam [Connection]
48
86
  def initialize(url, options = {}, &block)
49
- @url, @options = url, options
87
+ require 'addressable/uri' unless defined?(Addressable)
88
+ @url = case url
89
+ when Addressable::URI then url
90
+ else Addressable::URI.parse(url.to_s)
91
+ end
92
+
93
+ # Preserve only those URI components that we actually require for
94
+ # establishing a connection to the HTTP server in question:
95
+ @url = RDF::URI.new(Addressable::URI.new(to_hash))
96
+
97
+ @headers = options.delete(:headers) || {}
98
+ @options = options
50
99
  @connected = false
51
100
 
52
101
  if block_given?
@@ -58,14 +107,163 @@ module RDF module Sesame
58
107
  end
59
108
 
60
109
  ##
61
- # Opens the connection to the Sesame server.
110
+ # Returns `true` unless this is an HTTPS connection.
62
111
  #
63
112
  # @return [Boolean]
64
- def open
65
- if connected?
66
- true
113
+ def insecure?
114
+ !secure?
115
+ end
116
+
117
+ ##
118
+ # Returns `true` if this is an HTTPS connection.
119
+ #
120
+ # @return [Boolean]
121
+ def secure?
122
+ scheme == :https
123
+ end
124
+
125
+ ##
126
+ # Returns `:http` or `:https` to indicate whether this is an HTTP or
127
+ # HTTPS connection, respectively.
128
+ #
129
+ # @return [Symbol]
130
+ def scheme
131
+ url.scheme.to_s.to_sym
132
+ end
133
+
134
+ ##
135
+ # Returns `true` if there is user name and password information for this
136
+ # connection.
137
+ #
138
+ # @return [Boolean]
139
+ def userinfo?
140
+ !url.userinfo.nil?
141
+ end
142
+
143
+ ##
144
+ # Returns any user name and password information for this connection.
145
+ #
146
+ # @return [String] "username:password"
147
+ def userinfo
148
+ url.userinfo
149
+ end
150
+
151
+ ##
152
+ # Returns `true` if there is user name information for this connection.
153
+ #
154
+ # @return [Boolean]
155
+ def user?
156
+ !url.user.nil?
157
+ end
158
+
159
+ ##
160
+ # Returns any user name information for this connection.
161
+ #
162
+ # @return [String]
163
+ def user
164
+ url.user
165
+ end
166
+
167
+ ##
168
+ # Returns `true` if there is password information for this connection.
169
+ #
170
+ # @return [Boolean]
171
+ def password?
172
+ !url.password.nil?
173
+ end
174
+
175
+ ##
176
+ # Returns any password information for this connection.
177
+ #
178
+ # @return [String]
179
+ def password
180
+ url.password
181
+ end
182
+
183
+ ##
184
+ # Returns the host name for this connection.
185
+ #
186
+ # @return [String]
187
+ def host
188
+ url.host.to_s
189
+ end
190
+
191
+ alias_method :hostname, :host
192
+
193
+ ##
194
+ # Returns `true` if the port number for this connection differs from the
195
+ # standard HTTP or HTTPS port number (80 and 443, respectively).
196
+ #
197
+ # @return [Boolean]
198
+ def port?
199
+ !url.port.nil? && url.port != (insecure? ? 80 : 443)
200
+ end
201
+
202
+ ##
203
+ # Returns the port number for this connection.
204
+ #
205
+ # @return [Integer]
206
+ def port
207
+ url.port
208
+ end
209
+
210
+ ##
211
+ # Returns a `Hash` representation of this connection.
212
+ #
213
+ # @return [Hash{Symbol => Object}]
214
+ def to_hash
215
+ {
216
+ :scheme => url.scheme,
217
+ :userinfo => url.userinfo,
218
+ :host => url.host,
219
+ :port => url.port,
220
+ }
221
+ end
222
+
223
+ ##
224
+ # Returns the URI representation of this connection.
225
+ #
226
+ # @return [RDF::URI]
227
+ def to_uri
228
+ url
229
+ end
230
+
231
+ ##
232
+ # Returns a string representation of this connection.
233
+ #
234
+ # @return [String]
235
+ def to_s
236
+ url.to_s
237
+ end
238
+
239
+ ##
240
+ # Returns a developer-friendly representation of this connection.
241
+ #
242
+ # @return [String]
243
+ def inspect
244
+ sprintf("#<%s:%#0x(%s)>", self.class.name, object_id, to_s)
245
+ end
246
+
247
+ ##
248
+ # Establishes the connection to the Sesame server.
249
+ #
250
+ # @param [Hash{Symbol => Object}] options
251
+ # @yield [connection]
252
+ # @yieldparam [Connection] connection
253
+ # @raise [TimeoutError] if the connection could not be opened
254
+ # @return [Connection]
255
+ def open(options = {}, &block)
256
+ unless connected?
257
+ # TODO: support persistent connections
258
+ @connected = true
259
+ end
260
+
261
+ if block_given?
262
+ result = block.call(self)
263
+ close
264
+ result
67
265
  else
68
- false # TODO
266
+ self
69
267
  end
70
268
  end
71
269
 
@@ -74,14 +272,71 @@ module RDF module Sesame
74
272
  ##
75
273
  # Closes the connection to the Sesame server.
76
274
  #
275
+ # You do not generally need to call {#close} explicitly.
276
+ #
77
277
  # @return [void]
78
278
  def close
79
279
  if connected?
80
- # TODO
280
+ # TODO: support persistent connections
81
281
  @connected = false
82
282
  end
83
283
  end
84
284
 
85
285
  alias_method :close!, :close
286
+
287
+ ##
288
+ # Performs an HTTP GET request for the given Sesame `path`.
289
+ #
290
+ # @param [String, #to_s] path
291
+ # @param [Hash{String => String}] headers
292
+ # @yield [response]
293
+ # @yieldparam [Net::HTTPResponse] response
294
+ # @return [Net::HTTPResponse]
295
+ def get(path, headers = {}, &block)
296
+ Net::HTTP.start(host, port) do |http|
297
+ response = http.get(path.to_s, @headers.merge(headers))
298
+ if block_given?
299
+ block.call(response)
300
+ else
301
+ response
302
+ end
303
+ end
304
+ end
305
+
306
+ ##
307
+ # Performs an HTTP POST request for the given Sesame `path`.
308
+ #
309
+ # @param [String, #to_s] path
310
+ # @param [Hash{String => String}] headers
311
+ # @yield [response]
312
+ # @yieldparam [Net::HTTPResponse] response
313
+ # @return [Net::HTTPResponse]
314
+ def post(path, headers = {}, &block)
315
+ # TODO
316
+ end
317
+
318
+ ##
319
+ # Performs an HTTP PUT request for the given Sesame `path`.
320
+ #
321
+ # @param [String, #to_s] path
322
+ # @param [Hash{String => String}] headers
323
+ # @yield [response]
324
+ # @yieldparam [Net::HTTPResponse] response
325
+ # @return [Net::HTTPResponse]
326
+ def put(path, headers = {}, &block)
327
+ # TODO
328
+ end
329
+
330
+ ##
331
+ # Performs an HTTP DELETE request for the given Sesame `path`.
332
+ #
333
+ # @param [String, #to_s] path
334
+ # @param [Hash{String => String}] headers
335
+ # @yield [response]
336
+ # @yieldparam [Net::HTTPResponse] response
337
+ # @return [Net::HTTPResponse]
338
+ def delete(path, headers = {}, &block)
339
+ # TODO
340
+ end
86
341
  end
87
- end end
342
+ end
@@ -1,27 +1,83 @@
1
- module RDF module Sesame
1
+ module RDF::Sesame
2
2
  ##
3
- # A repository on a Sesame 2.0 HTTP server.
3
+ # A repository on a Sesame 2.0-compatible HTTP server.
4
4
  #
5
- # @example Connecting to a repository
6
- # url = RDF::URI.new("http://localhost:8080/openrdf-sesame/repositories/")
7
- # db = RDF::Sesame::Repository.new(:url => url)
5
+ # Instances of this class represent RDF repositories on Sesame-compatible
6
+ # servers.
8
7
  #
8
+ # @example Opening a Sesame repository (1)
9
+ # url = "http://localhost:8080/openrdf-sesame/repositories/SYSTEM"
10
+ # db = RDF::Sesame::Repository.new(url)
11
+ #
12
+ # @example Opening a Sesame repository (2)
13
+ # server = RDF::Sesame::Server.new("http://localhost:8080/openrdf-sesame")
14
+ # db = RDF::Sesame::Repository.new(:server => server, :id => :SYSTEM)
15
+ #
16
+ # @example Opening a Sesame repository (3)
17
+ # server = RDF::Sesame::Server.new("http://localhost:8080/openrdf-sesame")
18
+ # db = server.repository(:SYSTEM)
19
+ #
20
+ # @see RDF::Sesame
9
21
  # @see http://www.openrdf.org/doc/sesame2/system/ch08.html
10
22
  class Repository < RDF::Repository
11
- alias_method :url, :uri
23
+ include Enumerable
24
+
25
+ # @return [RDF::URI]
26
+ attr_reader :url
27
+ alias_method :uri, :url
28
+
29
+ # @return [String]
30
+ attr_reader :id
31
+
32
+ # @return [String]
33
+ attr_reader :title
12
34
 
13
- # @return [Connection]
14
- attr_reader :connection
35
+ # @return [Server]
36
+ attr_reader :server
15
37
 
16
38
  ##
17
- # @param [Hash{Symbol => Object}] options
18
- # @option options [RDF::URI] :url (nil)
19
- # @yield [repository]
20
- # @yieldparam [Repository]
21
- def initialize(options = {}, &block)
22
- @title = options.delete(:title) if options.has_key?(:title)
23
- @uri = options.delete(:url) || options.delete(:uri)
24
- @options = options
39
+ # Initializes this `Repository` instance.
40
+ #
41
+ # @overload initialize(url)
42
+ # @param [String, RDF::URI] url
43
+ # @yield [repository]
44
+ # @yieldparam [Repository]
45
+ #
46
+ # @overload initialize(options = {})
47
+ # @param [Hash{Symbol => Object}] options
48
+ # @option options [Server] :server (nil)
49
+ # @option options [String] :id (nil)
50
+ # @option options [String] :title (nil)
51
+ # @yield [repository]
52
+ # @yieldparam [Repository]
53
+ #
54
+ def initialize(url_or_options, &block)
55
+ case url_or_options
56
+ when String
57
+ initialize(RDF::URI.new(url_or_options), &block)
58
+ when RDF::URI
59
+ require 'addressable/uri' unless defined?(Addressable)
60
+ require 'pathname' unless defined?(Pathname)
61
+ @uri = url_or_options
62
+ @server = Server.new(RDF::URI.new(Addressable::URI.new({
63
+ :scheme => @uri.scheme,
64
+ :userinfo => @uri.userinfo,
65
+ :host => @uri.host,
66
+ :port => @uri.port,
67
+ :path => Pathname.new(@uri.path).parent.parent.to_s, # + '../..'
68
+ })))
69
+ @options = {}
70
+ when Hash
71
+ raise ArgumentError.new("missing options[:server]") unless url_or_options.has_key?(:server)
72
+ raise ArgumentError.new("missing options[:id]") unless url_or_options.has_key?(:id)
73
+ @options = url_or_options.dup
74
+ @server = @options.delete(:server)
75
+ @id = @options.delete(:id)
76
+ @uri = @options.delete(:uri) || server.url("repositories/#{@id}")
77
+ @title = @options.delete(:title)
78
+ else
79
+ raise ArgumentError.new("wrong argument type #{url_or_options.class} (expected String, RDF::URI or Hash)")
80
+ end
25
81
 
26
82
  if block_given?
27
83
  case block.arity
@@ -30,5 +86,49 @@ module RDF module Sesame
30
86
  end
31
87
  end
32
88
  end
89
+
90
+ ##
91
+ # Returns the URL for the given repository-relative `path`.
92
+ #
93
+ # @param [String, #to_s] path
94
+ # @return [RDF::URI]
95
+ def url(path = nil)
96
+ path ? RDF::URI.new("#{@uri}/#{path}") : @uri # FIXME
97
+ end
98
+
99
+ alias_method :uri, :url
100
+
101
+ ##
102
+ # Returns the number of RDF statements in this repository.
103
+ #
104
+ # @return [Integer]
105
+ # @see http://www.openrdf.org/doc/sesame2/system/ch08.html#d0e569
106
+ def size
107
+ get(:size) do |response|
108
+ case response
109
+ when Net::HTTPSuccess
110
+ size = response.body
111
+ size.to_i rescue 0
112
+ else 0
113
+ end
114
+ end
115
+ end
116
+
117
+ protected
118
+
119
+ ##
120
+ # Performs an HTTP GET request for the given Sesame repository `path`.
121
+ #
122
+ # @param [String, #to_s] path
123
+ # @param [Hash{String => String}] headers
124
+ # @yield [response]
125
+ # @yieldparam [Net::HTTPResponse] response
126
+ # @return [Net::HTTPResponse]
127
+ def get(path, headers = {}, &block)
128
+ @server.connection.open do
129
+ @server.connection.get(url(path), headers, &block)
130
+ end
131
+ end
132
+
33
133
  end
34
- end end
134
+ end
@@ -0,0 +1,226 @@
1
+ module RDF::Sesame
2
+ ##
3
+ # A server endpoint compatible with the Sesame 2.0 HTTP protocol.
4
+ #
5
+ # Instances of this class represent Sesame-compatible servers that contain
6
+ # one or more readable and/or writable RDF {Repository repositories}.
7
+ #
8
+ # @example Connecting to a Sesame server
9
+ # url = RDF::URI.new("http://localhost:8080/openrdf-sesame")
10
+ # server = RDF::Sesame::Server.new(url)
11
+ #
12
+ # @example Retrieving the server's protocol version
13
+ # server.protocol #=> 4
14
+ #
15
+ # @example Iterating over available RDF repositories
16
+ # server.each_repository do |repository|
17
+ # puts repository.inspect
18
+ # end
19
+ #
20
+ # @example Finding all readable, non-empty RDF repositories
21
+ # server.find_all do |repository|
22
+ # repository.readable? && !repository.empty?
23
+ # end
24
+ #
25
+ # @example Checking if any RDF repositories are writable
26
+ # server.any? { |repository| repository.writable? }
27
+ #
28
+ # @example Checking if a specific RDF repository exists on the server
29
+ # server.has_repository?(:SYSTEM) #=> true
30
+ # server.has_repository?(:foobar) #=> false
31
+ #
32
+ # @example Obtaining a specific RDF repository
33
+ # server.repository(:SYSTEM) #=> RDF::Sesame::Repository(SYSTEM)
34
+ # server[:SYSTEM] #=> RDF::Sesame::Repository(SYSTEM)
35
+ #
36
+ # @see RDF::Sesame
37
+ # @see http://www.openrdf.org/doc/sesame2/system/ch08.html
38
+ class Server
39
+ include Enumerable
40
+
41
+ ACCEPT_JSON = {'Accept' => 'application/sparql-results+json'}
42
+ ACCEPT_XML = {'Accept' => 'application/sparql-results+xml'}
43
+ ACCEPT_BOOL = {'Accept' => 'text/boolean'}
44
+
45
+ # @return [RDF::URI]
46
+ attr_reader :url
47
+
48
+ # @return [Hash{Symbol => Object}]
49
+ attr_reader :options
50
+
51
+ # @return [Connection]
52
+ attr_reader :connection
53
+
54
+ ##
55
+ # Initializes this `Server` instance.
56
+ #
57
+ # @param [RDF::URI] url
58
+ # @param [Hash{Symbol => Object}] options
59
+ # @option options [Connection] :connection (nil)
60
+ # @yield [connection]
61
+ # @yieldparam [Server]
62
+ def initialize(url, options = {}, &block)
63
+ require 'addressable/uri' unless defined?(Addressable)
64
+ @url = case url
65
+ when Addressable::URI then url
66
+ else Addressable::URI.parse(url.to_s)
67
+ end
68
+ @url = RDF::URI.new(@url)
69
+
70
+ @connection = options.delete(:connection) || Connection.new(@url)
71
+ @options = options
72
+
73
+ if block_given?
74
+ case block.arity
75
+ when 1 then block.call(self)
76
+ else instance_eval(&block)
77
+ end
78
+ end
79
+ end
80
+
81
+ ##
82
+ # Returns the URL for the given server-relative `path`.
83
+ #
84
+ # @example Getting a Sesame server's URL
85
+ # server.url #=> RDF::URI("http://localhost:8080/openrdf-sesame")
86
+ #
87
+ # @example Getting a Sesame server's protocol URL
88
+ # server.url(:protocol) #=> RDF::URI("http://localhost:8080/openrdf-sesame/protocol")
89
+ #
90
+ # @param [String, #to_s] path
91
+ # @return [RDF::URI]
92
+ def url(path = nil)
93
+ path ? RDF::URI.new("#{@url}/#{path}") : @url # FIXME
94
+ end
95
+
96
+ alias_method :uri, :url
97
+
98
+ ##
99
+ # Returns the URL of this server.
100
+ #
101
+ # @return [RDF::URI]
102
+ def to_uri
103
+ url
104
+ end
105
+
106
+ ##
107
+ # Returns the URL of this server as a string.
108
+ #
109
+ # @return [String]
110
+ def to_s
111
+ url.to_s
112
+ end
113
+
114
+ ##
115
+ # Returns a developer-friendly representation of this instance.
116
+ #
117
+ # @return [String]
118
+ def inspect
119
+ sprintf("#<%s:%#0x(%s)>", self.class.name, object_id, to_s)
120
+ end
121
+
122
+ ##
123
+ # Returns the Sesame server's protocol version.
124
+ #
125
+ # @example Retrieving the protocol version
126
+ # server.protocol #=> 4
127
+ #
128
+ # @return [Integer]
129
+ # @see http://www.openrdf.org/doc/sesame2/system/ch08.html#d0e180
130
+ def protocol
131
+ get(:protocol) do |response|
132
+ case response
133
+ when Net::HTTPSuccess
134
+ version = response.body
135
+ version.to_i rescue 0
136
+ else 0
137
+ end
138
+ end
139
+ end
140
+
141
+ alias_method :protocol_version, :protocol
142
+
143
+ ##
144
+ # Enumerates over each repository on this Sesame server.
145
+ #
146
+ # @yield [repository]
147
+ # @yieldparam [Repository] repository
148
+ # @return [Enumerable]
149
+ # @see #repository
150
+ # @see #repositories
151
+ def each_repository(&block)
152
+ repositories.values.each(&block)
153
+ end
154
+
155
+ alias_method :each, :each_repository
156
+
157
+ ##
158
+ # Returns `true` if
159
+ #
160
+ # @param [id] String
161
+ # @return [Boolean]
162
+ def has_repository?(id)
163
+ repositories.has_key?(id.to_s)
164
+ end
165
+
166
+ ##
167
+ # Returns a repository on this Sesame server.
168
+ #
169
+ # @param [String] id
170
+ # @return [Repository]
171
+ # @see #repositories
172
+ # @see #each_repository
173
+ def repository(id)
174
+ repositories[id.to_s]
175
+ end
176
+
177
+ alias_method :[], :repository
178
+
179
+ ##
180
+ # Returns all repositories on this Sesame server.
181
+ #
182
+ # @return [Hash{String => Repository}]
183
+ # @see #repository
184
+ # @see #each_repository
185
+ # @see http://www.openrdf.org/doc/sesame2/system/ch08.html#d0e204
186
+ def repositories
187
+ require 'json' unless defined?(JSON)
188
+
189
+ get(:repositories, ACCEPT_JSON) do |response|
190
+ case response
191
+ when Net::HTTPSuccess
192
+ json = JSON.parse(response.body)
193
+ json['results']['bindings'].inject({}) do |repositories, binding|
194
+ repository = Repository.new({
195
+ :server => self,
196
+ :uri => (uri = RDF::URI.new(binding['uri']['value'])),
197
+ :id => (id = binding['id']['value']),
198
+ :title => (title = binding['title']['value']),
199
+ :readable => binding['readable']['value'] == 'true',
200
+ :writable => binding['writable']['value'] == 'true',
201
+ })
202
+ repositories.merge({id => repository})
203
+ end
204
+ else [] # FIXME
205
+ end
206
+ end
207
+ end
208
+
209
+ protected
210
+
211
+ ##
212
+ # Performs an HTTP GET request for the given Sesame server `path`.
213
+ #
214
+ # @param [String, #to_s] path
215
+ # @param [Hash{String => String}] headers
216
+ # @yield [response]
217
+ # @yieldparam [Net::HTTPResponse] response
218
+ # @return [Net::HTTPResponse]
219
+ def get(path, headers = {}, &block)
220
+ @connection.open do
221
+ @connection.get(url(path), headers, &block)
222
+ end
223
+ end
224
+
225
+ end
226
+ end
@@ -2,7 +2,7 @@ module RDF module Sesame
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 0
5
+ TINY = 1
6
6
  EXTRA = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
data/lib/rdf/sesame.rb CHANGED
@@ -2,20 +2,41 @@ require 'rdf'
2
2
 
3
3
  module RDF
4
4
  ##
5
- # RDF::Sesame: Sesame 2.0 adapter for RDF.rb.
5
+ # **`RDF::Sesame`** is a Sesame 2.0 adapter for RDF.rb.
6
6
  #
7
- # @example Installing the RDF::Sesame plugin
8
- # $ sudo gem install rdf-sesame
7
+ # Dependencies
8
+ # ------------
9
9
  #
10
- # @example Requiring the RDF::Sesame plugin
10
+ # * [RDF.rb](http://rdf.rubyforge.org/) (>= 0.0.6)
11
+ # * [JSON](http://flori.github.com/json/) (>= 1.2.0)
12
+ #
13
+ # Installation
14
+ # ------------
15
+ #
16
+ # The recommended installation method is via RubyGems. To install the latest
17
+ # official release from Gemcutter, do:
18
+ #
19
+ # % [sudo] gem install rdf-sesame
20
+ #
21
+ # Documentation
22
+ # -------------
23
+ #
24
+ # * {RDF::Sesame::Connection}
25
+ # * {RDF::Sesame::Repository}
26
+ # * {RDF::Sesame::Server}
27
+ #
28
+ # @example Requiring the `RDF::Sesame` module
11
29
  # require 'rdf/sesame'
12
30
  #
13
31
  # @see http://rdf.rubyforge.org/
14
32
  # @see http://www.openrdf.org/
15
33
  # @see http://www.openrdf.org/doc/sesame2/system/ch08.html
34
+ #
35
+ # @author [Arto Bendiken](http://ar.to/)
16
36
  module Sesame
17
37
  autoload :Connection, 'rdf/sesame/connection'
18
38
  autoload :Repository, 'rdf/sesame/repository'
39
+ autoload :Server, 'rdf/sesame/server'
19
40
  autoload :VERSION, 'rdf/sesame/version'
20
41
  end
21
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-sesame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-31 00:00:00 +01:00
12
+ date: 2010-01-01 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,6 +42,16 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 0.0.6
44
44
  version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: json
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.2.0
54
+ version:
45
55
  description: RDF::Sesame is a Sesame 2.0 adapter for RDF.rb.
46
56
  email: arto.bendiken@gmail.com
47
57
  executables: []
@@ -57,6 +67,7 @@ files:
57
67
  - VERSION
58
68
  - lib/rdf/sesame/connection.rb
59
69
  - lib/rdf/sesame/repository.rb
70
+ - lib/rdf/sesame/server.rb
60
71
  - lib/rdf/sesame/version.rb
61
72
  - lib/rdf/sesame.rb
62
73
  has_rdoc: false