class Lutaml::Uml::Parsers::Yaml
Public Class Methods
parse(yaml_path, options = {})
click to toggle source
# File lib/lutaml/uml/parsers/yaml.rb, line 12 def self.parse(yaml_path, options = {}) new.parse(yaml_path, options) end
Public Instance Methods
parse(yaml_path, _options = {})
click to toggle source
# File lib/lutaml/uml/parsers/yaml.rb, line 16 def parse(yaml_path, _options = {}) yaml_parse(yaml_path) end
yaml_parse(yaml_path)
click to toggle source
# File lib/lutaml/uml/parsers/yaml.rb, line 20 def yaml_parse(yaml_path) yaml_content = YAML.safe_load(File.read(yaml_path)) serialized_yaml = Lutaml::Uml::Serializers::YamlView .new(yaml_content) result = Lutaml::Uml::Document.new(serialized_yaml) result.classes = imports_to_classes(yaml_content, yaml_path) result end
Private Instance Methods
imports_to_classes(yaml_content, yaml_path)
click to toggle source
# File lib/lutaml/uml/parsers/yaml.rb, line 31 def imports_to_classes(yaml_content, yaml_path) models_path = File.join(File.dirname(yaml_path), "..", "models") yaml_content["imports"].map do |(klass_name, _)| klass_attrs = YAML.safe_load( File.read( File.join(models_path, "#{klass_name}.yml") ) ) klass_attrs["name"] = klass_name if klass_attrs["name"].nil? Lutaml::Uml::Serializers::Class.new(klass_attrs) end end