Class: Lutaml::XMI::Parsers::XML
- Inherits:
-
Object
- Object
- Lutaml::XMI::Parsers::XML
- Defined in:
- lib/lutaml/xmi/parsers/xml.rb
Overview
Class for parsing .xmi schema files into ::Lutaml::Uml::Document
Instance Attribute Summary collapse
-
#xmi_cache ⇒ Object
readonly
Returns the value of attribute xmi_cache.
-
#xmi_root_model ⇒ Object
readonly
Returns the value of attribute xmi_root_model.
Class Method Summary collapse
- .parse(xml, _options = {}) ⇒ Lutaml::Uml::Document
- .serialize_generalization_by_name(xml, name, guidance = nil) ⇒ Hash
- .serialize_xmi(xml, with_gen: false) ⇒ Hash
- .serialize_xmi_to_liquid(xml, guidance = nil) ⇒ Liquid::Drop
Instance Method Summary collapse
- #get_guidance(yaml) ⇒ Hash
- #parse(xmi_model) ⇒ Lutaml::Uml::Document
- #serialize_generalization_by_name(xmi_model, name, guidance_yaml = nil) ⇒ Hash
-
#serialize_xmi(xmi_model, with_gen: false) ⇒ Object
return [Hash].
-
#serialize_xmi_to_liquid(xmi_model, guidance_yaml = nil) ⇒ Object
return [Liquid::Drop].
- #set_xmi_model(xmi_model) ⇒ Object
Instance Attribute Details
#xmi_cache ⇒ Object (readonly)
Returns the value of attribute xmi_cache.
13 14 15 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 13 def xmi_cache @xmi_cache end |
#xmi_root_model ⇒ Object (readonly)
Returns the value of attribute xmi_root_model.
13 14 15 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 13 def xmi_root_model @xmi_root_model end |
Class Method Details
.parse(xml, _options = {}) ⇒ Lutaml::Uml::Document
19 20 21 22 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 19 def parse(xml, = {}) xmi_model = get_xmi_model(xml) new.parse(xmi_model) end |
.serialize_generalization_by_name(xml, name, guidance = nil) ⇒ Hash
42 43 44 45 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 42 def serialize_generalization_by_name(xml, name, guidance = nil) xmi_model = get_xmi_model(xml) new.serialize_generalization_by_name(xmi_model, name, guidance) end |
.serialize_xmi(xml, with_gen: false) ⇒ Hash
27 28 29 30 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 27 def serialize_xmi(xml, with_gen: false) xmi_model = get_xmi_model(xml) new.serialize_xmi(xmi_model, with_gen: with_gen) end |
.serialize_xmi_to_liquid(xml, guidance = nil) ⇒ Liquid::Drop
34 35 36 37 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 34 def serialize_xmi_to_liquid(xml, guidance = nil) xmi_model = get_xmi_model(xml) new.serialize_xmi_to_liquid(xmi_model, guidance) end |
Instance Method Details
#get_guidance(yaml) ⇒ Hash
89 90 91 92 93 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 89 def get_guidance(yaml) return unless yaml YAML.safe_load(File.read(yaml, encoding: "UTF-8")) end |
#parse(xmi_model) ⇒ Lutaml::Uml::Document
64 65 66 67 68 69 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 64 def parse(xmi_model) set_xmi_model(xmi_model) serialized_hash = serialize_xmi(xmi_model) ::Lutaml::Uml::Document.new(serialized_hash) end |
#serialize_generalization_by_name(xmi_model, name, guidance_yaml = nil) ⇒ Hash
98 99 100 101 102 103 104 105 106 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 98 def serialize_generalization_by_name(xmi_model, name, guidance_yaml = nil) set_xmi_model(xmi_model) model = xmi_model.model klass = find_klass_packaged_element_by_name(name) serialized_hash = build_klass_hash(klass, model, with_gen: true) guidance = get_guidance(guidance_yaml) ::Lutaml::XMI::KlassDrop.new(serialized_hash, guidance) end |
#serialize_xmi(xmi_model, with_gen: false) ⇒ Object
return [Hash]
73 74 75 76 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 73 def serialize_xmi(xmi_model, with_gen: false) set_xmi_model(xmi_model) serialize_to_hash(xmi_model, with_gen: with_gen) end |
#serialize_xmi_to_liquid(xmi_model, guidance_yaml = nil) ⇒ Object
return [Liquid::Drop]
80 81 82 83 84 85 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 80 def serialize_xmi_to_liquid(xmi_model, guidance_yaml = nil) set_xmi_model(xmi_model) serialized_hash = serialize_xmi(xmi_model, with_gen: true) guidance = get_guidance(guidance_yaml) ::Lutaml::XMI::RootDrop.new(serialized_hash, guidance) end |
#set_xmi_model(xmi_model) ⇒ Object
57 58 59 60 |
# File 'lib/lutaml/xmi/parsers/xml.rb', line 57 def set_xmi_model(xmi_model) @xmi_cache = {} @xmi_root_model = xmi_model end |