Permalink
Browse files

all adapters load as gem_plugins now

  • Loading branch information...
1 parent dedaa77 commit 9771cd8bea2e657630b7535e3bcd05aaff7dc46b Eyal Oren committed Oct 24, 2006
View
@@ -1,39 +1,45 @@
-require 'rubygems'
+require 'rake'
+require 'rake/testtask'
+require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
+require 'tools/rakehelp'
+require 'rubygems'
-Gem::manage_gems
-
-spec = Gem::Specification.new do |s|
- s.name = 'activerdf'
- s.version = '0.9.4'
- s.author = 'Eyal Oren'
- s.email = 'eyal.oren@deri.org'
- s.homepage = 'http://activerdf.org'
- s.platform = Gem::Platform::RUBY
- s.summary = 'Offers object-oriented access to RDF (with adapters to several datastores).'
- s.files = Dir['lib/**/*.rb']
- s.require_path = 'lib'
- s.autorequire = 'active_rdf'
- s.test_file = 'test/ts_active_rdf.rb'
- s.has_rdoc = true
- s.extra_rdoc_files = ["README"]
- s.add_dependency('gem_plugin', '>= 0.2.1')
-end
+#Gem::manage_gems
+setup_tests
+setup_rdoc ['README', 'LICENSE', 'lib/**/*.rb']
-Rake::GemPackageTask.new(spec) do |pkg|
-end
+desc 'test and package gem'
+task :default => :reinstall
-Rake::RDocTask.new do |rd|
- rd.main = "README"
- rd.rdoc_dir = "doc"
- rd.title = "ActiveRDF RDoc documentation"
- rd.rdoc_files.include("README", "lib/**/*.rb")
-end
+version="0.9.5"
+name="activerdf"
-task :default => [:upload]
+setup_gem(name,version) do |spec|
+ spec.summary = 'Offers object-oriented access to RDF (with adapters to several datastores).'
+ spec.description = spec.summary
+ spec.author = 'Eyal Oren'
+ spec.email = 'eyal.oren@deri.org'
+ spec.homepage = 'http://www.activerdf.org'
+ spec.platform = Gem::Platform::RUBY
+ spec.require_path = 'lib'
+ spec.autorequire = 'active_rdf'
+ spec.test_file = 'test/ts_active_rdf.rb'
+ spec.add_dependency('gem_plugin', '>= 0.2.1')
+end
task :upload => :package do |task|
sh "scp pkg/*.gem eyal@m3pe.org:/home/eyal/webs/activerdf/gems/"
sh "scp activerdf-*/pkg/*.gem eyal@m3pe.org:/home/eyal/webs/activerdf/gems/"
end
+
+task :install => [:test, :package] do
+ sh %{sudo gem install pkg/#{name}-#{version}.gem}
+end
+
+task :uninstall => [:clean] do
+ sh %{sudo gem uninstall #{name}}
+end
+
+task :reinstall => [:uninstall, :install]
@@ -8,15 +8,13 @@ require 'fileutils'
include FileUtils
setup_tests
-setup_clean ["pkg", "lib/*.bundle", "*.gem", ".config"]
-
setup_rdoc ['README', 'LICENSE', 'lib/**/*.rb', 'doc/**/*.rdoc']
-desc "Does a full compile, test run"
+desc "test and package gem"
task :default => [:test, :package]
version="0.2.1"
-name="activerdf-rdflite"
+name="activerdf_rdflite"
setup_gem(name, version) do |spec|
spec.summary = "an RDF database for usage in ActiveRDF (based on sqlite3)"
@@ -37,3 +35,4 @@ task :uninstall => [:clean] do
sh %{sudo gem uninstall #{name}}
end
+task :reinstall => [:uninstall, :install]
@@ -18,7 +18,8 @@
@@have_ferret = false
end
-class RDFLite
+class RDFLite < GemPlugin::Plugin "/adapter"
+ $log.info "loading RDFLite adapter"
ConnectionPool.register_adapter(:rdflite,self)
attr_reader :db
@@ -105,6 +106,9 @@ def size
#end
def add(s,p,o)
+ raise(ActiveRdfError, "adding non-resource #{s}") unless s.respond_to?(:uri)
+ raise(ActiveRdfError, "adding non-resource #{p}") unless p.respond_to?(:uri)
+
s = "<#{s.uri}>"
p = "<#{p.uri}>"
o = case o
@@ -1,2 +0,0 @@
----
-:debug: false
@@ -16,15 +16,16 @@ desc "Does a full compile, test run"
task :default => [:test, :package]
version="0.9"
-name="activerdf-redland"
+name="activerdf_redland"
setup_gem(name, version) do |spec|
spec.summary = "ActiveRDF adapter to Redland RDF store"
spec.description = spec.summary
spec.author="Eyal Oren <eyal.oren@deri.org"
spec.add_dependency('gem_plugin', '>= 0.2.1')
spec.add_dependency('activerdf', '>= 0.9.2')
- spec.files += Dir.glob("resources/**/*")
+ spec.requirements << 'librdf0 (Redland)'
+ spec.requirements << 'librdf-ruby (Redland Ruby bindings)'
end
@@ -36,3 +37,4 @@ task :uninstall => [:clean] do
sh %{sudo gem uninstall #{name}}
end
+task :reinstall => [:uninstall, :install]
@@ -1 +0,0 @@
-require 'redland'
@@ -0,0 +1,10 @@
+# add the directory in which this file is located to the ruby loadpath
+file =
+if File.symlink?(__FILE__)
+ File.readlink(__FILE__)
+else
+ __FILE__
+end
+$: << File.dirname(File.expand_path(file))
+
+require 'redland.rb'
@@ -10,6 +10,7 @@
require 'rdf/redland'
class RedlandAdapter
+ $log.info "loading Redland adapter"
ConnectionPool.register_adapter(:redland,self)
# instantiate connection to Redland database
@@ -0,0 +1,105 @@
+
+def make(makedir)
+ Dir.chdir(makedir) do
+ sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
+ end
+end
+
+
+def extconf(dir)
+ Dir.chdir(dir) do ruby "extconf.rb" end
+end
+
+
+def setup_tests
+ Rake::TestTask.new do |t|
+ t.libs << "test"
+ t.test_files = FileList['test/test*.rb']
+ t.verbose = true
+ end
+end
+
+
+def setup_clean otherfiles
+ files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
+ CLEAN.include(files)
+end
+
+
+def setup_rdoc files
+ Rake::RDocTask.new do |rdoc|
+ rdoc.rdoc_dir = 'doc/rdoc'
+ rdoc.options << '--line-numbers'
+ rdoc.rdoc_files.add(files)
+ end
+end
+
+
+def setup_extension(dir, extension)
+ ext = "ext/#{dir}"
+ ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
+ ext_files = FileList[
+ "#{ext}/*.c",
+ "#{ext}/*.h",
+ "#{ext}/extconf.rb",
+ "#{ext}/Makefile",
+ "lib"
+ ]
+
+ task "lib" do
+ directory "lib"
+ end
+
+ desc "Builds just the #{extension} extension"
+ task extension.to_sym => ["#{ext}/Makefile", ext_so ]
+
+ file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
+ extconf "#{ext}"
+ end
+
+ file ext_so => ext_files do
+ make "#{ext}"
+ cp ext_so, "lib"
+ end
+end
+
+
+def base_gem_spec(pkg_name, pkg_version)
+ pkg_version = pkg_version
+ pkg_name = pkg_name
+ pkg_file_name = "#{pkg_name}-#{pkg_version}"
+ Gem::Specification.new do |s|
+ s.name = pkg_name
+ s.version = pkg_version
+ s.platform = Gem::Platform::RUBY
+ s.has_rdoc = true
+ s.extra_rdoc_files = [ "README" ]
+
+ s.files = %w(LICENSE README Rakefile) +
+ Dir.glob("{bin,doc/rdoc,test,lib}/**/*") +
+ Dir.glob("ext/**/*.{h,c,rb}") +
+ Dir.glob("examples/**/*.rb") +
+ Dir.glob("tools/*.rb")
+
+ s.require_path = "lib"
+ s.extensions = FileList["ext/**/extconf.rb"].to_a
+ s.bindir = "bin"
+ end
+end
+
+def setup_gem(pkg_name, pkg_version)
+ spec = base_gem_spec(pkg_name, pkg_version)
+ yield spec if block_given?
+
+ Rake::GemPackageTask.new(spec) do |p|
+ p.gem_spec = spec
+ p.need_tar = true
+ end
+end
+
+def setup_win32_gem(pkg_name, pkg_version)
+ spec = base_gem_spec(pkg_name, pkg_version)
+ yield spec if block_given?
+
+ Gem::Builder.new(spec).build
+end
@@ -16,15 +16,14 @@ desc "Does a full compile, test run"
task :default => [:test, :package]
version="0.9"
-name="activerdf-sparql"
+name="activerdf_sparql"
setup_gem(name, version) do |spec|
spec.summary = "ActiveRDF adapter to SPARQL endpoint"
spec.description = spec.summary
spec.author="Eyal Oren <eyal.oren@deri.org"
spec.add_dependency('gem_plugin', '>= 0.2.1')
spec.add_dependency('activerdf', '>= 0.9.2')
- spec.files += Dir.glob("resources/**/*")
end
@@ -36,3 +35,4 @@ task :uninstall => [:clean] do
sh %{sudo gem uninstall #{name}}
end
+task :reinstall => [:uninstall, :install]
@@ -1 +0,0 @@
-require 'sparql'
@@ -0,0 +1,10 @@
+# add the directory in which this file is located to the ruby loadpath
+file =
+if File.symlink?(__FILE__)
+ File.readlink(__FILE__)
+else
+ __FILE__
+end
+$: << File.dirname(File.expand_path(file))
+
+require 'sparql'
@@ -9,6 +9,7 @@
require 'cgi'
class SparqlAdapter
+ $log.info "loading SPARQL adapter"
ConnectionPool.register_adapter(:sparql, self)
def reads?
Oops, something went wrong.

0 comments on commit 9771cd8

Please sign in to comment.