Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to programmatically populate the Dim Loader with requirements #29

Open
aschaal opened this issue Oct 25, 2024 · 0 comments
Open
Assignees
Labels
dim This issue is about the Dim tool enhancement New feature or request

Comments

@aschaal
Copy link
Collaborator

aschaal commented Oct 25, 2024

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:

    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
@aschaal aschaal added enhancement New feature or request dim This issue is about the Dim tool labels Oct 25, 2024
@aschaal aschaal self-assigned this Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dim This issue is about the Dim tool enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant