A factory that can create a mixin on the fly from an RDF Class. It is responsible for discovering the vocabulary the class is from, loading it, and generating a Module object from the Properties in the class’s domain.
The directory that the registry cache store is created in
Create a new MixinFactory that will use the specified directory for its cache of loaded triples.
# File lib/redleaf/archetypes.rb, line 116 116: def initialize 117: @cachedb = REGISTRY_CACHE_DIR + 'redleaf' + 'archetypes' 118: @cachedb.mkpath 119: 120: @modules = {} 121: @store = Redland::HashesStore.load( @cachedb ) 122: @graph = @store.graph 123: end
Fetch the archetype module for the given uri, fetching the vocabulary and creating the module if necessary.
# File lib/redleaf/archetypes.rb, line 132 132: def get_archetype_module( classuri ) 133: @modules[ key ] ||= self.make_module_for( classuri ) 134: return @modules[ classuri ] 135: end
Return an Array of class property statements for the given classuri, loading the containing vocabulary if it isn’t already loaded.
# File lib/redleaf/archetypes.rb, line 148 148: def get_class_properties( classuri ) 149: 150: # If the graph doesn't yet have the necessary vocabulary loaded, try to load it 151: # ourselves. 152: unless @graph.has_subject?( classuri ) 153: vocabulary, typename = split_typeuri( classuri ) 154: 155: stmt_count = @graph.load( vocabulary ) 156: 157: unless @graph.has_subject?( classuri ) 158: raise Redleaf::Error, 159: "Loading the vocabulary at %s didn't add any statements describing %s" % 160: [ vocabulary, typename ] 161: end 162: end 163: 164: 165: end
Split the given uri into a vocabulary uri and a type name.
# File lib/redleaf/archetypes.rb, line 173 173: def split_typeuri( uri ) 174: vocabulary = uri.dup 175: typename = nil 176: 177: if uri.fragment 178: typename = uri.fragment 179: vocabulary.fragment = nil 180: else 181: typename = uri.path.sub( %r{.*/}, '' ) 182: vocabulary.path = uri.path.sub( %r{/[^/]*$}, '' ) 183: end 184: 185: return vocabulary, typename 186: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.