Class: Metanorma::Plugin::Lutaml::XmiParseCache
- Inherits:
-
Object
- Object
- Metanorma::Plugin::Lutaml::XmiParseCache
- Defined in:
- lib/metanorma/plugin/lutaml/xmi_parse_cache.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #fetch(full_path) ⇒ Object
- #fetch_drop(full_path, guidance: nil) ⇒ Object
-
#initialize(max_size: 50) ⇒ XmiParseCache
constructor
A new instance of XmiParseCache.
Constructor Details
#initialize(max_size: 50) ⇒ XmiParseCache
Returns a new instance of XmiParseCache.
13 14 15 16 |
# File 'lib/metanorma/plugin/lutaml/xmi_parse_cache.rb', line 13 def initialize(max_size: 50) @parse_cache = CacheStore.new(max_size: max_size) @drop_cache = CacheStore.new(max_size: max_size) end |
Instance Method Details
#clear ⇒ Object
40 41 42 43 |
# File 'lib/metanorma/plugin/lutaml/xmi_parse_cache.rb', line 40 def clear @parse_cache.clear @drop_cache.clear end |
#fetch(full_path) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/metanorma/plugin/lutaml/xmi_parse_cache.rb', line 18 def fetch(full_path) @parse_cache.fetch_or_store(full_path) do xmi_model = ::Xmi::Sparx::Root.parse_xml(File.read(full_path)) parser = ::Lutaml::Xmi::Parsers::Xml.new uml_document = parser.parse(xmi_model) ParsedXmi.new( parser: parser, uml_document: uml_document, drop_options: (parser), ) end end |
#fetch_drop(full_path, guidance: nil) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/metanorma/plugin/lutaml/xmi_parse_cache.rb', line 31 def fetch_drop(full_path, guidance: nil) parsed = fetch(full_path) @drop_cache.fetch_or_store([full_path, guidance]) do ::Lutaml::Xmi::LiquidDrops::RootDrop.new( parsed.uml_document, guidance, parsed. ) end end |