# (J)RTM: (J)Ruby Topic Maps. # Copyright: Topic Maps Lab www.topicmapslab.de # License: Apache License, Version 2.0 # Project lead: Benjamin Bock bock(at)informatik.uni-leipzig.de # Responsible for (J)RTM: Arnim Bleier bleier(at)informatik.uni-leipzig.de # Responsible for Documentation: Uta Schulze uta.schulze(at)informatik.uni-leipzig.de # Responsible for ActiveTM: Daniel Exner exner(at)informatik.uni-leipzig.de $: << File.expand_path(File.dirname(__FILE__)) module RTM module Topic end module Association end module Occurrence end module Reifiable end module Name end module Role end module Scoped end module Typed end module Variant end module Locator end module Construct end module Reifiable end module TopicMap attr_accessor :engine end module ItemIdentifier end module SubjectIdentifier end module SubjectLocator end module TopicMapSystem end end require 'rtm/version' require "rtm/engine" require 'rtm/extensions' require 'rtm/psi' require "rtm/navigation" require "rtm/axes" require "rtm/sugar" require "rtm/io" module RTM # Connects to a topic map engine. # The optional parameter can be used to # select the backend. # # :call-seq: # RTM.connect(:implementation => :ontopia) -> Ontopia backend # RTM.connect(:implementation => :tinytim) -> tinyTim backend # RTM.connect(:implementation => :activerecord) -> Active Record backend # RTM.connect(:implementation => :sesametm) -> SesameTM backend # RTM.connect(:implementation => :merged) -> Merged TMAPI backend # def self.connect(params = {}, *args) implementation = params[:implementation] unless implementation if Engine.list.first implementation = Engine.list.first warn("No engine implementation was specified for RTM.connect. Using the first already loaded engine (#{implementation.inspect}).") else if RUBY_PLATFORM =~ /java/ implementation = :ontopia else implementation = :activerecord warn("No engine implementation was specified for RTM.connect. Choosing default (#{implementation.inspect}).") end end params[:implementation] = implementation end unless Engine.list.include?(implementation) warn("Requested engine '#{implementation}' not loaded. Trying to autoload it.") Engine.load(implementation) if Engine.list.include?(implementation) warn("Autoloading '#{implementation}' was successful") else raise "Autoloading '#{implementation}' failed. Make sure rtm-#{implementation} exists and is installed or require it manually." end end engine = RTM::Engine[implementation] connection = engine.new(params) @connections ||= {} @connections[implementation] ||= [] @connections[implementation] << connection connection end # Returns all connections grouped by their backend # # :call-seq: # connections -> Hash # def self.connections @connections ||= {} @connections end # Returns all connections. The optional argument may specify the backend # the connections should use. # # :call-seq: # [] -> all connections as Hash # [:tinytim] -> all connections using TinyTiM # [:ontopia] -> all connections using Ontopia # [:sesame] -> all connections using SesameTM # [:activerecord] -> all connectioms using RTM AR # def self.[](args = nil) return @connections[args] if args connections end def self.included(klass) @@meine_implementierungen ||= [] @@meine_implementierungen << klass self.included_modules.each {|im| klass.extend(im)} end end