Module: Ea::Cli::Command::RepositoryBuilder
- Included in:
- Diagrams
- Defined in:
- lib/ea/cli/command/repository_builder.rb
Overview
Shared helper for building a Lutaml::UmlRepository::Repository
from any file format supported by Ea::Transformations.
Single source of truth for "QEA/XMI/LUR → Repository" wiring.
Used by Ea::Cli::Command::Diagrams (extract action) and
Ea::Cli::Command::Spa (SPA generation).
.lur files take the fast path via Repository.from_file (the
native LUR loader). QEA/XMI files are parsed via
Ea::Transformations.parse and wrapped via
Repository.from_document.
Constant Summary collapse
- LUR_EXT =
".lur".freeze
Class Method Summary collapse
- .build_repository(path) ⇒ Lutaml::UmlRepository::Repository
- .lur?(path) ⇒ Boolean
-
.require_lutaml_uml! ⇒ Object
Loads the bridge gem.
- .require_lutaml_uml_repository! ⇒ Object
Class Method Details
.build_repository(path) ⇒ Lutaml::UmlRepository::Repository
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ea/cli/command/repository_builder.rb', line 24 def build_repository(path) require_lutaml_uml! if lur?(path) require_lutaml_uml_repository! return Lutaml::UmlRepository::Repository.from_file(path) end document = Ea::Transformations.parse(path) require_lutaml_uml_repository! Lutaml::UmlRepository::Repository.from_document(document) end |
.lur?(path) ⇒ Boolean
37 38 39 |
# File 'lib/ea/cli/command/repository_builder.rb', line 37 def lur?(path) File.extname(path).downcase == LUR_EXT end |
.require_lutaml_uml! ⇒ Object
Loads the bridge gem. The lutaml-uml gem is an optional dependency; if missing, raise the CLI's MissingUmlDependency so the user gets a clear message about installing it.
44 45 46 47 48 49 50 51 |
# File 'lib/ea/cli/command/repository_builder.rb', line 44 def require_lutaml_uml! require "lutaml/uml" rescue LoadError => e raise Ea::Cli::MissingUmlDependency, "spa and diagrams-extract commands require the " \ "`lutaml-uml` gem. Install it via `gem install lutaml-uml` " \ "or add it to your Gemfile. (#{e.})" end |
.require_lutaml_uml_repository! ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/ea/cli/command/repository_builder.rb', line 53 def require_lutaml_uml_repository! require "lutaml/uml_repository" rescue LoadError => e raise Ea::Cli::MissingUmlDependency, "spa and diagrams-extract commands require the " \ "`lutaml-uml` gem. Install it via `gem install lutaml-uml` " \ "or add it to your Gemfile. (#{e.})" end |