activerdf_sesame 0.2.1 → 0.2.2

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.
Files changed (6) hide show
  1. data/CHANGELOG +6 -0
  2. data/README +23 -16
  3. data/Rakefile +51 -31
  4. data/VERSION +1 -0
  5. data/lib/activerdf_sesame/sesame.rb +40 -57
  6. metadata +11 -9
@@ -0,0 +1,6 @@
1
+ == activerdf_sesame (0.2.2) Tue, 13 Feb 2007 20:38:16 +0000
2
+ * gems published automatically from Rakefile
3
+ * updated readme
4
+
5
+ == activerdf_sesame (0.2.1)
6
+ * included readme and licenses
data/README CHANGED
@@ -1,26 +1,33 @@
1
+ The Sesame2 adapter for ActiveRDF connects ActiveRDF with the Sesame2 RDF store.
1
2
 
2
- This is the sesame 2 adapter for ActiveRDF.
3
+ == Benefits and disadvantages
4
+ Using Sesame2 through this adapter has the following benefits :
5
+ * Good performance, because java code is used for all communication
6
+ * Support for RDF Schema inferencing
7
+ * Support for quads/named graphs (as soon as I get around to implementing them in the adapter)
3
8
 
4
- currently the major benefits of using ActiveRDF with the Sesame Adapter are:
5
- * good speed, because java code is used for all the heavy lifting of a triple store
6
- * rdf schema inferencing
7
- * support for quads/named graphs (as soon as I get around to implementing them in the adapter)
9
+ The disadvantages currently are:
10
+ * Requires installation of jruby and manual setting of the Java CLASSPATH
11
+ * No OWL inferencing (but on other ActiveRDF adapter currently has this anyway)
12
+ * No support for a database backend (Sesame2 uses its own native storage
13
+ interanlly, which is recommended anyway)
8
14
 
9
- disadvantages:
10
- * installation of jruby and manual setting of the java CLASSPATH are required
11
- * no owl inferencing (but all the other adapters also dont have this)
12
- * no support for a database backend
15
+ The adapter uses Sesame 2 Alpha 4, which is distributed as a jar inside this gem.
13
16
 
14
- It uses Sesame 2 Alpha 4, which is distributed as a jar together with this gem.
17
+ == License
18
+ The adapter is distributed under LGPL, the Sesame2 jar is under the Aduna
19
+ license. See LICENSE for more information.
15
20
 
21
+ == Installation
16
22
  For installation instructions visit: http://wiki.activerdf.org/ActiveRDF_and_RoR_and_Sesame
17
23
 
24
+ == More info
18
25
  For more information about ActiveRDF visit:
19
- http://www.activerdf.org/
20
- http://wiki.activerdf.org/ActiveRDF
26
+ * http://www.activerdf.org/
27
+ * http://wiki.activerdf.org/ActiveRDF
21
28
 
22
- For more information about Sesame 2, visit:
23
- http://www.openrdf.org/
24
-
25
- This ruby gem was created by Benjamin Heitmann <benjamin.heitmann@deri.org>
29
+ For more information about Sesame 2, visit:
30
+ * http://www.openrdf.org/
26
31
 
32
+ == Athors
33
+ * Benjamin Heitmann <benjamin.heitmann@deri.org>
data/Rakefile CHANGED
@@ -1,55 +1,75 @@
1
+ require 'meta_project'
1
2
  require 'rake'
2
3
  require 'rake/testtask'
3
4
  require 'rake/clean'
4
5
  require 'rake/gempackagetask'
5
6
  require 'rake/rdoctask'
6
- require '../tools/rakehelp'
7
+ require 'rake/contrib/xforge'
8
+ require 'rubygems'
7
9
  require 'fileutils'
8
- include FileUtils
10
+ require '../tools/rakehelp'
9
11
 
10
- setup_tests
11
- setup_rdoc ['README', 'LICENSE', 'lib/**/*.rb', 'doc/**/*.rdoc']
12
+ $version = IO.read('VERSION').strip
13
+ $name = 'activerdf_sesame'
14
+ $project = MetaProject::Project::XForge::RubyForge.new('activerdf')
12
15
 
13
- desc "test and package gem"
14
- task :default => [:test, :package]
16
+ # setup tests
17
+ setup_tests
18
+ setup_clean ["pkg", "lib/*.bundle", "*.gem", ".config"]
15
19
 
16
- # get @VERSION from commandline
17
- @VERSION = '0.2.1'
18
- NAME="activerdf_sesame"
19
- GEMNAME="#{NAME}-#{@VERSION}.gem"
20
+ # setup rdoc
21
+ Rake::RDocTask.new do |rdoc|
22
+ rdoc.rdoc_dir = 'doc/rdoc'
23
+ rdoc.options << '--line-numbers'
24
+ rdoc.rdoc_files.add ['README', 'LICENSE', 'lib/**/*.rb', 'doc/**/*.rdoc']
25
+ end
20
26
 
21
- # which files should go into the gem?
22
- PKG_FILES = FileList[
23
- 'ext/*.jar',
24
- '[A-Z]*',
25
- 'lib/**/*.rb',
26
- 'test/**/*',
27
- ]
27
+ desc "Does a full compile, test run"
28
+ task :default => [:test, :package]
28
29
 
29
30
  # define package task
30
- setup_gem(NAME,@VERSION) do |spec|
31
- spec.summary = "an RDF database for usage in ActiveRDF (based on sesame2)"
31
+ setup_gem($name, $version) do |spec|
32
+ spec.summary = "jruby adapter to sesame2 datastore (for usage in ActiveRDF)"
32
33
  spec.description = spec.summary
33
34
  spec.author="Benjamin Heitmann <benjamin.heitmann@deri.org>"
34
35
  spec.add_dependency('gem_plugin', '>= 0.2.1')
35
36
  spec.add_dependency('activerdf', '>= 1.2')
36
- spec.files = PKG_FILES.to_a
37
-
37
+ spec.files = FileList[ 'ext/*.jar', '[A-Z]*', 'lib/**/*.rb', 'test/**/*' ].to_a
38
38
  end
39
39
 
40
-
41
-
42
- task :install => [:package] do
43
- sh %{sudo gem install pkg/#{NAME}-#{@VERSION}.gem}
40
+ task :verify_rubyforge do
41
+ raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
42
+ raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD']
44
43
  end
45
44
 
46
- task :uninstall => [:clean] do
47
- sh %{sudo gem uninstall #{NAME}}
48
- end
45
+ desc "Release files on RubyForge."
46
+ task :release_files => [:clean, :verify_rubyforge, :package ] do
47
+ release_files = FileList["pkg/#$name-#$version.gem"]
48
+
49
+ Rake::XForge::Release.new($project) do |release|
50
+ release.user_name = ENV['RUBYFORGE_USER']
51
+ release.password = ENV['RUBYFORGE_PASSWORD']
52
+ release.files = release_files.to_a
53
+ release.release_name = "#$name #$version"
54
+ release.package_name = "activerdf-sesame"
55
+ release.release_notes = ""
49
56
 
50
- task :reinstall => [:uninstall, :install]
57
+ changes = []
58
+ File.open("CHANGELOG") do |file|
59
+ current = true
51
60
 
52
- task :upload => :package do |task|
53
- sh "scp pkg/#{GEMNAME} eyal@activerdf.org:/home/eyal/webs/activerdf/gems/"
61
+ file.each do |line|
62
+ line.chomp!
63
+ if current and line =~ /^==/
64
+ current = false; next
65
+ end
66
+ break if line.empty? and not current
67
+ changes << line
68
+ end
69
+ end
70
+ release.release_changes = changes.join("\n")
71
+ end
54
72
  end
55
73
 
74
+ desc "Release the latest version."
75
+ task :release => [ :verify_rubyforge, :release_files, :rdoc ]
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.2
@@ -119,69 +119,30 @@ class SesameAdapter < ActiveRdfAdapter
119
119
  # you can specify a context to limit deletion to that context:
120
120
  # delete(:s,:p,:o, 'http://context') will delete all triples with that context
121
121
  def delete(s, p, o, c=nil)
122
- if s.class == RDFS::Resource then
123
- sesameSubject = @valueFactory.createURI(s.uri)
124
- elsif s == :s
125
- sesameSubject = nil
126
- else
127
- raise ActiveRdfError, "the Sesame Adapter tried to delete a subject which was not of type RDFS::Resource, but of type #{s.class}"
128
- end
129
- if p.class == RDFS::Resource then
130
- sesamePredicate = @valueFactory.createURI(p.uri)
131
- elsif p == :p
132
- sesamePredicate = nil
133
- else
134
- raise ActiveRdfError, "the Sesame Adapter tried to delete a predicate which was not of type RDFS::Resource, but of type #{p.class}"
135
- end
136
- if o.class == RDFS::Resource then
137
- sesameObject = @valueFactory.createURI(o.uri)
138
- elsif o == :o
139
- sesameObject = nil
140
- else
141
- sesameObject = @valueFactory.createLiteral(o.to_s)
142
- end
143
-
144
- # TODO contexts
145
- candidateStatements = @db.getStatements(sesameSubject, sesamePredicate, sesameObject, false)
146
-
122
+ params = activerdf_to_sesame(s, p, o, c)
123
+
124
+ # TODO: handle context
125
+ candidateStatements = @db.getStatements(params[0], params[1], params[2], false)
147
126
  @db.remove(candidateStatements)
148
-
149
127
  candidateStatements.close
150
- return @db
128
+
129
+ @db
151
130
  end
152
131
 
153
132
  # adds triple(s,p,o) to datastore
154
133
  # s,p must be resources, o can be primitive data or resource
155
134
  def add(s,p,o,c=nil)
156
-
157
- if s.class == RDFS::Resource then
158
- sesameSubject = @valueFactory.createURI(s.uri)
159
- else
160
- raise ActiveRdfError, "the Sesame Adapter tried to add a subject which was not of type RDFS::Resource, but of type #{s.class}"
161
- end
162
- if p.class == RDFS::Resource then
163
- sesamePredicate = @valueFactory.createURI(p.uri)
164
- else
165
- raise ActiveRdfError, "the Sesame Adapter tried to add a predicate which was not of type RDFS::Resource, but of type #{p.class}"
166
- end
167
- if o.class == RDFS::Resource then
168
- sesameObject = @valueFactory.createURI(o.uri)
169
- else
170
- sesameObject = @valueFactory.createLiteral(o.to_s)
171
- end
172
-
173
135
  # TODO: handle context, especially if it is null
174
-
175
- @db.add(sesameSubject, sesamePredicate, sesameObject)
176
- # for contexts, just add 4th parameter
177
-
178
136
  # TODO: do we need to handle errors from the java side ?
137
+
138
+ check_input = [s,p,o]
139
+ raise ActiveRdfError, "cannot add triple with nil subject, predicate, or object" if check_input.any? {|r| r.nil? || r.is_a?(Symbol) }
179
140
 
180
- return @db
141
+ params = activerdf_to_sesame(s, p, o, c)
142
+ @db.add(params[0], params[1], params[2])
143
+ @db
181
144
  end
182
145
 
183
-
184
-
185
146
  # flushing is done automatically, because we run sesame2 in autocommit mode
186
147
  def flush
187
148
  true
@@ -203,18 +164,17 @@ class SesameAdapter < ActiveRdfAdapter
203
164
  # a to a RDFHandler, which we supply, by constructing a NTriplesWriter, which writes to StringWriter,
204
165
  # and we kindly ask that StringWriter to make a string for us. Note, you have to use stringy.to_s,
205
166
  # somehow stringy.toString does not work. yes yes, those wacky jruby guys ;)
206
- stringy = StringWriter.new
207
- sesameWriter = NTriplesWriter.new(stringy)
167
+ _string = StringWriter.new
168
+ sesameWriter = NTriplesWriter.new(_string)
208
169
  @db.export(sesameWriter)
209
- return stringy.to_s
170
+ return _string.to_s
210
171
  end
211
172
 
212
173
  # loads triples from file in ntriples format
213
174
  def load(file)
214
175
  reader = FileReader.new(file)
215
176
  @db.add(reader, "", RDFFormat::NTRIPLES)
216
-
217
- return @db
177
+ @db
218
178
  end
219
179
 
220
180
  # executes ActiveRDF query on the sesame triple store associated with this adapter
@@ -308,5 +268,28 @@ class SesameAdapter < ActiveRdfAdapter
308
268
  raise ActiveRdfError, "the Sesame Adapter tried to return something which is neither a URI nor a Literal, but is instead a #{input.java_class.name}"
309
269
  end
310
270
  end
311
-
271
+
272
+ # converts spoc input into sesame objects (RDFS::Resource into
273
+ # valueFactory.createURI etc.)
274
+ def activerdf_to_sesame(s, p, o, c)
275
+ # TODO: manage contexts
276
+ params = []
277
+
278
+ # construct sesame parameters from s,p,o,c
279
+ [s,p,o].each_with_index do |r,i|
280
+ params[i] = case r
281
+ when RDFS::Resource
282
+ @valueFactory.createURI(s.uri)
283
+ when Symbol
284
+ nil
285
+ else
286
+ if i < 2 # subject or predicate
287
+ raise ActiveRdfError, "trying to add or delete a subject, predicate, or object of type #{r.class}"
288
+ else
289
+ @valueFactory.createLiteral(o.to_s)
290
+ end
291
+ end
292
+ end
293
+ params << c
294
+ end
312
295
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: activerdf_sesame
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.1
7
- date: 2007-02-08 00:00:00 +00:00
8
- summary: an RDF database for usage in ActiveRDF (based on sesame2)
6
+ version: 0.2.2
7
+ date: 2007-02-13 00:00:00 +00:00
8
+ summary: jruby adapter to sesame2 datastore (for usage in ActiveRDF)
9
9
  require_paths:
10
10
  - lib
11
11
  email:
12
12
  homepage:
13
13
  rubyforge_project:
14
- description: an RDF database for usage in ActiveRDF (based on sesame2)
14
+ description: jruby adapter to sesame2 datastore (for usage in ActiveRDF)
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin
@@ -29,18 +29,20 @@ post_install_message:
29
29
  authors:
30
30
  - Benjamin Heitmann <benjamin.heitmann@deri.org>
31
31
  files:
32
- - ext/wrapper-sesame2.jar
33
32
  - ext/openrdf-sesame-2.0-alpha4-onejar.jar
33
+ - ext/wrapper-sesame2.jar
34
34
  - LICENSE
35
- - README
36
- - Rakefile
37
35
  - LICENSE-aduna
38
36
  - LICENSE-lgpl
37
+ - README
38
+ - Rakefile
39
+ - VERSION
40
+ - CHANGELOG
39
41
  - lib/activerdf_sesame/init.rb
40
42
  - lib/activerdf_sesame/sesame.rb
41
43
  - test/eyal-foaf.nt
42
- - test/test_sesame_adapter.rb
43
44
  - test/eyal-foaf.rdf
45
+ - test/test_sesame_adapter.rb
44
46
  test_files: []
45
47
 
46
48
  rdoc_options: []