Sha256: 29bc16c10cb775fad5a36cc7b5d535387bf5dccca61556f8e8605e6978346d8f

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

#:include: ../shared/license.rdoc

require "set"

#This class is a singleton used for storing locations of model source files.
class Crdf_loader
	include Singleton
	attr_reader :rdf_model
	attr_reader :availableProfiles,:activeProfiles
	#attr_writer :availableProfiles,:activeProfiles
	attr_reader :sourceFiles

	def profiles
	end
	
	# Add fn file to the list of model source files and loads it.
	# Note:  
	#   source file is stored internaly as full path (expanded)
	#   because running program current directory is subject to change 
	#   especialy when rails server is used.
	def addModelFile(fn)
		fn=File.expand_path(fn)
		@sourceFiles << fn if !@sourceFiles.include?(fn)
		@rdf_model.loadModelFromFile(fn)
		#log.debug "fn=#{fn}"
		#TODO: enlever les fragments
	end

	# clear current model and reloads it from file
	def reset 
		@rdf_model=Crdf_Model.new
		#TODO: supprimer adhérence UML
		@rdf_model.loadUml2
		@sourceFiles.each { |fn| 
			@rdf_model.loadModelFromFile(fn)
		}
	end

	def initialize
		log.debug "Crdf_loader: initialisation singleton"

		#TODO: REWRITE (currently KO) 
		@sourceFiles=Array.new()
		@availableProfiles=Set.new()
		@availableProfiles.add("uml2/uml2.rb")
		@availableProfiles.add("java/java.rb")
		#@availableProfiles[2]="java/hibernate.rb"
		@activeProfiles=Set.new()
		log.debug "Crdf_loader: fin initialisation singleton"
		reset
	end
## 	def loadProfile
## 		log.warn "TODO: reecrire"
## 		return
## 		log.debug "loadProfile ...."
## 		@availableProfiles.each { |prof| 
## 			if @activeProfiles.include?(prof)
## 			#c=cookies[:user_name]
## 				log.debug "load profile #{prof}"
## 				require prof
## 			else
## 				log.debug "skip profile #{prof}"
## 				require prof
## 			end
## 			}
## 		load "uml2/uml2.rdfs.nt.rb"
## 	end
end

#Crdf_loader.instance

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ontomde-core-1.0.2 lib/ontomde-core/loader.rb