Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

all adapters load as gem_plugins now

  • Loading branch information...
commit 9771cd8bea2e657630b7535e3bcd05aaff7dc46b 1 parent dedaa77
Eyal Oren authored
Showing with 504 additions and 201 deletions.
  1. +34 −28 Rakefile
  2. +3 −4 activerdf-rdflite/Rakefile
  3. 0  activerdf-rdflite/lib/{activerdf-rdflite → activerdf_rdflite}/init.rb
  4. +5 −1 activerdf-rdflite/lib/{activerdf-rdflite → activerdf_rdflite}/rdflite.rb
  5. +0 −2  activerdf-rdflite/resources/defaults.yaml
  6. +4 −2 activerdf-redland/Rakefile
  7. +0 −1  activerdf-redland/lib/activerdf-redland/init.rb
  8. +10 −0 activerdf-redland/lib/activerdf_redland/init.rb
  9. +1 −0  activerdf-redland/lib/{activerdf-redland → activerdf_redland}/redland.rb
  10. 0  {test/adapter → activerdf-redland/test}/ts_redland_adapter.rb
  11. +105 −0 activerdf-redland/tools/rakehelp.rb
  12. +2 −2 activerdf-sparql/Rakefile
  13. +0 −1  activerdf-sparql/lib/activerdf-sparql/init.rb
  14. +10 −0 activerdf-sparql/lib/activerdf_sparql/init.rb
  15. +1 −0  activerdf-sparql/lib/{activerdf-sparql → activerdf_sparql}/sparql.rb
  16. 0  activerdf-sparql/lib/{activerdf-sparql → activerdf_sparql}/sparql_result_parser.rb
  17. 0  {test/adapter → activerdf-sparql/test}/ts_sparql_adapter.rb
  18. +105 −0 activerdf-sparql/tools/rakehelp.rb
  19. +2 −2 activerdf-yars/Rakefile
  20. +0 −1  activerdf-yars/lib/activerdf-yars/init.rb
  21. +10 −0 activerdf-yars/lib/activerdf_yars/init.rb
  22. +1 −0  activerdf-yars/lib/{activerdf-yars → activerdf_yars}/jars2.rb
  23. +105 −0 activerdf-yars/tools/rakehelp.rb
  24. +0 −156 designdocs/new-design.rb.bak
  25. +1 −1  lib/active_rdf/federation/federation_manager.rb
  26. +105 −0 tools/rakehelp.rb
62 Rakefile
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]
7 activerdf-rdflite/Rakefile
View
@@ -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]
0  activerdf-rdflite/lib/activerdf-rdflite/init.rb → activerdf-rdflite/lib/activerdf_rdflite/init.rb
View
File renamed without changes
6 activerdf-rdflite/lib/activerdf-rdflite/rdflite.rb → activerdf-rdflite/lib/activerdf_rdflite/rdflite.rb
View
@@ -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
2  activerdf-rdflite/resources/defaults.yaml
View
@@ -1,2 +0,0 @@
----
-:debug: false
6 activerdf-redland/Rakefile
View
@@ -16,7 +16,7 @@ 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"
@@ -24,7 +24,8 @@ setup_gem(name, version) do |spec|
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  activerdf-redland/lib/activerdf-redland/init.rb
View
@@ -1 +0,0 @@
-require 'redland'
10 activerdf-redland/lib/activerdf_redland/init.rb
View
@@ -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'
1  activerdf-redland/lib/activerdf-redland/redland.rb → activerdf-redland/lib/activerdf_redland/redland.rb
View
@@ -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  test/adapter/ts_redland_adapter.rb → activerdf-redland/test/ts_redland_adapter.rb
View
File renamed without changes
105 activerdf-redland/tools/rakehelp.rb
View
@@ -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
4 activerdf-sparql/Rakefile
View
@@ -16,7 +16,7 @@ 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"
@@ -24,7 +24,6 @@ setup_gem(name, version) do |spec|
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  activerdf-sparql/lib/activerdf-sparql/init.rb
View
@@ -1 +0,0 @@
-require 'sparql'
10 activerdf-sparql/lib/activerdf_sparql/init.rb
View
@@ -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'
1  activerdf-sparql/lib/activerdf-sparql/sparql.rb → activerdf-sparql/lib/activerdf_sparql/sparql.rb
View
@@ -9,6 +9,7 @@
require 'cgi'
class SparqlAdapter
+ $log.info "loading SPARQL adapter"
ConnectionPool.register_adapter(:sparql, self)
def reads?
0  ...arql/lib/activerdf-sparql/sparql_result_parser.rb → ...arql/lib/activerdf_sparql/sparql_result_parser.rb
View
File renamed without changes
0  test/adapter/ts_sparql_adapter.rb → activerdf-sparql/test/ts_sparql_adapter.rb
View
File renamed without changes
105 activerdf-sparql/tools/rakehelp.rb
View
@@ -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
4 activerdf-yars/Rakefile
View
@@ -16,7 +16,7 @@ desc "Does a full compile, test run"
task :default => [:test, :package]
version="0.9"
-name="activerdf-yars"
+name="activerdf_yars"
setup_gem(name, version) do |spec|
spec.summary = "ActiveRDF adapter to YARS RDF store"
@@ -24,7 +24,6 @@ setup_gem(name, version) do |spec|
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  activerdf-yars/lib/activerdf-yars/init.rb
View
@@ -1 +0,0 @@
-require 'jars2'
10 activerdf-yars/lib/activerdf_yars/init.rb
View
@@ -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 'jars2'
1  activerdf-yars/lib/activerdf-yars/jars2.rb → activerdf-yars/lib/activerdf_yars/jars2.rb
View
@@ -12,6 +12,7 @@
# TODO: add unit test
class Jars2Adapter
+ $log.info "loading Jars2 adapter"
ConnectionPool.register_adapter(:jars2, self)
def initialize(params = {})
105 activerdf-yars/tools/rakehelp.rb
View
@@ -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
156 designdocs/new-design.rb.bak
View
@@ -1,156 +0,0 @@
-# scenario's:
-# - construct class model: renaud
-# - lookup resource: renaud
-# - find resource: renaud
-# - read attr. value: eyal
-# - write attr. value: eyal
-#
-#
-# Object logic
-# instance mngr | class mngr | namespace manager
-# Caching Graph
-# lookup & update | complete graph
-# Query Engine
-# Federation
-# Adapter
-# connector | translator | triples
-#
-# graph model is accessible from everywhere (sidebar)
-#
-# dependencies:
-# Class: Graph, QE
-# QE: Graph (construct query), Federation (execute query)
-# Federation: Adapter (execute query), Graph (merge results)
-# Adapter: Connector (execute query on datasource), Translator (transform triples/graph)
-# Translator: Graph, Triple (translate up/down)
-
-# federation manager:
-# 1. ensure single connection to single datasource (REUSE)
-# 2. retrieve right datasource for some task, e.g. writable (SELECT)
-# 3. distribute query and aggregate results (FEDERATE)
-
-
-class RedlandAdapter
- writable = true
- down = Graph2SparqlTranslator.new
- up = RedlandRubyTranslator.new
- connector = RedlandConnector.new
-
- def query(graph)
- result = connector.query(down(graph))
- return up(results)
- end
-end
-
-# managing graph in memory cache
-# caching options
-# 1. RDF(S)::Core (builtin to ActiveRDF
-# 2. schema caching (classes and properties)
-# 3. instance caching (deletion slightly inefficient)
-
-# deletion scenario: QE builds delete
-# QE: federation.delete(graph)
-# federation: adapter.delete(graph)
-# adapter figures out which subgraph will be deleted (same subgraph will be
-# deleted in memory)
-class Adapter
- def delete(graph)
- deleted = query(graph)
- delete(graph)
- return deleted
- end
-end
-
-class Federation
- def delete(graph)
- pool.writable.delete(graph)
- end
-end
-
-class QueryEngine
- def delete(graph)
- deleted = federation.delete(graph)
- graph.remove_graph(subgraph)
- end
-end
-
-class Graph
- def add(source, edge, target)
- end
-
- def remove(source, edge, target)
- end
-
- def add_graph(datagraph)
- end
-
- def remove_graph(datagraph)
- end
-
- def nodes
- end
-
- def lookup(content)
- end
-end
-
-# code below now CHANGED: adapter receives and returns graphs
-
-# in adapter:
-def query(qs)
- results = query(qs)
- # an example, actual code would depend on number of result bindings (in this
- # case, we only consider triples)
- results.each do |s,p,o|
- # an example, actual code would depend on parse-type of s, p, and o
- yield URI.new(s), URI.new(p), Literal.new(o)
- end
-end
-
-# in QueryEngine (including translator)
-# before this we have code building the query... such as select, condition,
-# keyword
-def query
- query_graph = build_graph # builds a query graph from the current query options
- result_graph = Graph.new
-
- datasource.query(translator.query_string(query_graph)).each do |s,p,o|
- $graph.add(s,p,o)
- end
- return result_graph
-end
-
-# in class logic (static API)
-def get(property)
- qe.select :o
- qe.condition self, property, :o
- nodes = qe.execute
- nodes.collect do |n|
- # instance manager returns objects, such as Strings or Persons
- InstanceManager.retrieve(n)
- end
-end
-
-# in instance manager (part of OMM)
-def retrieve(node)
- if cache.contains? node
- cache[node]
- else
- node_type = node.outgoing(RDF::type)
- node_class = retrieve(type)
- cache[node] = node_class.send(:create, node)
- end
-end
-
-# in Resource (or Person, virtually)
-def create(uri)
- node = graph.lookup(uri)
- OMM.retrieve(node)
-end
-
-# OMM manages cache if cache enabled
-#
-# OMM builds class model (need to work out further)
-# def add_namespace(prefix, symbol)
-# def add_class(URI, symbol)
-# def add_instance(URI, symbol)
2  lib/active_rdf/federation/federation_manager.rb
View
@@ -64,7 +64,7 @@ def FederationManager.query(q, options={:flatten => true})
final_results = results
end
end
- $log.debug "FederationManager: query results are #{final_results.join(', ')}"
+ $log.debug "FederationManager: query results are #{final_results}"
return final_results
end
end
105 tools/rakehelp.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.