Currently, the Loader class is intended exclusively for loading data from Dim files and was not designed to be programmatically populated with data.
A mechanism shall be implemented to programmatically load requirement data into the loader, either by adding elements to the original data or by incorporating additional requirements.
Therefore, the Loader class must be fully initialized without the need for calling the load method, achieved, for example, through an init method.
Example:
class Reqirement_Container
attr_accessor :original_data, :all_attributes, :base_dir
def initialize(base_directory)
@base_dir = base_directory
@original_data = {}
@all_attributes = ::Dim::Requirement::SYNTAX
end
def add_attribute(attribute)
@all_attributes.merge!(attribute)
end
def add_module(moduleName, module_data = {})
filename = File.join(@base_dir, moduleName)
module_data.merge!({"module" => moduleName })
@original_data[filename] = module_data
return filename
end
def requirements
@original_data.map do |filename, data|
modulename = data.fetch("module", "")
origin = ""
category = ""
linenumber = 0
data.map do |id, attr|
Dim::Requirement.new(id, modulename, filename, attr, origin, self, category, linenumber, @all_attributes)
end
end.flatten
end
end
From @JTiefnig:
Currently, the Loader class is intended exclusively for loading data from Dim files and was not designed to be programmatically populated with data.
A mechanism shall be implemented to programmatically load requirement data into the loader, either by adding elements to the original data or by incorporating additional requirements.
Therefore, the Loader class must be fully initialized without the need for calling the load method, achieved, for example, through an init method.
Example: