diff --git a/.github/workflows/rake.yml b/.github/workflows/rake.yml deleted file mode 100644 index 7c59a51..0000000 --- a/.github/workflows/rake.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Auto-generated by Cimas: Do not edit it manually! -# See https://github.com/metanorma/cimas -name: rake - -on: - push: - branches: [ master, main ] - tags: [ v* ] - pull_request: - -jobs: - rake: - uses: metanorma/ci/.github/workflows/graphviz-rake.yml@main - secrets: - pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index badaba3..aa6ca31 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,3 +19,4 @@ jobs: secrets: rubygems-api-key: ${{ secrets.LUTAML_CI_RUBYGEMS_API_KEY }} pat_token: ${{ secrets.LUTAML_CI_PAT_TOKEN }} + diff --git a/.gitignore b/.gitignore deleted file mode 100644 index cbe6612..0000000 --- a/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/.bundle/ -/.yardoc -/_yardoc/ -/coverage/ -/doc/ -/pkg/ -/spec/reports/ -/tmp/ - -# rspec failure tracking -.rspec_status -Gemfile.lock diff --git a/.rspec b/.rspec deleted file mode 100644 index 34c5164..0000000 --- a/.rspec +++ /dev/null @@ -1,3 +0,0 @@ ---format documentation ---color ---require spec_helper diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 41e7e49..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,74 +0,0 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of experience, -nationality, personal appearance, race, religion, or sexual identity and -orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or -advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at ronald.tse@ribose.com. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [https://contributor-covenant.org/version/1/4][version] - -[homepage]: https://contributor-covenant.org -[version]: https://contributor-covenant.org/version/1/4/ diff --git a/Gemfile b/Gemfile index 4256133..354d102 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,4 @@ -# frozen_string_literal: true - source "https://rubygems.org" -ruby ">= 2.7" - -# Specify your gem's dependencies in lutaml-uml.gemspec gemspec - -gem "rake", "~> 12.0" +gem "rake" diff --git a/LUTAML.adoc b/LUTAML.adoc deleted file mode 100644 index 769f13e..0000000 --- a/LUTAML.adoc +++ /dev/null @@ -1,372 +0,0 @@ -= LutaML syntax - -== `diagram` syntax - -`diagram` is a root element for each diagram. - -[source,java] ----- -diagram MyView { - title "My diagram" - caption "My custom caption" - fontname "Helvetica" -} ----- - -where: - -* `fontname` - optional, configuration option to use supplied font name -* `title` - optional, set custom title for diagram -* `caption` - optional, set custom caption for diagram - -== DataTypes - -Lutaml supports 3 types of data_types: `data_type`, `primitive` and `enum`. - -Example of data types declaration: - -[source,java] ----- -diagram MyView { - enum MyEnum {} - - enum AddressClassProfile { - +addressClassProfile: CharacterString - } - - data_type "Banking Information" { - "art code" - "CCT Number" - } - - primitive Integer - - enum Profile { - imlicistAttributeProfile: CharacterString - +attributeProfile: CharacterString - -privateAttributeProfile: CharacterString - ~friendlyAttributeProfile: CharacterString - #protectedAttributeProfile: CharacterString - } -} ----- - -== Associations - -=== Explicit declaration - -Syntax: - -[source,java] ----- -association name { - owned_type association|composition|aggregation|generalization|uses - member_type association|composition|aggregation|generalization|uses - owned association_name[#attribute_name] [{property_string}][cardinality] - member association_name[#attribute_name] [{property_string}][cardinality] -} ----- - -where: - -* `owned_type` - optional, use to define a bidirectional association (`association`|`composition`|`aggregation`|`generalization`|`uses`) -* `member_type` - association type (`association`|`composition`|`aggregation`|`generalization`|`uses`) -* `owned|member` - end of association, use `\#attribute_name` to set a role name -* `property_string` - property string for attibutes associations -* `cardinality` - examples: '1..*', '*' - -Example: - -[source,java] ----- -class Association { - +association: -} -class Type { - +endType: -} - -association AssociatingTypeAndAssociation { - type uses - from Association#+association {subsets relationship}[*] - to Type#+/endType {readOnly, subsets relatedElement} [1..*] -} ----- - -=== Undirected associations - -The simplest way to define relationship between two classes is to use `generalize` keyword: - -[source,java] ----- -class Pet {} -class Cat { - generalize Pet -} ----- - -=== Attribute relationship - -Derived attribute `relatedElement` can have 1 to many `Element` associated with it through `union` - -[source,java] ----- -class Relationship { - +/relatedElement: Element[1..*] {union} -} -class Element {} ----- - -== Class' multiline "definition" property - -=== Definition - -Full syntax: - -[source,java] ----- -definition { - inner text -} ----- - - -== Attributes/entries - -=== Definition - -Full syntax: - -[source,java] ----- -[visibility][/][attribute] name [:type][multiplicity][=initial value][{attribute body}] ----- - -where: - -* `visibility` can be equal to -** `-`: private -** `+`: public -** `#`: protected -** `~`: friendly - -* `attribute` - attrbute keyword -* `/` - symbolizes a derived attribute. -* `multiplicity` - Multiplicity is in square brackets (e.g. [1..*]). -* `initial value` - Default value specifies the initial value of the attribute. -* `{attribute body}` - Body of attribute, additional properties for attribute - - -One can use explicit or implicit syntax for attribute definition - -explicit syntax: - -[source,java] ----- -class A { - attribute my_attribute -} - -enum A { - entry my_val2 -} ----- - -implicit syntax: - -[source,java] ----- -class A { - my_attribute -} - -enum A { - my_val2 -} ----- - -[[attribute-visibility]] -=== Attribute visibility - -Syntax for defining visibility: `[+|-|#|~] [attribute] attribute_name`. - -LutaML uses these modificators to define attribute (entry) visbility: - -`+`:: public -`-`:: private -`#`:: protected -`~`:: package - -example: - -[source,java] ----- -class Figure { - // Public attribute `radius` - + radius - // private attribute `filled` - - filled - // protected attribute `length` - # length -} ----- - -=== Additional attribute' properties - -example: - -[source,java] ----- -class Figure { - + radius { - definition { - Radius of the Figure - } - } -} ----- - -== Methods - -Syntax for defining methods: - -[source,java] ----- -[visbility] method-name (parameter-list): return type {property-modifier} ----- - -where: - -* `visibility` can be equal to -** `-`: private -** `+`: public -** `#`: protected -** `~`: friendly - -* `parameter-list`: parameter list - -* `property-modifier`: can be equal to -** `redefines` -** `query` -** `ordered` (defaults to `unordered`) -** `unique`(defaults to `nonunique`) - -Syntax for a `parameter-list`: - -[source,java] ----- -[direction] name:type [multiplicity] [=default] [{property string}] ----- - -where: - -* `direction` can be equal to -** `in` -** `out` -** `inout` -** `return` - -== import files - -Use `include` special word: - -[source,java] ----- -include path/to/file ----- - -== Package syntax - -Namespaces - -A named element is an element that can have a name and a defined visibility (public, private, protected, package): - -[source,java] ----- -+ => public -- => private -# => protected -~ => package ----- - -The name of the element and its visibility are optional. - -[source,java] ----- -package Customers { - class Insurance {} - - class PrivateInsurance {} - # class ProtectedInsurance {} -} ----- - -== Code comments - -Use `//` notation for LutaML comments skipped by parser, example: - -[source,java] ----- -// TODO: implement -abstract class Pet {} ----- - -== Comment objects diagram - -Use `\**`(one line comment) or `*| |*`(multiline comment) to create comment object for diagram entry. - -If this syntax is used inside a `class`/`enum`/`association` block, it will be created for owner of this block. - -[source,java] ----- -** I am a document comment - -*| - This is a - multiply - lines document comment. -*| - -class A -enum B { - ** one line enum comment - foo - *| - This is a - multiply - lines class comment. - *| - bar -} ----- - -== Syntax comments - -Use `//` to create syntax comment, chars after `//` will be ignored during processing. - -[source,java] ----- -// TODO: attributes -class A -enum B { - // Write docs - foo - bar -} ----- - -== Value specification - -A value specification indicates one or several values in a model. Examples for value specifications include simple, mathematical expressions, such as `4+2`, and expressions with values from the object model, `Integer::MAX_INT-1` - -[source,java] ----- -class {Class name, if any} {as ref name, optional} { - {attribute name} = {attribute value} - {attribute name}:{attribute class} = {attribute value} -} - -instance :{Class name, if any} {as ref name, optional} { - {attribute name} = {attribute value} - {attribute name}:{attribute class} = {attribute value} -} ----- diff --git a/README.adoc b/README.adoc index bcb602a..7da419a 100644 --- a/README.adoc +++ b/README.adoc @@ -1,44 +1,6 @@ -# Lutaml::Uml += lutaml-uml -image:https://badge.fury.io/rb/lutaml-uml.svg["Gem Version", link="https://badge.fury.io/rb/lutaml-uml"] +This repository has been merged into LutaML. See: -image:https://github.com/lutaml/lutaml-uml/actions/workflows/macos.yml/badge.svg["macos", link="https://github.com/lutaml/lutaml-uml/actions/workflows/macos.yml"] -image:https://github.com/lutaml/lutaml-uml/actions/workflows/ubuntu.yml/badge.svg["ubuntu", link="https://github.com/lutaml/lutaml-uml/actions/workflows/ubuntu.yml"] -image:https://github.com/lutaml/lutaml-uml/actions/workflows/windows.yml/badge.svg["windows", link="https://github.com/lutaml/lutaml-uml/actions/workflows/windows.yml"] - -Lutaml is a language for specifying UML class diagrams and a tool for converting it into various different formats. - -## Install - -### Bundler: `gem "lutaml-uml"` - -### RubyGems: `gem install lutaml-uml` - -## Language - -See link:LUTAML.adoc[LUTAML.adoc] - -## Usage - -Converter executables are available: - -* PlantUML WSD to LutaML UML: `lutaml-wsd2uml` -* LutaML YAML to LutaML UML: `lutaml-yaml2uml` - -EXAMPLE: `lutaml-wsd2uml mn/metanorma-model-standoc/models/StandardDoc_Blocks_New.wsd` - - -## Development - -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. - -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). - -## Contributing - -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lutaml-uml. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/lutaml-uml/blob/master/CODE_OF_CONDUCT.md). - - -## Code of Conduct - -Everyone interacting in the Lutaml::Uml project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lutaml-uml/blob/master/CODE_OF_CONDUCT.md). +* https://github.com/lutaml/lutaml/ +* https://github.com/lutaml/lutaml/tree/main/lib/lutaml/uml diff --git a/Rakefile b/Rakefile index b6ae734..5263b58 100644 --- a/Rakefile +++ b/Rakefile @@ -1,8 +1,3 @@ # frozen_string_literal: true require "bundler/gem_tasks" -require "rspec/core/rake_task" - -RSpec::Core::RakeTask.new(:spec) - -task default: :spec diff --git a/bin/console b/bin/console deleted file mode 100755 index 5b31ccf..0000000 --- a/bin/console +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -require "bundler/setup" -require "lutaml/uml" - -# You can add fixtures and/or initialization code here to make experimenting -# with your gem easier. You can also use a different console, if you like. - -# (If you use this, don't forget to add pry to your Gemfile!) -# require "pry" -# Pry.start - -require "irb" -IRB.start(__FILE__) diff --git a/bin/folder_yaml2lutaml.sh b/bin/folder_yaml2lutaml.sh deleted file mode 100755 index 3346126..0000000 --- a/bin/folder_yaml2lutaml.sh +++ /dev/null @@ -1,6 +0,0 @@ -script_full_path=$(dirname "$0") - -for i in $1/*.yml -do -$script_full_path/yaml2lutaml $i > "$1/$(basename -s .yml $i).lutaml" -done \ No newline at end of file diff --git a/bin/plantuml2lutaml b/bin/plantuml2lutaml deleted file mode 100755 index 3608e91..0000000 --- a/bin/plantuml2lutaml +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# Script to convert plantuml files into LutaML syntax -# Usage: bin/plantuml2lutaml /path/to/plantuml.wsd - -file_path = ARGV[0] -FILE_NAME = File.basename(file_path, ".wsd") -wsd_file = File.new(ARGV[0]) - -def sync_puts(line, level = 0) - $stdout.puts("#{''.rjust(level)}#{line}") - $stdout.flush -end - -SKIPPED_LINES_REGEXP = /^(@startuml|'\*{7}|note|@enduml|\!|'\/)/ -COMMENT_START = /\/'/ -COMMENT_END = /'\// -ASSOCIATION_MAPPINGS = { - /-\|>/ => ",inheritance", - /<\|-/ => "inheritance,", - /->/ => ",direct", - /<-/ => "direct,", -}.freeze - -in_comment_block = false - -def transform_line(line) - line = line.gsub(/^\s*'/, '** ').gsub(/\|[\sa-zA-Z]+$/, '') - return sync_puts(line, 2) if ASSOCIATION_MAPPINGS.keys.none? { |key| line =~ key } - - owner_type, member_type = ASSOCIATION_MAPPINGS.detect { |(key, _value)| line =~ key }.last.split(",") - blocks = line.split(" ") - owner = blocks.first - member = blocks.last - sync_puts("association {", 2) - sync_puts("owner #{owner}", 4) - sync_puts("member #{member}", 4) - sync_puts("owner_type #{owner_type}", 4) if !owner_type.to_s.empty? - sync_puts("member_type #{member_type}", 4) if !member_type.to_s.empty? - sync_puts("}", 2) -end - -sync_puts("diagram #{FILE_NAME} {") -wsd_file.readlines.each do |line| - if line.match?(COMMENT_START) - in_comment_block = true - end - - if line.match?(COMMENT_END) - in_comment_block = false - end - - next if in_comment_block || line =~ SKIPPED_LINES_REGEXP - - transform_line(line) -end -sync_puts("}") diff --git a/bin/setup b/bin/setup deleted file mode 100755 index dce67d8..0000000 --- a/bin/setup +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail -IFS=$'\n\t' -set -vx - -bundle install - -# Do any other automated setup that you need to do here diff --git a/bin/yaml2lutaml b/bin/yaml2lutaml deleted file mode 100755 index 50f27f0..0000000 --- a/bin/yaml2lutaml +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# Script to convert datamodel yaml files into LutaML syntax -# Usage: bin/yaml2lutaml /path/to/datamodel/view/file.yml - -require "yaml" - -view_yaml = YAML.safe_load(File.read(ARGV[0])) -models_path = File.expand_path("../../models", ARGV[0]) - -def sync_puts(line, level = 0) - $stdout.puts("#{''.rjust(level)}#{line}") - $stdout.flush -end - -encountered_relations = Hash.new { |h, key| h[key] = [] } -# relations: -# - target: AttributeProfile -# relationship: -# source: -# type: aggregation -# attribute: -# addressClassProfile: -# target: -# type: direct -# attribute: -# attributeProfile: -# cardinality: -# min: 0 -# max: '*' -def process_association(owner, values, encountered_relations) - target_name = values["target"] - return if encountered_relations[owner].include?(target_name) - - encountered_relations[owner].push(target_name) - sync_puts("association {", 2) - - relationship_block = values["relationship"] || {} - - if relationship_block["source"] && relationship_block["source"]["type"] - source = relationship_block["source"] - sync_puts("owner_type #{source['type']}", 4) - if source["attribute"] - source_attribute_name = source["attribute"].keys.first - owner += "##{source_attribute_name}" - if source["attribute"][source_attribute_name] && source["attribute"][source_attribute_name]["cardinality"] - cardinality = source["attribute"][source_attribute_name]["cardinality"] - owner += " [#{cardinality['min']}..#{cardinality['max']}]" - end - end - end - sync_puts("owner #{owner}", 4) - - member = target_name - if relationship_block["target"] - target = relationship_block["target"] - type = target["type"] || "direct" - sync_puts("member_type #{type}", 4) - if target["attribute"] - target_attribute_name = target["attribute"].keys.first - member += "##{target_attribute_name}" - if target["attribute"][target_attribute_name] && target["attribute"][target_attribute_name]["cardinality"] - cardinality = target["attribute"][target_attribute_name]["cardinality"] - member += " [#{cardinality['min']}..#{cardinality['max']}]" - end - end - else - sync_puts("member_type direct", 4) - end - sync_puts("member #{member}", 4) - - sync_puts("}", 2) -end -sync_puts("diagram #{File.basename(ARGV[0], 'yml')[0..-2]} {") -sync_puts("title '#{view_yaml['title']}'", 2) -sync_puts("caption '#{view_yaml['caption']}'", 2) - -# Class associations notations -view_yaml["relations"]&.each do |values| - process_association(values["source"], values, encountered_relations) -end - -view_yaml["imports"].keys.each do |entry| - import = YAML.safe_load(File.read(File.join(models_path, "#{entry}.yml"))) - import_name = import["name"] || File.basename(entry) - # Class notation - sync_puts("#{import['modelType']} #{import_name} {", 2) - if import["definition"] - definition = <<~TEXT - definition { - #{import['definition']} - } - TEXT - sync_puts(definition, 4) - end - import["values"]&.each_pair do |key, values| - result_string = key - if values["definition"] - result_string += <<~TEXT - { - definition { - #{values['definition']} - } - } - TEXT - end - sync_puts(result_string, 4) - end - import["attributes"]&.each_pair do |key, values| - definition = values["definition"] - cardinality = if values["cardinality"] - cardinality_val = values["cardinality"] - "[#{cardinality_val['min']}..#{cardinality_val['max']}]" - else - "" - end - result_string = "+#{key}" - if values["type"] - result_string += ": #{values['type']}" - end - if cardinality - result_string += " #{cardinality}" - end - if definition - result_string += <<~TEXT - { - definition - #{definition} - end definition - } - TEXT - end - sync_puts(result_string, 4) - end - sync_puts("}", 2) - - # Associations notations - import["relations"]&.each do |values| - process_association(import_name, values, encountered_relations) - end -end -sync_puts("}") diff --git a/exe/lutaml-wsd2uml b/exe/lutaml-wsd2uml deleted file mode 100755 index 8a95499..0000000 --- a/exe/lutaml-wsd2uml +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# Script to convert plantuml files into LutaML syntax -# Usage: bin/plantuml2lutaml /path/to/plantuml.wsd - -file_path = ARGV[0] -FILE_NAME = File.basename(file_path, ".wsd") -wsd_file = File.new(ARGV[0]) - -def sync_puts(line, level = 0) - $stdout.puts("#{''.rjust(level)}#{line}") - $stdout.flush -end - -SKIPPED_LINES_REGEXP = /^(@startuml|'\*{7}|note|@enduml|\!|'\/)/ -COMMENT_START = /\/'/ -COMMENT_END = /'\// -ASSOCIATION_MAPPINGS = { - /-\|>/ => ",inheritance", - /<\|-/ => "inheritance,", - /->/ => ",direct", - /<-/ => "direct,", -}.freeze - -in_comment_block = false - -def transform_line(line) - line = line.gsub(/^\s*'/, '** ').gsub(/\|[\sa-zA-Z]+$/, '').gsub(/\r/, '') - return sync_puts(line, 2) if ASSOCIATION_MAPPINGS.keys.none? { |key| line =~ key } - - owner_type, member_type = ASSOCIATION_MAPPINGS.detect { |(key, _value)| line =~ key }.last.split(",") - blocks = line.split(" ") - owner = blocks.first - member = blocks.last - sync_puts("association {", 2) - sync_puts("owner #{owner}", 4) - sync_puts("member #{member}", 4) - sync_puts("owner_type #{owner_type}", 4) if !owner_type.to_s.empty? - sync_puts("member_type #{member_type}", 4) if !member_type.to_s.empty? - sync_puts("}", 2) -end - -sync_puts("diagram #{FILE_NAME} {") -wsd_file.readlines.each do |line| - if line.match?(COMMENT_START) - in_comment_block = true - end - - if line.match?(COMMENT_END) - in_comment_block = false - end - - next if in_comment_block || line =~ SKIPPED_LINES_REGEXP - - transform_line(line) -end -sync_puts("}") diff --git a/exe/lutaml-yaml2uml b/exe/lutaml-yaml2uml deleted file mode 100755 index 50f27f0..0000000 --- a/exe/lutaml-yaml2uml +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env ruby -# frozen_string_literal: true - -# -# Script to convert datamodel yaml files into LutaML syntax -# Usage: bin/yaml2lutaml /path/to/datamodel/view/file.yml - -require "yaml" - -view_yaml = YAML.safe_load(File.read(ARGV[0])) -models_path = File.expand_path("../../models", ARGV[0]) - -def sync_puts(line, level = 0) - $stdout.puts("#{''.rjust(level)}#{line}") - $stdout.flush -end - -encountered_relations = Hash.new { |h, key| h[key] = [] } -# relations: -# - target: AttributeProfile -# relationship: -# source: -# type: aggregation -# attribute: -# addressClassProfile: -# target: -# type: direct -# attribute: -# attributeProfile: -# cardinality: -# min: 0 -# max: '*' -def process_association(owner, values, encountered_relations) - target_name = values["target"] - return if encountered_relations[owner].include?(target_name) - - encountered_relations[owner].push(target_name) - sync_puts("association {", 2) - - relationship_block = values["relationship"] || {} - - if relationship_block["source"] && relationship_block["source"]["type"] - source = relationship_block["source"] - sync_puts("owner_type #{source['type']}", 4) - if source["attribute"] - source_attribute_name = source["attribute"].keys.first - owner += "##{source_attribute_name}" - if source["attribute"][source_attribute_name] && source["attribute"][source_attribute_name]["cardinality"] - cardinality = source["attribute"][source_attribute_name]["cardinality"] - owner += " [#{cardinality['min']}..#{cardinality['max']}]" - end - end - end - sync_puts("owner #{owner}", 4) - - member = target_name - if relationship_block["target"] - target = relationship_block["target"] - type = target["type"] || "direct" - sync_puts("member_type #{type}", 4) - if target["attribute"] - target_attribute_name = target["attribute"].keys.first - member += "##{target_attribute_name}" - if target["attribute"][target_attribute_name] && target["attribute"][target_attribute_name]["cardinality"] - cardinality = target["attribute"][target_attribute_name]["cardinality"] - member += " [#{cardinality['min']}..#{cardinality['max']}]" - end - end - else - sync_puts("member_type direct", 4) - end - sync_puts("member #{member}", 4) - - sync_puts("}", 2) -end -sync_puts("diagram #{File.basename(ARGV[0], 'yml')[0..-2]} {") -sync_puts("title '#{view_yaml['title']}'", 2) -sync_puts("caption '#{view_yaml['caption']}'", 2) - -# Class associations notations -view_yaml["relations"]&.each do |values| - process_association(values["source"], values, encountered_relations) -end - -view_yaml["imports"].keys.each do |entry| - import = YAML.safe_load(File.read(File.join(models_path, "#{entry}.yml"))) - import_name = import["name"] || File.basename(entry) - # Class notation - sync_puts("#{import['modelType']} #{import_name} {", 2) - if import["definition"] - definition = <<~TEXT - definition { - #{import['definition']} - } - TEXT - sync_puts(definition, 4) - end - import["values"]&.each_pair do |key, values| - result_string = key - if values["definition"] - result_string += <<~TEXT - { - definition { - #{values['definition']} - } - } - TEXT - end - sync_puts(result_string, 4) - end - import["attributes"]&.each_pair do |key, values| - definition = values["definition"] - cardinality = if values["cardinality"] - cardinality_val = values["cardinality"] - "[#{cardinality_val['min']}..#{cardinality_val['max']}]" - else - "" - end - result_string = "+#{key}" - if values["type"] - result_string += ": #{values['type']}" - end - if cardinality - result_string += " #{cardinality}" - end - if definition - result_string += <<~TEXT - { - definition - #{definition} - end definition - } - TEXT - end - sync_puts(result_string, 4) - end - sync_puts("}", 2) - - # Associations notations - import["relations"]&.each do |values| - process_association(import_name, values, encountered_relations) - end -end -sync_puts("}") diff --git a/lib/lutaml/layout/engine.rb b/lib/lutaml/layout/engine.rb deleted file mode 100644 index 7ebfe1d..0000000 --- a/lib/lutaml/layout/engine.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - class Engine - attr_accessor :input - - def initialize(input:) - @input = input - end - - def render(_type) - raise ArgumentError, "Implement render method" - end - end -end diff --git a/lib/lutaml/layout/graph_viz_engine.rb b/lib/lutaml/layout/graph_viz_engine.rb deleted file mode 100644 index adcba10..0000000 --- a/lib/lutaml/layout/graph_viz_engine.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -require "ruby-graphviz" -require "lutaml/layout/engine" - -module Lutaml - module Layout - class GraphVizEngine < Engine - def render(type) - Open3.popen3("dot -T#{type}") do |stdin, stdout, _stderr, _wait| - stdin.puts(input) - stdin.close - # unless (err = stderr.read).empty? then raise err end - stdout.read - end - end - end - end -end diff --git a/lib/lutaml/uml.rb b/lib/lutaml/uml.rb deleted file mode 100644 index cd99c48..0000000 --- a/lib/lutaml/uml.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/version" -require "lutaml/uml/parsers/dsl" -require "lutaml/uml/parsers/yaml" -require "lutaml/uml/parsers/attribute" -require "lutaml/uml/formatter" - -module Lutaml - module Uml - class Error < StandardError; end - end -end diff --git a/lib/lutaml/uml/abstraction.rb b/lib/lutaml/uml/abstraction.rb deleted file mode 100644 index 7f6bd4a..0000000 --- a/lib/lutaml/uml/abstraction.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class Abstraction < Dependency - end - end -end diff --git a/lib/lutaml/uml/activity.rb b/lib/lutaml/uml/activity.rb deleted file mode 100644 index 8450e69..0000000 --- a/lib/lutaml/uml/activity.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class Activity < Behavior - end - end -end diff --git a/lib/lutaml/uml/actor.rb b/lib/lutaml/uml/actor.rb deleted file mode 100644 index 7a4d4a0..0000000 --- a/lib/lutaml/uml/actor.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## - -module Lutaml - module Uml - class Actor < Classifier - def initialize - @name = nil - @xmi_id = nil - @stereotype = [] - @generalization = [] - @namespace = nil - end - end - end -end diff --git a/lib/lutaml/uml/association.rb b/lib/lutaml/uml/association.rb deleted file mode 100644 index 10fe554..0000000 --- a/lib/lutaml/uml/association.rb +++ /dev/null @@ -1,43 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class Association < TopElement - include HasMembers - - attr_accessor :owner_end, - :owner_end_attribute_name, - :owner_end_cardinality, - :owner_end_type, - :owner_end_xmi_id, - :member_end, - :member_end_attribute_name, - :member_end_xmi_id, - :member_end_cardinality, - :member_end_type, - :static, - :action - - # TODO: move to Parslet::Transform - def members=(value) - value.group_by { |member| member.keys.first } - .each do |(type, group)| - if %w[owner_end member_end].include?(type) - group.each do |member| - member.each_pair do |key, member_value| - public_send("#{associtaion_type(key)}=", member_value) - end - end - next - end - attribute_value = group.map(&:values).flatten - if attribute_value.length == 1 && !attribute_value.first.is_a?(Hash) - next public_send("#{associtaion_type(type)}=", attribute_value.first) - end - - public_send("#{associtaion_type(type)}=", attribute_value) - end - end - end - end -end diff --git a/lib/lutaml/uml/behavior.rb b/lib/lutaml/uml/behavior.rb deleted file mode 100644 index 09620eb..0000000 --- a/lib/lutaml/uml/behavior.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class Behavior < Class - end - end -end diff --git a/lib/lutaml/uml/class.rb b/lib/lutaml/uml/class.rb deleted file mode 100644 index 669cee5..0000000 --- a/lib/lutaml/uml/class.rb +++ /dev/null @@ -1,83 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/classifier" - -require "lutaml/uml/has_members" -require "lutaml/uml/association" -require "lutaml/uml/constraint" -require "lutaml/uml/data_type" -require "lutaml/uml/operation" -require "lutaml/uml/top_element_attribute" - -module Lutaml - module Uml - class Class < Classifier - include HasMembers - - attr_accessor :nested_classifier, - :is_abstract, - :type, - :package - - attr_reader :associations, - :attributes, - :members, - :modifier, - :constraints, - :operations, - :data_types - - def initialize(attributes = {}) - @nested_classifier = [] - @stereotype = [] - @generalization = [] - @is_abstract = false - super - end - - def modifier=(value) - @modifier = value.to_s # TODO: Validate? - end - - def attributes=(value) - @attributes = value.to_a.map do |attr| - TopElementAttribute.new(attr) - end - end - - def associations=(value) - @associations = value.to_a.map do |attr| - Association.new(attr.to_h.merge(owner_end: name)) - end - end - - def constraints=(value) - @constraints = value.to_a.map do |attr| - Constraint.new(attr) - end - end - - def operations=(value) - @operations = value.to_a.map do |attr| - Operation.new(attr) - end - end - - def data_types=(value) - @data_types = value.to_a.map do |attr| - DataType.new(attr) - end - end - - def methods - # @members&.select { |member| member.class == Method } - [] - end - - def relationships - # @members&.select { |member| member.class == ClassRelationship } - [] - end - end - end -end diff --git a/lib/lutaml/uml/classifier.rb b/lib/lutaml/uml/classifier.rb deleted file mode 100644 index 3dd09ed..0000000 --- a/lib/lutaml/uml/classifier.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/top_element" - -module Lutaml - module Uml - class Classifier < TopElement - attr_accessor :generalization - end - end -end diff --git a/lib/lutaml/uml/connector.rb b/lib/lutaml/uml/connector.rb deleted file mode 100644 index 96a8cd1..0000000 --- a/lib/lutaml/uml/connector.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class Connector < TopElement - attr_accessor :kind, :connector_end - - def initialize - @name = nil - @xmi_id = nil - @xmi_uuid = nil - @connector_end = [] - @namespace = nil - @kind = nil - end - end - end -end diff --git a/lib/lutaml/uml/constraint.rb b/lib/lutaml/uml/constraint.rb deleted file mode 100644 index fc11e90..0000000 --- a/lib/lutaml/uml/constraint.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class Constraint < TopElement - attr_accessor :body - end - end -end diff --git a/lib/lutaml/uml/constructor_end.rb b/lib/lutaml/uml/constructor_end.rb deleted file mode 100644 index f8cd5fe..0000000 --- a/lib/lutaml/uml/constructor_end.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class ConnectorEnd < TopElement - attr_accessor :role, :part_with_port, :connector - - def initialize - @role = nil - end - end - end -end diff --git a/lib/lutaml/uml/data_type.rb b/lib/lutaml/uml/data_type.rb deleted file mode 100644 index 92ca7db..0000000 --- a/lib/lutaml/uml/data_type.rb +++ /dev/null @@ -1,75 +0,0 @@ -# frozen_string_literal: true -require "lutaml/uml/classifier" - -module Lutaml - module Uml - class DataType < Classifier - include HasMembers - - attr_accessor :nested_classifier, - :is_abstract, - :type - - attr_reader :associations, - :attributes, - :members, - :modifier, - :constraints, - :operations, - :data_types - - def initialize(attributes = {}) - @nested_classifier = [] - @stereotype = [] - @generalization = [] - @is_abstract = false - super - @keyword = "dataType" - end - - def modifier=(value) - @modifier = value.to_s # TODO: Validate? - end - - def attributes=(value) - @attributes = value.to_a.map do |attr| - TopElementAttribute.new(attr) - end - end - - def associations=(value) - @associations = value.to_a.map do |attr| - Association.new(attr.to_h.merge(owner_end: name)) - end - end - - def constraints=(value) - @constraints = value.to_a.map do |attr| - Constraint.new(attr) - end - end - - def operations=(value) - @operations = value.to_a.map do |attr| - Operation.new(attr) - end - end - - def data_types=(value) - @data_types = value.to_a.map do |attr| - DataType.new(attr) - end - end - - def methods - # @members&.select { |member| member.class == Method } - [] - end - - def relationships - # @members&.select { |member| member.class == ClassRelationship } - [] - end - end - end -end diff --git a/lib/lutaml/uml/dependency.rb b/lib/lutaml/uml/dependency.rb deleted file mode 100644 index 5e4525e..0000000 --- a/lib/lutaml/uml/dependency.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class Dependency < TopElement - attr_accessor :client, :supplier - - def initialize - @name = nil - @xmi_id = nil - @xmi_uuid = nil - @client = [] - @supplier = [] - @namespace = nil - end - end - end -end diff --git a/lib/lutaml/uml/diagram.rb b/lib/lutaml/uml/diagram.rb deleted file mode 100644 index 7255602..0000000 --- a/lib/lutaml/uml/diagram.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class Diagram < TopElement - end - end -end diff --git a/lib/lutaml/uml/document.rb b/lib/lutaml/uml/document.rb deleted file mode 100644 index 5627ff5..0000000 --- a/lib/lutaml/uml/document.rb +++ /dev/null @@ -1,81 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/class" -require "lutaml/uml/data_type" -require "lutaml/uml/enum" -require "lutaml/uml/diagram" -require "lutaml/uml/package" -require "lutaml/uml/primitive_type" - -module Lutaml - module Uml - class Document - include HasAttributes - include HasMembers - - attr_accessor :name, - :title, - :caption, - :groups, - :fidelity, - :fontname, - :comments - attr_reader :packages - - # rubocop:disable Rails/ActiveRecordAliases - def initialize(attributes = {}) - update_attributes(attributes) - end - # rubocop:enable Rails/ActiveRecordAliases - def classes=(value) - @classes = value.to_a.map { |attributes| Class.new(attributes) } - end - - def data_types=(value) - @data_types = value.to_a.map { |attributes| DataType.new(attributes) } - end - - def enums=(value) - @enums = value.to_a.map { |attributes| Enum.new(attributes) } - end - - def packages=(value) - @packages = value.to_a.map { |attributes| Package.new(attributes) } - end - - def primitives=(value) - @primitives = value.to_a.map { |attributes| PrimitiveType.new(attributes) } - end - - def associations=(value) - @associations = value.to_a.map do |attributes| - Association.new(attributes) - end - end - - def classes - @classes || [] - end - - def enums - @enums || [] - end - - def data_types - @data_types || [] - end - - def packages - @packages || [] - end - - def primitives - @primitives || [] - end - - def associations - @associations || [] - end - end - end -end diff --git a/lib/lutaml/uml/enum.rb b/lib/lutaml/uml/enum.rb deleted file mode 100644 index 7911490..0000000 --- a/lib/lutaml/uml/enum.rb +++ /dev/null @@ -1,45 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/has_members" -require "lutaml/uml/classifier" -require "lutaml/uml/association" -require "lutaml/uml/top_element_attribute" -require "lutaml/uml/value" - -module Lutaml - module Uml - class Enum < Classifier - include HasMembers - - attr_reader :attributes, - :members, - :modifier, - :definition, - :keyword, - :values - - def initialize(attributes = {}) - super - @keyword = "enumeration" - end - - # TODO: delete? - def attributes=(value) - @attributes = value.to_a.map do |attr| - TopElementAttribute.new(attr) - end - end - - def values=(value) - @values = value.to_a.map do |attr| - Value.new(attr) - end - end - - # TODO: reserved name, change - def methods - [] - end - end - end -end diff --git a/lib/lutaml/uml/event.rb b/lib/lutaml/uml/event.rb deleted file mode 100644 index b4d222d..0000000 --- a/lib/lutaml/uml/event.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## - -module Lutaml - module Uml - class Event < TopElement - end - end -end diff --git a/lib/lutaml/uml/final_state.rb b/lib/lutaml/uml/final_state.rb deleted file mode 100644 index f7d0c1b..0000000 --- a/lib/lutaml/uml/final_state.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class FinalState < State - end - end -end diff --git a/lib/lutaml/uml/formatter.rb b/lib/lutaml/uml/formatter.rb deleted file mode 100644 index b3cee54..0000000 --- a/lib/lutaml/uml/formatter.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - module Formatter - class << self - def all - @all ||= [] - end - - def find_by_name(name) - name = name.to_sym - - all.detect { |formatter_class| formatter_class.name == name } - end - end - end - end -end - -require "lutaml/uml/formatter/graphviz" diff --git a/lib/lutaml/uml/formatter/base.rb b/lib/lutaml/uml/formatter/base.rb deleted file mode 100644 index 15cd34d..0000000 --- a/lib/lutaml/uml/formatter/base.rb +++ /dev/null @@ -1,67 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/formatter" -require "lutaml/uml/has_attributes" - -module Lutaml - module Uml - module Formatter - class Base - class << self - def inherited(subclass) - Formatter.all << subclass - end - - def format(node, attributes = {}) - new(attributes).format(node) - end - - def name - to_s.split("::").last.downcase.to_sym - end - end - - include HasAttributes - - # rubocop:disable Rails/ActiveRecordAliases - def initialize(attributes = {}) - update_attributes(attributes) - end - # rubocop:enable Rails/ActiveRecordAliases - - def name - self.class.name - end - - attr_reader :type - - def type=(value) - @type = value.to_s.strip.downcase.to_sym - end - - def format(node) - case node - when Node::Field then format_field(node) - when Node::Method then format_method(node) - when Node::Relationship then format_relationship(node) - when Node::ClassRelationship then format_class_relationship(node) - when Node::ClassNode then format_class(node) - when Lutaml::Uml::Document then format_document(node) - end - end - - def format_field(_node); raise NotImplementedError; end - - def format_method(_node); raise NotImplementedError; end - - def format_relationship(_node); raise NotImplementedError; end - - def format_class_relationship(_node); raise NotImplementedError; end - - def format_class(_node); raise NotImplementedError; end - - def format_document(_node); raise NotImplementedError; end - end - end - end -end diff --git a/lib/lutaml/uml/formatter/graphviz.rb b/lib/lutaml/uml/formatter/graphviz.rb deleted file mode 100644 index 00e4077..0000000 --- a/lib/lutaml/uml/formatter/graphviz.rb +++ /dev/null @@ -1,334 +0,0 @@ -# frozen_string_literal: true - -require "open3" -require "lutaml/uml/formatter/base" -require "lutaml/layout/graph_viz_engine" - -module Lutaml - module Uml - module Formatter - class Graphviz < Base - class Attributes < Hash - def to_s - to_a - .reject { |(_k, val)| val.nil? } - .map { |(a, b)| "#{a}=#{b.inspect}" } - .join(" ") - end - end - - ACCESS_SYMBOLS = { - "public" => "+", - "protected" => "#", - "private" => "-", - }.freeze - DEFAULT_CLASS_FONT = "Helvetica".freeze - - VALID_TYPES = %i[ - dot - xdot - ps - pdf - svg - svgz - fig - png - gif - jpg - jpeg - json - imap - cmapx - ].freeze - - def initialize(attributes = {}) - super - - @graph = Attributes.new - # Associations lines style, `true` gives curved lines - # https://graphviz.org/doc/info/attrs.html#d:splines - @graph["splines"] = "ortho" - # Padding between outside of picture and nodes - @graph["pad"] = 0.5 - # Padding between levels - @graph["ranksep"] = "1.2.equally" - # Padding between nodes - @graph["nodesep"] = "1.2.equally" - # TODO: set rankdir - # @graph['rankdir'] = 'BT' - - @edge = Attributes.new - @edge["color"] = "gray50" - - @node = Attributes.new - @node["shape"] = "box" - - @type = :dot - end - - attr_reader :graph - attr_reader :edge - attr_reader :node - - def type=(value) - super - - @type = :dot unless VALID_TYPES.include?(@type) - end - - def format(node) - dot = super.lines.map(&:rstrip).join("\n") - - generate_from_dot(dot) - end - - def escape_html_chars(text) - text - .gsub(//, ">") - .gsub(/\[/, "[") - .gsub(/\]/, "]") - end - - def format_field(node) - symbol = ACCESS_SYMBOLS[node.visibility] - result = "#{symbol}#{node.name}" - if node.type - keyword = node.keyword ? "«#{node.keyword}»" : "" - result += " : #{keyword}#{node.type}" - end - if node.cardinality - result += "[#{node.cardinality[:min]}..#{node.cardinality[:max]}]" - end - result = escape_html_chars(result) - result = "#{result}" if node.static - - result - end - - def format_method(node) - symbol = ACCESS_SYMBOLS[node.access] - result = "#{symbol} #{node.name}" - if node.arguments - arguments = node.arguments.map do |argument| - "#{argument.name}#{" : #{argument.type}" if argument.type}" - end.join(", ") - end - - result << "(#{arguments})" - result << " : #{node.type}" if node.type - result = "#{result}" if node.static - result = "#{result}" if node.abstract - - result - end - - def format_relationship(node) - graph_parent_name = generate_graph_name(node.owner_end) - graph_node_name = generate_graph_name(node.member_end) - attributes = generate_graph_relationship_attributes(node) - graph_attributes = " [#{attributes}]" unless attributes.empty? - - %{#{graph_parent_name} -> #{graph_node_name}#{graph_attributes}} - end - - def generate_graph_relationship_attributes(node) - attributes = Attributes.new - if %w[dependency realizes].include?(node.member_end_type) - attributes["style"] = "dashed" - end - attributes["dir"] = if node.owner_end_type && node.member_end_type - "both" - elsif node.owner_end_type - "back" - else - "direct" - end - attributes["label"] = node.action if node.action - if node.owner_end_attribute_name - attributes["headlabel"] = format_label( - node.owner_end_attribute_name, - node.owner_end_cardinality - ) - end - if node.member_end_attribute_name - attributes["taillabel"] = format_label( - node.member_end_attribute_name, - node.member_end_cardinality - ) - end - - attributes["arrowtail"] = case node.owner_end_type - when "composition" - "diamond" - when "aggregation" - "odiamond" - when "direct" - "vee" - else - "onormal" - end - - attributes["arrowhead"] = case node.member_end_type - when "composition" - "diamond" - when "aggregation" - "odiamond" - when "direct" - "vee" - else - "onormal" - end - # swap labels and arrows if `dir` eq to `back` - if attributes["dir"] == "back" - attributes["arrowhead"], attributes["arrowtail"] = - [attributes["arrowtail"], attributes["arrowhead"]] - attributes["headlabel"], attributes["taillabel"] = - [attributes["taillabel"], attributes["headlabel"]] - end - attributes - end - - def format_label(name, cardinality = {}) - res = "+#{name}" - if cardinality.nil? || - (cardinality["min"].nil? || cardinality["max"].nil?) - return res - end - - "#{res} #{cardinality['min']}..#{cardinality['max']}" - end - - def format_member_rows(members, hide_members) - unless !hide_members && members && members.length.positive? - return <<~HEREDOC.chomp - - -
- HEREDOC - end - - field_rows = members.map do |field| - %{#{format_field(field)}} - end - field_table = <<~HEREDOC.chomp - - #{field_rows.map { |row| ' ' * 10 + row }.join("\n")} -
- HEREDOC - field_table << "\n" << " " * 6 - field_table - end - - def format_class(node, hide_members) - name = ["#{node.name}"] - name.unshift("«#{node.keyword}»") if node.keyword - name_html = <<~HEREDOC - - #{name.map { |n| %() }.join('\n')} -
#{n}
- HEREDOC - - field_table = format_member_rows(node.attributes, hide_members) - method_table = format_member_rows(node.methods, hide_members) - table_body = [name_html, field_table, method_table].map do |type| - next if type.nil? - - <<~TEXT - - #{type} - - TEXT - end - - <<~HEREDOC.chomp - - #{table_body.compact.join("\n")} -
- HEREDOC - end - - def format_document(node) - @fontname = node.fontname || DEFAULT_CLASS_FONT - @node["fontname"] = "#{@fontname}-bold" - - if node.fidelity - hide_members = node.fidelity["hideMembers"] - hide_other_classes = node.fidelity["hideOtherClasses"] - end - classes = (node.classes + - node.enums + - node.data_types + - node.primitives).map do |class_node| - graph_node_name = generate_graph_name(class_node.name) - - <<~HEREDOC - #{graph_node_name} [ - shape="plain" - fontname="#{@fontname || DEFAULT_CLASS_FONT}" - label=<#{format_class(class_node, hide_members)}>] - HEREDOC - end.join("\n") - associations = node.classes.map(&:associations).compact.flatten + - node.associations - if node.groups - associations = sort_by_document_groupping(node.groups, - associations) - end - classes_names = node.classes.map(&:name) - associations = associations.map do |assoc_node| - if hide_other_classes && - !classes_names.include?(assoc_node.member_end) - next - end - - format_relationship(assoc_node) - end.join("\n") - - classes = classes.lines.map { |line| " #{line}" }.join.chomp - associations = associations - .lines.map { |line| " #{line}" }.join.chomp - - <<~HEREDOC - digraph G { - graph [#{@graph}] - edge [#{@edge}] - node [#{@node}] - - #{classes} - - #{associations} - } - HEREDOC - end - - protected - - def sort_by_document_groupping(groups, associations) - result = [] - groups.each do |batch| - batch.each do |group_name| - associations - .select { |assc| assc.owner_end == group_name } - .each do |association| - result.push(association) unless result.include?(association) - end - end - end - associations.each do |association| - result.push(association) unless result.include?(association) - end - result - end - - def generate_from_dot(input) - Lutaml::Layout::GraphVizEngine.new(input: input).render(@type) - end - - def generate_graph_name(name) - name.gsub(/[^0-9a-zA-Z]/i, "") - end - end - end - end -end diff --git a/lib/lutaml/uml/has_attributes.rb b/lib/lutaml/uml/has_attributes.rb deleted file mode 100644 index c117de8..0000000 --- a/lib/lutaml/uml/has_attributes.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - module HasAttributes - def update_attributes(attributes = {}) - attributes.to_h.each do |name, value| - value = value.respond_to?(:str) ? value.str : value - public_send("#{name}=", value) - end - end - end - end -end diff --git a/lib/lutaml/uml/has_members.rb b/lib/lutaml/uml/has_members.rb deleted file mode 100644 index 9b26dc6..0000000 --- a/lib/lutaml/uml/has_members.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - module HasMembers - class UnknownMemberTypeError < StandardError; end - - # TODO: move to Parslet::Transform - def members=(value) - value.group_by { |member| member.keys.first } - .each do |(type, group)| - attribute_value = group.map(&:values).flatten - if attribute_value.length == 1 && !attribute_value.first.is_a?(Hash) - next public_send("#{associtaion_type(type)}=", attribute_value.first) - end - - public_send("#{associtaion_type(type)}=", attribute_value) - end - end - - private - - def associtaion_type(type) - return type if respond_to?("#{type}=") - - raise(UnknownMemberTypeError, "Unknown member type: #{type}") - end - end - end -end diff --git a/lib/lutaml/uml/instance.rb b/lib/lutaml/uml/instance.rb deleted file mode 100644 index 3ba036e..0000000 --- a/lib/lutaml/uml/instance.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class Instance < TopElement - attr_accessor :classifier, :slot - - def initialize - @name = nil - @xmi_id = nil - @xmi_uuid = nil - @classifier = nil - @slot = [] - end - end - end -end diff --git a/lib/lutaml/uml/model.rb b/lib/lutaml/uml/model.rb deleted file mode 100644 index 8b68900..0000000 --- a/lib/lutaml/uml/model.rb +++ /dev/null @@ -1,13 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class Model < Package - attr_accessor :viewpoint - - def initialize - @contents = [] - end - end - end -end diff --git a/lib/lutaml/uml/node/base.rb b/lib/lutaml/uml/node/base.rb deleted file mode 100644 index 0b9069b..0000000 --- a/lib/lutaml/uml/node/base.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/has_attributes" - -module Lutaml - module Uml - module Node - class Base - include HasAttributes - - # rubocop:disable Rails/ActiveRecordAliases - def initialize(attributes = {}) - update_attributes(attributes) - end - # rubocop:enable Rails/ActiveRecordAliases - - attr_accessor :parent - end - end - end -end diff --git a/lib/lutaml/uml/node/class_node.rb b/lib/lutaml/uml/node/class_node.rb deleted file mode 100644 index 67168ea..0000000 --- a/lib/lutaml/uml/node/class_node.rb +++ /dev/null @@ -1,57 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/node/base" -require "lutaml/uml/node/field" -require "lutaml/uml/node/method" -require "lutaml/uml/node/relationship" -require "lutaml/uml/node/class_relationship" -require "lutaml/uml/node/has_name" - -module Lutaml - module Uml - module Node - class ClassNode < Base - include HasName - - attr_reader :modifier - - def modifier=(value) - @modifier = value.to_s # TODO: Validate? - end - - attr_reader :members - - def members=(value) - @members = value.to_a.map do |member| - type = member.to_a[0][0] # TODO: This is dumb - attributes = member.to_a[0][1] - attributes[:parent] = self - - case type - when :field then Field.new(attributes) - when :method then Method.new(attributes) - when :relationship then Relationship.new(attributes) - when :class_relationship then ClassRelationship.new(attributes) - end - end - end - - def fields - @members.select { |member| member.class == Field } - end - - def methods - @members.select { |member| member.class == Method } - end - - def relationships - @members.select { |member| member.class == Relationship } - end - - def class_relationships - @members.select { |member| member.class == ClassRelationship } - end - end - end - end -end diff --git a/lib/lutaml/uml/node/class_relationship.rb b/lib/lutaml/uml/node/class_relationship.rb deleted file mode 100644 index 55eabc6..0000000 --- a/lib/lutaml/uml/node/class_relationship.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/node/relationship" -require "lutaml/uml/node/has_name" - -module Lutaml - module Uml - module Node - class ClassRelationship < Relationship - include HasName - end - end - end -end diff --git a/lib/lutaml/uml/node/document.rb b/lib/lutaml/uml/node/document.rb deleted file mode 100644 index 1a4345a..0000000 --- a/lib/lutaml/uml/node/document.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/node/base" -require "lutaml/uml/node/class_node" - -module Lutaml - module Uml - module Node - class Document < Base - attr_reader :classes - - def classes=(value) - @classes = value.to_a.map { |attributes| ClassNode.new(attributes) } - end - end - end - end -end diff --git a/lib/lutaml/uml/node/field.rb b/lib/lutaml/uml/node/field.rb deleted file mode 100644 index 8f76a52..0000000 --- a/lib/lutaml/uml/node/field.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/node/base" -require "lutaml/uml/node/has_name" -require "lutaml/uml/node/has_type" - -module Lutaml - module Uml - module Node - class Field < Base - include HasName - include HasType - - def initialize(attributes = {}) - @access = "public" - - super - end - - attr_reader :static - - def static=(value) - @static = !!value - end - - attr_reader :access - - def access=(value) - @access = value.to_s # TODO: Validate? - end - end - end - end -end diff --git a/lib/lutaml/uml/node/has_name.rb b/lib/lutaml/uml/node/has_name.rb deleted file mode 100644 index 22f5ace..0000000 --- a/lib/lutaml/uml/node/has_name.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - module Node - module HasName - attr_reader :name - - def name=(value) - @name = value.to_s - end - end - end - end -end diff --git a/lib/lutaml/uml/node/has_type.rb b/lib/lutaml/uml/node/has_type.rb deleted file mode 100644 index a18128a..0000000 --- a/lib/lutaml/uml/node/has_type.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - module Node - module HasType - attr_reader :type - - def type=(value) - @type = value.to_s - end - end - end - end -end diff --git a/lib/lutaml/uml/node/method.rb b/lib/lutaml/uml/node/method.rb deleted file mode 100644 index 7638db6..0000000 --- a/lib/lutaml/uml/node/method.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/node/field" -require "lutaml/uml/node/method_argument" -require "lutaml/uml/node/has_name" - -module Lutaml - module Uml - module Node - class Method < Field - include HasName - - attr_reader :abstract - - def abstract=(value) - @abstract = !!value - end - - attr_reader :arguments - - def arguments=(value) - @arguments = value.to_a.map do |attributes| - MethodArgument.new(attributes) - end - end - end - end - end -end diff --git a/lib/lutaml/uml/node/method_argument.rb b/lib/lutaml/uml/node/method_argument.rb deleted file mode 100644 index 7f9a2a6..0000000 --- a/lib/lutaml/uml/node/method_argument.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/node/base" -require "lutaml/uml/node/has_name" -require "lutaml/uml/node/has_type" - -module Lutaml - module Uml - module Node - class MethodArgument < Base - include HasName - include HasType - end - end - end -end diff --git a/lib/lutaml/uml/node/relationship.rb b/lib/lutaml/uml/node/relationship.rb deleted file mode 100644 index 23159fa..0000000 --- a/lib/lutaml/uml/node/relationship.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/node/base" -require "lutaml/uml/node/has_name" -require "lutaml/uml/node/has_type" - -module Lutaml - module Uml - module Node - class Relationship < Base - include HasName - include HasType - - attr_reader :from - - def from=(value) - @from = value.to_s - end - - attr_reader :to - - def to=(value) - @to = value.to_s - end - end - end - end -end diff --git a/lib/lutaml/uml/opaque_behavior.rb b/lib/lutaml/uml/opaque_behavior.rb deleted file mode 100644 index f6e7667..0000000 --- a/lib/lutaml/uml/opaque_behavior.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class OpaqueBehavior < Behavior - end - end -end diff --git a/lib/lutaml/uml/operation.rb b/lib/lutaml/uml/operation.rb deleted file mode 100644 index 1b6a90e..0000000 --- a/lib/lutaml/uml/operation.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class Operation - include HasAttributes - include HasMembers - - attr_accessor :definition, - :name, - :return_type, - :parameter_type - - # rubocop:disable Rails/ActiveRecordAliases - def initialize(attributes = {}) - update_attributes(attributes) - end - # rubocop:enable Rails/ActiveRecordAliases - - def definition=(value) - @definition = value - .to_s - .gsub(/\\}/, '}') - .gsub(/\\{/, '{') - .split("\n") - .map(&:strip) - .join("\n") - end - end - end -end diff --git a/lib/lutaml/uml/package.rb b/lib/lutaml/uml/package.rb deleted file mode 100644 index a215716..0000000 --- a/lib/lutaml/uml/package.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class Package < TopElement - include HasAttributes - - attr_accessor :imports, :contents - attr_reader :classes, :enums, :data_types, :children_packages - - def initialize(attributes) - update_attributes(attributes) - @children_packages ||= packages.map { |pkg| [pkg, pkg.packages, pkg.packages.map(&:children_packages)] }.flatten.uniq - end - - def classes=(value) - @classes = value.to_a.map { |attributes| Class.new(attributes) } - end - - def enums=(value) - @enums = value.to_a.map { |attributes| Enum.new(attributes) } - end - - def data_types=(value) - @data_types = value.to_a.map { |attributes| DataType.new(attributes) } - end - - def packages=(value) - @packages = value.to_a.map { |attributes| Package.new(attributes) } - end - - def diagrams=(value) - @diagrams = value.to_a.map { |attributes| Diagram.new(attributes) } - end - - def classes - @classes || [] - end - - def enums - @enums || [] - end - - def packages - @packages || [] - end - - def diagrams - @diagrams || [] - end - end - end -end diff --git a/lib/lutaml/uml/parsers/attribute.rb b/lib/lutaml/uml/parsers/attribute.rb deleted file mode 100644 index 9ea05a1..0000000 --- a/lib/lutaml/uml/parsers/attribute.rb +++ /dev/null @@ -1,70 +0,0 @@ -# frozen_string_literal: true - -require "parslet" - -module Lutaml - module Uml - module Parsers - class Attribute < Parslet::Parser - class Transform < Parslet::Transform - rule(integer: simple(:x)) { Integer(x) } - rule(float: simple(:x)) { Float(x) } - rule(string: simple(:x)) { String(x) } - end - - def self.parse(io, options = {}) - new.parse(io, options) - end - - def parse(io, options = {}) - tree = Transform.new.apply(super) - tree = tree[:assignments].each_with_object({}) do |assignment, memo| - memo[assignment[:name].to_s] = assignment[:value] - end - - tree - end - - rule(:spaces) { match("\s").repeat(1) } - rule(:spaces?) { spaces.maybe } - - rule(:digits) { match["0-9"].repeat(1) } - - rule(:integer) do - (str("-").maybe >> digits >> str(".").absent?).as(:integer) - end - rule(:float) do - (str("-").maybe >> digits >> str(".") >> digits).as(:float) - end - - rule(:string_single_quoted) do - str("'") >> - (str("'").absent? >> any).repeat.as(:string) >> - str("'") - end - rule(:string_double_quoted) do - str('"') >> - (str('"').absent? >> any).repeat.as(:string) >> - str('"') - end - - rule(:string) { string_single_quoted | string_double_quoted } - - rule(:assignment_name) do - (match["=\s"].absent? >> any).repeat.as(:name) - end - rule(:assignment_value) { (integer | float | string).as(:value) } - rule(:assignment) do - assignment_name >> spaces? >> str("=") >> spaces? >> assignment_value - end - - rule(:attribute) { spaces? >> assignment >> spaces? } - rule(:attributes) do - (attribute >> (str(",") >> attribute).repeat).repeat.as(:assignments) - end - - root(:attributes) - end - end - end -end diff --git a/lib/lutaml/uml/parsers/dsl.rb b/lib/lutaml/uml/parsers/dsl.rb deleted file mode 100644 index acbdd74..0000000 --- a/lib/lutaml/uml/parsers/dsl.rb +++ /dev/null @@ -1,413 +0,0 @@ -# frozen_string_literal: true - -require "parslet" -require "parslet/convenience" -require "lutaml/uml/parsers/dsl_preprocessor" -require "lutaml/uml/parsers/dsl_transform" -require "lutaml/uml/node/document" - -module Lutaml - module Uml - module Parsers - class ParsingError < StandardError; end - # Class for parsing LutaML dsl into Lutaml::Uml::Document - class Dsl < Parslet::Parser - # @param [String] io - LutaML string representation - # [Hash] options - options for parsing - # - # @return [Lutaml::Uml::Document] - def self.parse(io, options = {}) - new.parse(io, options) - end - - def parse(input_file, _options = {}) - data = Lutaml::Uml::Parsers::DslPreprocessor.call(input_file) - # https://kschiess.github.io/parslet/tricks.html#Reporter engines - # Parslet::ErrorReporter::Deepest allows more - # detailed display of error - reporter = Parslet::ErrorReporter::Deepest.new - ::Lutaml::Uml::Document - .new(DslTransform.new.apply(super(data, reporter: reporter))) - rescue Parslet::ParseFailed => e - raise(ParsingError, - "#{e.message}\ncause: #{e.parse_failure_cause.ascii_tree}") - end - - KEYWORDS = %w[ - abstract - aggregation - association - association - attribute - bidirectional - class - composition - data_type - dependency - diagram - directional - enum - fontname - generalizes - include - interface - member - member_type - method - owner - owner_type - primitive - private - protected - public - realizes - static - title - caption - ].freeze - - KEYWORDS.each do |keyword| - rule("kw_#{keyword}") { str(keyword) } - end - - rule(:spaces) { match("\s").repeat(1) } - rule(:spaces?) { spaces.maybe } - rule(:whitespace) do - (match("\s") | match(" ") | match("\r?\n") | match("\r") | str(";")).repeat(1) - end - rule(:whitespace?) { whitespace.maybe } - rule(:name) { match["a-zA-Z0-9 _-"].repeat(1) } - rule(:newline) { str("\n") >> str("\r").maybe } - rule(:comment_definition) do - spaces? >> str("**") >> (newline.absent? >> any).repeat.as(:comments) - end - rule(:comment_multiline_definition) do - spaces? >> str("*|") >> (str("|*").absent? >> any).repeat.as(:comments) >> whitespace? >> str("|*") - end - rule(:class_name_chars) { match('(?:[a-zA-Z0-9 _-]|\:|\.)').repeat(1) } - rule(:class_name) do - class_name_chars >> - (str("(") >> - class_name_chars >> - str(")")).maybe - end - rule(:cardinality_body_definition) do - match['0-9\*'].as('min') >> - str("..").maybe >> - match['0-9\*'].as('max').maybe - end - rule(:cardinality) do - str("[") >> - cardinality_body_definition.as(:cardinality) >> - str("]") - end - rule(:cardinality?) { cardinality.maybe } - - # -- attribute/Method - rule(:kw_visibility_modifier) do - str("+") | str("-") | str("#") | str("~") - end - - rule(:member_static) { (kw_static.as(:static) >> spaces).maybe } - rule(:visibility) do - kw_visibility_modifier.as(:visibility_modifier) - end - rule(:visibility?) { visibility.maybe } - - rule(:method_abstract) { (kw_abstract.as(:abstract) >> spaces).maybe } - rule(:attribute_keyword) do - str("<<") >> - match['a-zA-Z0-9_\-\/'].repeat(1).as(:keyword) >> - str(">>") - end - rule(:attribute_keyword?) { attribute_keyword.maybe } - rule(:attribute_type) do - (str(":") >> - spaces? >> - attribute_keyword? >> - spaces? >> - match['"\''].maybe >> - match['a-zA-Z0-9_\- \/\+'].repeat(1).as(:type) >> - match['"\''].maybe >> - spaces? - ) - end - rule(:attribute_type?) do - attribute_type.maybe - end - - rule(:attribute_name) { match['a-zA-Z0-9_\- \/\+'].repeat(1).as(:name) } - rule(:attribute_definition) do - (visibility?.as(:visibility) >> - match['"\''].maybe >> - attribute_name >> - match['"\''].maybe >> - attribute_type? >> - cardinality? >> - class_body?) - .as(:attributes) - end - - rule(:title_keyword) { kw_title >> spaces } - rule(:title_text) do - match['"\''].maybe >> - match['a-zA-Z0-9_\- ,.:;'].repeat(1).as(:title) >> - match['"\''].maybe - end - rule(:title_definition) { title_keyword >> title_text } - rule(:caption_keyword) { kw_caption >> spaces } - rule(:caption_text) do - match['"\''].maybe >> - match['a-zA-Z0-9_\- ,.:;'].repeat(1).as(:caption) >> - match['"\''].maybe - end - rule(:caption_definition) { caption_keyword >> caption_text } - - rule(:fontname_keyword) { kw_fontname >> spaces } - rule(:fontname_text) do - match['"\''].maybe >> - match['a-zA-Z0-9_\- '].repeat(1).as(:fontname) >> - match['"\''].maybe - end - rule(:fontname_definition) { fontname_keyword >> fontname_text } - - # Method - # rule(:method_keyword) { kw_method >> spaces } - # rule(:method_argument) { name.as(:name) >> member_type } - # rule(:method_arguments_inner) do - # (method_argument >> - # (spaces? >> str(",") >> spaces? >> method_argument).repeat) - # .repeat.as(:arguments) - # end - # rule(:method_arguments) do - # (str("(") >> - # spaces? >> - # method_arguments_inner >> - # spaces? >> - # str(")")) - # .maybe - # end - - # rule(:method_name) { name.as(:name) } - # rule(:method_return_type) { member_type.maybe } - # rule(:method_definition) do - # (method_abstract >> - # member_static >> - # visibility >> - # method_keyword >> - # method_name >> - # method_arguments >> - # method_return_type) - # .as(:method) - # end - - # -- Association - - rule(:association_keyword) { kw_association >> spaces } - - %w[owner member].each do |association_end_type| - rule("#{association_end_type}_cardinality") do - spaces? >> - str("[") >> - cardinality_body_definition - .as("#{association_end_type}_end_cardinality") >> - str("]") - end - rule("#{association_end_type}_cardinality?") do - send("#{association_end_type}_cardinality").maybe - end - rule("#{association_end_type}_attribute_name") do - str("#") >> - visibility? >> - name.as("#{association_end_type}_end_attribute_name") - end - rule("#{association_end_type}_attribute_name?") do - send("#{association_end_type}_attribute_name").maybe - end - rule("#{association_end_type}_definition") do - send("kw_#{association_end_type}") >> - spaces >> - name.as("#{association_end_type}_end") >> - send("#{association_end_type}_attribute_name?") >> - send("#{association_end_type}_cardinality?") - end - rule("#{association_end_type}_type") do - send("kw_#{association_end_type}_type") >> - spaces >> - name.as("#{association_end_type}_end_type") - end - end - - rule(:association_inner_definitions) do - owner_type | - member_type | - owner_definition | - member_definition | - comment_definition | - comment_multiline_definition - end - rule(:association_inner_definition) do - association_inner_definitions >> whitespace? - end - rule(:association_body) do - spaces? >> - str("{") >> - whitespace? >> - association_inner_definition.repeat.as(:members) >> - str("}") - end - rule(:association_definition) do - association_keyword >> - name.as(:name).maybe >> - association_body - end - - # -- Class - - rule(:kw_class_modifier) { kw_abstract | kw_interface } - - rule(:class_modifier) do - (kw_class_modifier.as(:modifier) >> spaces).maybe - end - rule(:class_keyword) { kw_class >> spaces } - rule(:class_inner_definitions) do - definition_body | - attribute_definition | - comment_definition | - comment_multiline_definition - end - rule(:class_inner_definition) do - class_inner_definitions >> whitespace? - end - rule(:class_body) do - spaces? >> - str("{") >> - whitespace? >> - class_inner_definition.repeat.as(:members) >> - str("}") - end - rule(:class_body?) { class_body.maybe } - rule(:class_definition) do - class_modifier >> - class_keyword >> - class_name.as(:name) >> - spaces? >> - attribute_keyword? >> - class_body? - end - - # -- Definition - rule(:definition_body) do - spaces? >> - str("definition") >> - whitespace? >> - str("{") >> - ((str("\\") >> any) | (str("}").absent? >> any)).repeat.maybe.as(:definition) >> - str('}') - end - - # -- Enum - rule(:enum_keyword) { kw_enum >> spaces } - rule(:enum_inner_definitions) do - definition_body | - attribute_definition | - comment_definition | - comment_multiline_definition - end - rule(:enum_inner_definition) do - enum_inner_definitions >> whitespace? - end - rule(:enum_body) do - spaces? >> - str("{") >> - whitespace? >> - enum_inner_definition.repeat.as(:members) >> - str("}") - end - rule(:enum_body?) { enum_body.maybe } - rule(:enum_definition) do - enum_keyword >> - match['"\''].maybe >> - class_name.as(:name) >> - match['"\''].maybe >> - attribute_keyword? >> - enum_body? - end - - # -- data_type - rule(:data_type_keyword) { kw_data_type >> spaces } - rule(:data_type_inner_definitions) do - definition_body | - attribute_definition | - comment_definition | - comment_multiline_definition - end - rule(:data_type_inner_definition) do - data_type_inner_definitions >> whitespace? - end - rule(:data_type_body) do - spaces? >> - str("{") >> - whitespace? >> - data_type_inner_definition.repeat.as(:members) >> - str("}") - end - rule(:data_type_body?) { data_type_body.maybe } - rule(:data_type_definition) do - data_type_keyword >> - match['"\''].maybe >> - class_name.as(:name) >> - match['"\''].maybe >> - attribute_keyword? >> - data_type_body? - end - - # -- primitive - rule(:primitive_keyword) { kw_primitive >> spaces } - rule(:primitive_definition) do - primitive_keyword >> - match['"\''].maybe >> - class_name.as(:name) >> - match['"\''].maybe - end - - # -- Diagram - rule(:diagram_keyword) { kw_diagram >> spaces? } - rule(:diagram_inner_definitions) do - title_definition | - caption_definition | - fontname_definition | - class_definition.as(:classes) | - enum_definition.as(:enums) | - primitive_definition.as(:primitives) | - data_type_definition.as(:data_types) | - association_definition.as(:associations) | - comment_definition | - comment_multiline_definition - end - rule(:diagram_inner_definition) do - diagram_inner_definitions >> whitespace? - end - rule(:diagram_body) do - spaces? >> - str("{") >> - whitespace? >> - diagram_inner_definition.repeat.as(:members) >> - str("}") - end - rule(:diagram_definition) do - diagram_keyword >> - spaces? >> - class_name.as(:name) >> - diagram_body >> - whitespace? - end - rule(:diagram_definitions) { diagram_definition >> whitespace? } - rule(:diagram) { whitespace? >> diagram_definition } - # -- Root - - root(:diagram) - end - end - end -end diff --git a/lib/lutaml/uml/parsers/dsl_preprocessor.rb b/lib/lutaml/uml/parsers/dsl_preprocessor.rb deleted file mode 100644 index d0f20cb..0000000 --- a/lib/lutaml/uml/parsers/dsl_preprocessor.rb +++ /dev/null @@ -1,59 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - module Parsers - # Class for preprocessing dsl ascii file special directives: - # - include - class DslPreprocessor - attr_reader :input_file - - def initialize(input_file) - @input_file = input_file - end - - class << self - def call(input_file) - new(input_file).call - end - end - - def call - include_root = File.dirname(input_file.path) - input_file.read.split("\n").reduce([]) do |res, line| - res.push(*process_dsl_line(include_root, line)) - end.join("\n") - end - - private - - def process_dsl_line(include_root, line) - process_include_line(include_root, process_comment_line(line)) - end - - def process_comment_line(line) - has_comment = line.match(%r{//.*}) - return line if has_comment.nil? - - line.gsub(%r{//.*}, "") - end - - def process_include_line(include_root, line) - include_path_match = line.match(/^\s*include\s+(.+)/) - return line if include_path_match.nil? || line =~ /^\s\*\*/ - - path_to_file = include_path_match[1].strip - path_to_file = if path_to_file.match?(/^\//) - path_to_file - else - File.join(include_root, path_to_file) - end - File.read(path_to_file).split("\n").map { |line| process_comment_line(line) } - rescue Errno::ENOENT - puts("No such file or directory @ rb_sysopen - #{path_to_file}, \ - include file paths need to be supplied relative to the main document") - end - end - end - end -end diff --git a/lib/lutaml/uml/parsers/dsl_transform.rb b/lib/lutaml/uml/parsers/dsl_transform.rb deleted file mode 100644 index f90c96f..0000000 --- a/lib/lutaml/uml/parsers/dsl_transform.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require "parslet" - -module Lutaml - module Uml - module Parsers - # Class for additional transformations of LutaML syntax: - # visibility modifier etc - class DslTransform < Parslet::Transform - rule(visibility_modifier: simple(:visibility_value)) do - case visibility_value - when "-" - "private" - when "#" - "protected" - when "~" - "friendly" - else - "public" - end - end - rule(simple(:member)) { member.nil? ? member : member.to_s.strip } - end - end - end -end diff --git a/lib/lutaml/uml/parsers/yaml.rb b/lib/lutaml/uml/parsers/yaml.rb deleted file mode 100644 index 374e771..0000000 --- a/lib/lutaml/uml/parsers/yaml.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true - -require "yaml" -require "lutaml/uml/class" -require "lutaml/uml/document" -require "lutaml/uml/serializers/yaml_view" - -module Lutaml - module Uml - module Parsers - class Yaml - def self.parse(yaml_path, options = {}) - new.parse(yaml_path, options) - end - - def parse(yaml_path, _options = {}) - yaml_parse(yaml_path) - end - - 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 - - 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 - end - end - end -end diff --git a/lib/lutaml/uml/port.rb b/lib/lutaml/uml/port.rb deleted file mode 100644 index d7ab158..0000000 --- a/lib/lutaml/uml/port.rb +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class Port < Property - end - end -end diff --git a/lib/lutaml/uml/primitive_type.rb b/lib/lutaml/uml/primitive_type.rb deleted file mode 100644 index 364ebef..0000000 --- a/lib/lutaml/uml/primitive_type.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class PrimitiveType < DataType - attr_reader :keyword - - def initialize(attributes = {}) - super - @keyword = "primitive" - end - end - end -end diff --git a/lib/lutaml/uml/property.rb b/lib/lutaml/uml/property.rb deleted file mode 100644 index 60c10cb..0000000 --- a/lib/lutaml/uml/property.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class Property < TopElement - attr_accessor :type, - :aggregation, - :association, - :is_derived, - :lowerValue, - :upperValue - - def initialize - @name = nil - @xmi_id = nil - @xmi_uuid = nil - @aggregation = nil - @association = nil - @namespace = nil - @is_derived = false - @visibility = "public" - @lowerValue = "1" - @upperValue = "1" - end - end - end -end diff --git a/lib/lutaml/uml/pseudostate.rb b/lib/lutaml/uml/pseudostate.rb deleted file mode 100644 index 7f41acf..0000000 --- a/lib/lutaml/uml/pseudostate.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class Pseudostate < Vertex - end - end -end diff --git a/lib/lutaml/uml/realization.rb b/lib/lutaml/uml/realization.rb deleted file mode 100644 index 6a2d5e7..0000000 --- a/lib/lutaml/uml/realization.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class Realization < Abstraction - end - end -end diff --git a/lib/lutaml/uml/region.rb b/lib/lutaml/uml/region.rb deleted file mode 100644 index 7ecf3c0..0000000 --- a/lib/lutaml/uml/region.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## - -module Lutaml - module Uml - class Region < TopElement - end - end -end diff --git a/lib/lutaml/uml/serializers/association.rb b/lib/lutaml/uml/serializers/association.rb deleted file mode 100644 index a7f77ac..0000000 --- a/lib/lutaml/uml/serializers/association.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/serializers/base" -require "lutaml/uml/serializers/class" - -module Lutaml - module Uml - module Serializers - class Association < Base - property :member_end, from: :target - property :member_end_attribute_name, - from: "relationship", - transform_with: (lambda do |val| - val.dig("target", "attributes")&.keys&.first || - val.dig("target", "attribute")&.keys&.first - end) - property :member_end_cardinality, - from: "relationship", - transform_with: (lambda do |val| - res = val.dig("source", "attributes")&.values&.first || - val.dig("source", "attribute")&.values&.first - res["cardinality"] if res - end) - property :member_end_type, - from: "relationship", - transform_with: (lambda do |val| - val.dig("target", "type") - end) - property :owner_end_attribute_name, - from: "relationship", - transform_with: (lambda do |val| - val.dig("source", "attributes")&.keys&.first || - val.dig("source", "attribute")&.keys&.first - end) - property :owner_end_cardinality, - from: "relationship", - transform_with: (lambda do |val| - res = val.dig("source", "attributes")&.values&.first || - val.dig("source", "attribute")&.values&.first - res["cardinality"] if res - end) - property :owner_end_type, - from: "relationship", - transform_with: (lambda do |val| - val.dig("source", "type") - end) - property :action, - transform_with: (lambda do |val| - if val["direction"] == "target" - "#{val['verb']} ▶" - else - "◀ #{val['verb']}" - end - end) - end - end - end -end diff --git a/lib/lutaml/uml/serializers/base.rb b/lib/lutaml/uml/serializers/base.rb deleted file mode 100644 index 2867674..0000000 --- a/lib/lutaml/uml/serializers/base.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require "hashie" - -module Lutaml - module Uml - module Serializers - class Base < Hashie::Dash - include Hashie::Extensions::Dash::PropertyTranslation - include Hashie::Extensions::Dash::IndifferentAccess - include Hashie::Extensions::Dash::Coercion - include Hashie::Extensions::IgnoreUndeclared - end - end - end -end diff --git a/lib/lutaml/uml/serializers/class.rb b/lib/lutaml/uml/serializers/class.rb deleted file mode 100644 index a5d9cab..0000000 --- a/lib/lutaml/uml/serializers/class.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/serializers/base" -require "lutaml/uml/serializers/top_element_attribute" -require "lutaml/uml/serializers/association" - -module Lutaml - module Uml - module Serializers - class Class < Base - property :attributes, - transform_with: (lambda do |entry| - entry - .to_a - .map do |(name, attributes)| - attributes.merge(name: name) - end - end) - property :associations, - from: :relations, - coerce: Array[::Lutaml::Uml::Serializers::Association] - property :name - # property :type, from: :modelType - # property :relations, - # coerce: Array[Relation] - end - end - end -end diff --git a/lib/lutaml/uml/serializers/top_element_attribute.rb b/lib/lutaml/uml/serializers/top_element_attribute.rb deleted file mode 100644 index 5cd21c6..0000000 --- a/lib/lutaml/uml/serializers/top_element_attribute.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/serializers/base" - -module Lutaml - module Uml - module Serializers - class TopElementAttribute < Base - property :cardinality - property :type - end - end - end -end diff --git a/lib/lutaml/uml/serializers/yaml_view.rb b/lib/lutaml/uml/serializers/yaml_view.rb deleted file mode 100644 index c5f215a..0000000 --- a/lib/lutaml/uml/serializers/yaml_view.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require "lutaml/uml/serializers/base" -require "lutaml/uml/serializers/class" - -module Lutaml - module Uml - module Serializers - class YamlView < Base - property :name - property :title - property :caption - property :groups - property :fidelity - end - end - end -end diff --git a/lib/lutaml/uml/state.rb b/lib/lutaml/uml/state.rb deleted file mode 100644 index 8200c3a..0000000 --- a/lib/lutaml/uml/state.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class State < Vertex - attr_accessor :exit, :entry, :do_activity - end - end -end diff --git a/lib/lutaml/uml/state_machine.rb b/lib/lutaml/uml/state_machine.rb deleted file mode 100644 index 9f35783..0000000 --- a/lib/lutaml/uml/state_machine.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## - -module Lutaml - module Uml - class StateMachine < Behavior - end - end -end diff --git a/lib/lutaml/uml/top_element.rb b/lib/lutaml/uml/top_element.rb deleted file mode 100644 index 07e6b77..0000000 --- a/lib/lutaml/uml/top_element.rb +++ /dev/null @@ -1,58 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class TopElement - include HasAttributes - - attr_accessor :name, - :definition, - :xmi_id, - :xmi_uuid, - :namespace, - :keyword, - :stereotype, - :href, - :visibility, - :comments - - # rubocop:disable Rails/ActiveRecordAliases - def initialize(attributes = {}) - @visibility = "public" - @name = attributes["name"] - update_attributes(attributes) - end - # rubocop:enable Rails/ActiveRecordAliases - - def full_name - if name == nil - return nil - end - - the_name = name - next_namespace = namespace - - while !next_namespace.nil? - the_name = if !next_namespace.name.nil? - next_namespace.name + "::" + the_name - else - "::" + the_name - end - next_namespace = next_namespace.namespace - end - - the_name - end - - def definition=(value) - @definition = value - .to_s - .gsub(/\\}/, '}') - .gsub(/\\{/, '{') - .split("\n") - .map(&:strip) - .join("\n") - end - end - end -end diff --git a/lib/lutaml/uml/top_element_attribute.rb b/lib/lutaml/uml/top_element_attribute.rb deleted file mode 100644 index 4b5eede..0000000 --- a/lib/lutaml/uml/top_element_attribute.rb +++ /dev/null @@ -1,39 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class TopElementAttribute - include HasAttributes - include HasMembers - - attr_accessor :name, - :visibility, - :type, - :id, - :xmi_id, - :definition, - :contain, - :static, - :cardinality, - :keyword, - :is_derived - - # rubocop:disable Rails/ActiveRecordAliases - def initialize(attributes = {}) - @visibility = "public" - update_attributes(attributes) - end - # rubocop:enable Rails/ActiveRecordAliases - - def definition=(value) - @definition = value - .to_s - .gsub(/\\}/, '}') - .gsub(/\\{/, '{') - .split("\n") - .map(&:strip) - .join("\n") - end - end - end -end diff --git a/lib/lutaml/uml/transition.rb b/lib/lutaml/uml/transition.rb deleted file mode 100644 index 5627418..0000000 --- a/lib/lutaml/uml/transition.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class Transition < TopElement - attr_accessor :source, :target, :guard, :effect - end - end -end diff --git a/lib/lutaml/uml/trigger.rb b/lib/lutaml/uml/trigger.rb deleted file mode 100644 index ea4078d..0000000 --- a/lib/lutaml/uml/trigger.rb +++ /dev/null @@ -1,12 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class Trigger < TopElement - attr_accessor :event - end - end -end diff --git a/lib/lutaml/uml/value.rb b/lib/lutaml/uml/value.rb deleted file mode 100644 index 754d39c..0000000 --- a/lib/lutaml/uml/value.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - class Value - include HasAttributes - include HasMembers - - attr_accessor :definition, - :name, - :id, - :type - - # rubocop:disable Rails/ActiveRecordAliases - def initialize(attributes = {}) - update_attributes(attributes) - end - # rubocop:enable Rails/ActiveRecordAliases - - def definition=(value) - @definition = value - .to_s - .gsub(/\\}/, '}') - .gsub(/\\{/, '{') - .split("\n") - .map(&:strip) - .join("\n") - end - end - end -end diff --git a/lib/lutaml/uml/version.rb b/lib/lutaml/uml/version.rb deleted file mode 100644 index 84593f1..0000000 --- a/lib/lutaml/uml/version.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -module Lutaml - module Uml - VERSION = "0.4.3" - end -end diff --git a/lib/lutaml/uml/vertex.rb b/lib/lutaml/uml/vertex.rb deleted file mode 100644 index 1ee1762..0000000 --- a/lib/lutaml/uml/vertex.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -## -## Behaviour metamodel -## -module Lutaml - module Uml - class Vertex < TopElement - end - end -end diff --git a/lutaml-uml.gemspec b/lutaml-uml.gemspec index 2fefe27..44ef653 100644 --- a/lutaml-uml.gemspec +++ b/lutaml-uml.gemspec @@ -1,40 +1,24 @@ -# frozen_string_literal: true - -require_relative "lib/lutaml/uml/version" - -Gem::Specification.new do |spec| - spec.name = "lutaml-uml" - spec.version = Lutaml::Uml::VERSION - spec.authors = ["Ribose Inc."] - spec.email = ["open.source@ribose.com'"] - - spec.summary = "UML model module for LutaML." - spec.description = "UML model module for LutaML." - spec.homepage = "https://github.com/lutaml/lutaml-uml" - spec.license = "MIT" - - spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = spec.homepage - spec.metadata["changelog_uri"] = "https://github.com/lutaml/lutaml-uml/releases" - - spec.files = `git ls-files`.split("\n") - spec.test_files = `git ls-files -- {spec}/*`.split("\n") - - spec.bindir = "exe" - spec.require_paths = ["lib"] - spec.executables = %w[lutaml-wsd2uml lutaml-yaml2uml] - - spec.required_ruby_version = '>= 2.7.0' - - spec.add_runtime_dependency "hashie", "~> 4.1.0" - spec.add_runtime_dependency "parslet", "~> 2.0.0" - spec.add_runtime_dependency "ruby-graphviz", "~> 1.2" - spec.add_runtime_dependency "thor", "~> 1.0" - spec.add_runtime_dependency "nokogiri", "~> 1.10" - - spec.add_development_dependency "bundler", "~> 2.0" - spec.add_development_dependency "pry", "~> 0.12.2" - spec.add_development_dependency "rake", "~> 10.0" - spec.add_development_dependency "rspec", "~> 3.0" - spec.add_development_dependency "rubocop", "~> 0.54.0" +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = "lutaml-uml" + s.version = "1.0.0" + s.authors = ["Ribose Inc."] + s.email = ["open.source@ribose.com"] + + s.homepage = "http://github.com/lutaml/lutaml" + s.summary = "Lutaml stub gem for lutaml-uml" + s.description = "Lutaml stub gem for lutaml-uml" + s.license = "BSD-2-Clause" + + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") + s.executables = `git ls-files -- exe/*`.split("\n").map do |f| + File.basename(f) + end + s.bindir = "exe" + s.require_paths = ["lib"] + s.required_ruby_version = Gem::Requirement.new(">= 2.7.0") + + s.add_dependency "lutaml", "> 0.7.7" end diff --git a/spec/fixtures/datamodel/models/AddressClassProfile.yml b/spec/fixtures/datamodel/models/AddressClassProfile.yml deleted file mode 100644 index fc029dc..0000000 --- a/spec/fixtures/datamodel/models/AddressClassProfile.yml +++ /dev/null @@ -1,90 +0,0 @@ -modelType: class -# TODO -definition: | - An `AddressClassProfile` represents a profile of a `ProfileCompliantAddress`. - It corresponds to the concept of an `AddressClass` originally - expressed in <> as a referenced codelist. - - It represents additional attributes and restrictions to the - `ProfileCompliantAddress` model. It also represents metadata for the use of - the profile. - - A single profile can include and support multiple types of - address formats, such as a numbered street address and a - "`PO Box`" address simultaneously. Each of these address formats - is represented as an interchange address class. - - [example] - -- - The US Numbered Thoroughfare Address with this syntax can be - represented as an address class profile: - - *{sp}{ Complete Landmark Name or Complete Place Name } + - *{sp}{ Complete Address Number * } + - *{sp}{ Complete Street Name * } + - *{sp}{ Complete Subaddress } + - *{sp}{ Complete Place Name * } + - *{sp}{ State Name * } + - *{sp}{ Zip Code } + - *{sp}{ Zip Plus 4 } + - *{sp}{ Country Name } - -- -attributes: - id: - definition: Unique identifier of this AddressClassProfile. - type: CharacterString - type: - definition: Intended usage of this profile. - type: CharacterString - description: - definition: Textual description of this profile. - type: CharacterString - localization: - definition: The language and script used within this profile. - type: Localization - signature: - definition: The digital signature to verify the integrity of this profile, and the identity of the publishing authority. - type: Signature - cardinality: - min: 0 - max: 1 - areaApplicability: - definition: The geographic representation of which this AddressClassProfile applies to. Overlapping geographic areas are allowed across different profiles. - type: iso19115MD_SpatialRepresentation - cardinality: - min: 0 - max: "*" - timeToLive: - definition: The maximum time interval between refreshing of this profile via an authoritative source, in seconds. - type: Integer - validity: - definition: The period of date and time that this profile should be considered as valid. - type: Validity -relations: - - target: AttributeProfile - relationship: - source: - type: aggregation - attribute: - addressClassProfile: - target: - type: direct - attribute: - attributeProfile: - cardinality: - min: 0 - max: '*' - - - target: ProfileCompliantAddress - relationship: - source: - attribute: - profile: - cardinality: - min: 1 - max: 1 - target: - type: direct - action: - verb: compliesWith - direction: source \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/AddressComponentProfile.yml b/spec/fixtures/datamodel/models/AddressComponentProfile.yml deleted file mode 100644 index b14ca3e..0000000 --- a/spec/fixtures/datamodel/models/AddressComponentProfile.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: AddressComponentProfile -modelType: class -definition: | - An `AddressComponentProfile` represents a profile of a `ProfileCompliantAddressComponent`, - which is extended from the `AddressComponent` model defined in <>. - - It represents additional attributes and restrictions to the `Address` model - of a `ProfileCompliantAddress`. It also represents metadata for the use of - the profile. -attributes: - key: - definition: An identifier of this `AddressComponentProfile`, shall be unique within the `AddressProfile`. - type: CharacterString - description: - definition: Textual description of this component. - type: CharacterString - example: - definition: A textual example to demonstrate the correct use of this component. - type: CharacterString - cardinality: - min: 0 - max: 1 -relations: - - target: AddressClassProfile - relationship: - target: - type: aggregation - attribute: - componentProfile: - cardinality: - min: 0 - max: "*" - association: AddressComponentSpecification - action: - verb: uses - direction: source - - - target: AttributeProfile - relationship: - source: - type: aggregation - attribute: - addressClassProfile: - target: - type: direct - attribute: - attributeProfile: - cardinality: - min: 0 - max: '*' - - - target: ProfileCompliantAddressComponent - relationship: - target: - type: direct - attribute: - profile: - cardinality: - min: 1 - max: 1 - action: - verb: compliesWith - direction: source \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/AddressComponentSpecification.yml b/spec/fixtures/datamodel/models/AddressComponentSpecification.yml deleted file mode 100644 index fe3d775..0000000 --- a/spec/fixtures/datamodel/models/AddressComponentSpecification.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: AddressComponentSpecification -modelType: class -definition: | - An `AddressComponentSpecification` specifies the cardinalities between a - `ProfileCompliantAddress` and `ProfileCompliantAddressComponents`. - - A `ProfileComplinatAddress` MUST conform to this - `AddressComponentSpecification` to specifies its components. -attributes: - maxCardinality: - definition: The maximum number of instances of the specific `ProfileCompliantAddressComponent` of a `ProfileCompliantAddress`. - type: Integer - minCardinality: - definition: The minimum number of instances of the specific `ProfileCompliantAddressComponent` of a `ProfileCompliantAddress`. - type: Integer \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/AddressProfile.yml b/spec/fixtures/datamodel/models/AddressProfile.yml deleted file mode 100644 index 130a8d6..0000000 --- a/spec/fixtures/datamodel/models/AddressProfile.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: AddressProfile -modelType: class -definition: -attributes: - country: - definition: The country of which this AddressProfile represents. - type: iso3166Code - cardinality: - min: 0 - max: "*" -relations: - - target: AddressComponentProfile - relationship: - source: - type: aggregation - attribute: - componentProfile: - cardinality: - min: 0 - max: "*" - action: - verb: defines - direction: target - - - target: AddressClassProfile - relationship: - source: - type: aggregation - attribute: - addressProfile: - cardinality: - min: 0 - max: "*" - action: - verb: defines - direction: target \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/AttributeProfile.yml b/spec/fixtures/datamodel/models/AttributeProfile.yml deleted file mode 100644 index 8a0514b..0000000 --- a/spec/fixtures/datamodel/models/AttributeProfile.yml +++ /dev/null @@ -1,32 +0,0 @@ -modelType: class -definition: | - An `AttributeProfile` represents name, cardinalities and value type of an - attribute in a model that complies with a profile that includes this - AttributeProfile. - - If it represents an attribute that has been previously defined, e.g. an - attribute in Address model defined in <>, it extends the - definition of the attribute by redefining the name, cardinalities and value - type. -attributes: - name: - definition: The name of the attribute represented by this AttributeProfile. - type: CharacterString - minCardinality: - definition: The minimum number of occurrences of the attribute represented by this AttributeProfile. - type: Integer - cardinality: - min: 0 - max: 1 - maxCardinality: - definition: The maximum number of occurences of the attribute represented by this AttributeProfile. - type: Integer - cardinality: - min: 0 - max: 1 - valueType: - definition: The data type of values of the attribute represented by this AttributeProfile. - type: CharacterString - cardinality: - min: 0 - max: 1 \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/InterchangeAddressClassProfile.yml b/spec/fixtures/datamodel/models/InterchangeAddressClassProfile.yml deleted file mode 100644 index d050777..0000000 --- a/spec/fixtures/datamodel/models/InterchangeAddressClassProfile.yml +++ /dev/null @@ -1,79 +0,0 @@ -name: InterchangeAddressClassProfile -modelType: class -definition: | - This `InterchangeAddressClassProfile` extends from `AddressClassProfile` to - enforce the existence of several subclasses of `AttributeProfile` for - interchange. - - It also introduces `FormTemplate` and `DisplayTemplate` to - to allow the display, entry of, and the interchange of an - `ProfileCompliantAddress` (address - instance complying with an `InterchangeAddressClassProfile`). - -- -attributes: -relations: - - target: AddressClassProfile - relationship: - target: - type: inheritance - - - target: AttributeProfileSignature - relationship: - source: - type: aggregation - attribute: - attributeProfile: - target: - type: direct - attribute: - addressClassProfile: - - - target: AttributeProfileAddressFeature - relationship: - source: - type: aggregation - attribute: - attributeProfile: - target: - type: direct - attribute: - addressClassProfile: - - - target: AttributeProfileValidity - relationship: - source: - type: aggregation - attribute: - attributeProfile: - target: - type: direct - attribute: - addressClassProfile: - - - target: FormTemplate - relationship: - source: - type: aggregation - target: - attribute: - formTemplate: - cardinality: - min: 0 - max: "*" - action: - verb: defines - direction: target - - - target: DisplayTemplate - relationship: - source: - type: aggregation - target: - attribute: - displayTemplate: - cardinality: - min: 0 - max: "*" - action: - verb: defines - direction: target \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/Localization copy.yml b/spec/fixtures/datamodel/models/Localization copy.yml deleted file mode 100644 index 98154da..0000000 --- a/spec/fixtures/datamodel/models/Localization copy.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Localization -modelType: class -definition: | - The language and script used within the parent object. - - Represented by the `PT_Locale` object defined in <> and an - <> script code. -attributes: - locale: - definition: The locale of the parent object. - type: iso19115PT_Locale - script: - definition: The type of written script used in the parent object. - type: iso15924Code - textDirection: - definition: Indicating in which direction the text of the parent should be read. - type: TextDirectionCode -relations: - - target: Validity - relationship: - target: - type: direct - direction: "[hidden]" diff --git a/spec/fixtures/datamodel/models/Localization.yml b/spec/fixtures/datamodel/models/Localization.yml deleted file mode 100644 index 98154da..0000000 --- a/spec/fixtures/datamodel/models/Localization.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Localization -modelType: class -definition: | - The language and script used within the parent object. - - Represented by the `PT_Locale` object defined in <> and an - <> script code. -attributes: - locale: - definition: The locale of the parent object. - type: iso19115PT_Locale - script: - definition: The type of written script used in the parent object. - type: iso15924Code - textDirection: - definition: Indicating in which direction the text of the parent should be read. - type: TextDirectionCode -relations: - - target: Validity - relationship: - target: - type: direct - direction: "[hidden]" diff --git a/spec/fixtures/datamodel/models/ProfileCompliantAddress.yml b/spec/fixtures/datamodel/models/ProfileCompliantAddress.yml deleted file mode 100644 index 1fd3608..0000000 --- a/spec/fixtures/datamodel/models/ProfileCompliantAddress.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: ProfileCompliantAddress -modelType: class -definition: | - ProfileCompliantAddress extends from the `Address` model defined in - <> to represent an `Address` complying with an - `AddressClassProfile`. - - A `ProfileCompliantAddress` MUST conform to the constraints and - requirements specified in `AddressClassProfile`, and its associated - profiles and specifications. -relations: - - target: Address - relationship: - target: - type: inheritance - - - target: ProfileCompliantAddressComponent - relationship: - source: - type: aggregation - attributes: - address: - cardinality: - min: 1 - max: "*" - target: - type: direct - attributes: - addressComponent: - cardinality: - min: 1 - max: "*" - association: AddressComponentSpecification - action: - verb: comprises - direction: target diff --git a/spec/fixtures/datamodel/models/ProfileCompliantAddressComponent.yml b/spec/fixtures/datamodel/models/ProfileCompliantAddressComponent.yml deleted file mode 100644 index 206df1a..0000000 --- a/spec/fixtures/datamodel/models/ProfileCompliantAddressComponent.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: ProfileCompliantAddressComponent -modelType: class -definition: | - ProfileCompliantAddressComponent extends from the AddressComponent model - defined in <> to represent an Address complying with an - AddressClassProfile. - - A ProfileCompliantAddressComponent MUST conform to the constraints and - requirements specified in AddressComponentProfile, and its associated - profiles and specifications. -relations: - - target: AddressComponent - relationship: - target: - type: inheritance \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/Signature.yml b/spec/fixtures/datamodel/models/Signature.yml deleted file mode 100644 index c58404d..0000000 --- a/spec/fixtures/datamodel/models/Signature.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Signature -modelType: class -definition: | - A cryptographic signature used to determine data integrity and validity of the object it belongs to. -attributes: - algorithm: - definition: The public key cryptographic algorithm used for this digital signature. - type: iso14888Oid - publicKey: - definition: A reference to the actual public key used to verify the digital signature, a URI where the public key of the signer used for this signature is found. - type: Uri - signature: - definition: The actual digital signature value encoded in Base64 format. - type: CharacterString -relations: - - target: Localization - relationship: - target: - type: direct - direction: "[hidden]" \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/SignatureBlankDefinition.yml b/spec/fixtures/datamodel/models/SignatureBlankDefinition.yml deleted file mode 100644 index 27b5c7f..0000000 --- a/spec/fixtures/datamodel/models/SignatureBlankDefinition.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: Signature -modelType: class -definition: | - A cryptographic signature used to determine data integrity and validity of the object it belongs to. -attributes: - algorithm: - definition: - type: iso14888Oid - publicKey: - definition: - type: Uri - signature: - definition: The actual digital signature value encoded in Base64 format. - type: CharacterString -relations: - - target: Localization - relationship: - target: - type: direct - direction: "[hidden]" \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/TextDirectionCode copy.yml b/spec/fixtures/datamodel/models/TextDirectionCode copy.yml deleted file mode 100644 index 0757818..0000000 --- a/spec/fixtures/datamodel/models/TextDirectionCode copy.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: TextDirectionCode -modelType: enum -definition: | - An enumeration value of TextDirectionCode represents the reading - direction of textual data whether it is from left to right or right to - left, and from top to bottom or bottom to top. -type: enumeration -values: - leftToRightTopToBottom: - definition: Indicating that text should be read left to right, and top to bottom. - rightToLeftTopToBottom: - definition: Indicating that text should be read right to left, and top to bottom. - leftToRightBottomToTop: - definition: Indicating that text should be read left to right, and bottom to top. - rightToLeftBottomToTop: - definition: Indicating that text should be read right to left, and bottom to top. \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/TextDirectionCode.yml b/spec/fixtures/datamodel/models/TextDirectionCode.yml deleted file mode 100644 index 0757818..0000000 --- a/spec/fixtures/datamodel/models/TextDirectionCode.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: TextDirectionCode -modelType: enum -definition: | - An enumeration value of TextDirectionCode represents the reading - direction of textual data whether it is from left to right or right to - left, and from top to bottom or bottom to top. -type: enumeration -values: - leftToRightTopToBottom: - definition: Indicating that text should be read left to right, and top to bottom. - rightToLeftTopToBottom: - definition: Indicating that text should be read right to left, and top to bottom. - leftToRightBottomToTop: - definition: Indicating that text should be read left to right, and bottom to top. - rightToLeftBottomToTop: - definition: Indicating that text should be read right to left, and bottom to top. \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/Validity.yml b/spec/fixtures/datamodel/models/Validity.yml deleted file mode 100644 index b1b9875..0000000 --- a/spec/fixtures/datamodel/models/Validity.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Validity -modelType: class -definition: | - The time interval where this interchange address profile is determined valid, and the revision number (represented as a date). -attributes: - validityBegins: - definition: The date and time when this object becomes valid. - type: iso19115CI_Date - validityEnds: - definition: The date and time when this object becomes invalid. - type: iso19115CI_Date - revision: - definition: Issuance date/time of this object. - type: iso19115CI_Date diff --git a/spec/fixtures/datamodel/models/iso19160-1/Address.yml b/spec/fixtures/datamodel/models/iso19160-1/Address.yml deleted file mode 100644 index aefcabd..0000000 --- a/spec/fixtures/datamodel/models/iso19160-1/Address.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Address -modelType: class -relations: - - target: AddressComponent - relationship: - source: - type: aggregation - attributes: - address: - cardinality: - min: 1 - max: "*" - target: - type: direct - attributes: - addressComponent: - cardinality: - min: 1 - max: "*" - action: - verb: comprises - direction: target \ No newline at end of file diff --git a/spec/fixtures/datamodel/models/iso19160-1/AddressComponent.yml b/spec/fixtures/datamodel/models/iso19160-1/AddressComponent.yml deleted file mode 100644 index 8044608..0000000 --- a/spec/fixtures/datamodel/models/iso19160-1/AddressComponent.yml +++ /dev/null @@ -1,2 +0,0 @@ -name: AddressComponent -modelType: class \ No newline at end of file diff --git a/spec/fixtures/datamodel/style.uml.inc b/spec/fixtures/datamodel/style.uml.inc deleted file mode 100644 index 45c61e5..0000000 --- a/spec/fixtures/datamodel/style.uml.inc +++ /dev/null @@ -1,37 +0,0 @@ -skinparam Dpi 150 -skinparam Monochrome false -hide circle -/' skinparam CircledCharacterRadius 0 '/ -/' skinparam CircledCharacterFontSize 0 '/ -skinparam Default { - TextAlignment center - FontName Helvetica -} -skinparam Class { - AttributeIconSize 0 - BackgroundColor White - ArrowColor Black - BorderColor Black - FontStyle bold - StereotypeFontSize 10 -} -skinparam Rectangle { - BackgroundColor White - ArrowColor Black - BorderColor Black - FontStyle bold - FontSize 11 - StereotypeFontSize 10 -} -skinparam Object { - BackgroundColor White - ArrowColor Black - BorderColor Black - FontStyle bold - FontSize 11 - StereotypeFontSize 10 -} - -skinparam Entity { - StereotypeFontSize 10 -} diff --git a/spec/fixtures/datamodel/views/AddressClassProfile.yml b/spec/fixtures/datamodel/views/AddressClassProfile.yml deleted file mode 100644 index e83f4ad..0000000 --- a/spec/fixtures/datamodel/views/AddressClassProfile.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: AddressClassProfile -imports: - AddressProfile: - AddressClassProfile: - AddressClassProfile: - AddressComponentProfile: - AttributeProfile: - ProfileCompliantAddress: - InterchangeAddressClassProfile: -fidelity: - hideMembers: true - hideOtherClasses: true \ No newline at end of file diff --git a/spec/fixtures/datamodel/views/AddressProfile.yml b/spec/fixtures/datamodel/views/AddressProfile.yml deleted file mode 100644 index 1f0cdf8..0000000 --- a/spec/fixtures/datamodel/views/AddressProfile.yml +++ /dev/null @@ -1,3 +0,0 @@ -name: AddressProfile -imports: - AddressProfile: \ No newline at end of file diff --git a/spec/fixtures/datamodel/views/CommonModels.yml b/spec/fixtures/datamodel/views/CommonModels.yml deleted file mode 100644 index 3ebaaaf..0000000 --- a/spec/fixtures/datamodel/views/CommonModels.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: CommonModels -title: Common models -caption: Common models to be used in this standard -directive: ix-common -imports: - Localization: - Validity: - Signature: - TextDirectionCode: diff --git a/spec/fixtures/datamodel/views/TopDown.yml b/spec/fixtures/datamodel/views/TopDown.yml deleted file mode 100644 index 1b8b275..0000000 --- a/spec/fixtures/datamodel/views/TopDown.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: TopDown -title: Address profile model overview -caption: Address profile model overview in UML -imports: - iso19160-1/Address: - iso19160-1/AddressComponent: - ProfileCompliantAddress: - ProfileCompliantAddressComponent: - AddressProfile: - AddressClassProfile: - InterchangeAddressClassProfile: - AddressComponentProfile: - AddressComponentSpecification: - AttributeProfile: -groups: - - - AddressProfile - - - InterchangeAddressClassProfile - - AddressClassProfile - - AddressComponentProfile - - - AddressComponentSpecification - - - ProfileCompliantAddress - - ProfileCompliantAddressComponent - - - Address - - AddressComponent -relations: - - source: InterchangeAddressClassProfile - target: AddressClassProfile - direction: '[hidden]right' - - source: AddressClassProfile - target: AddressComponentProfile - direction: '[hidden]right' - - - source: ProfileCompliantAddress - target: ProfileCompliantAddressComponent - direction: '[hidden]right' - - - source: Address - target: AddressComponent - direction: '[hidden]right' - - - source: AddressProfile - target: AddressClassProfile - direction: '[hidden]down' - - source: AddressClassProfile - target: ProfileCompliantAddress - direction: '[hidden]down' - - source: AddressComponentProfile - target: AddressComponentSpecification - direction: '[hidden]down' - - source: AddressComponentSpecification - target: ProfileCompliantAddressComponent - direction: '[hidden]down' - - source: ProfileCompliantAddress - target: Address - direction: '[hidden]down' - - source: ProfileCompliantAddressComponent - target: AddressComponent - direction: '[hidden]down' - -fidelity: - hideMembers: true - hideOtherClasses: true diff --git a/spec/fixtures/dsl/broken_diagram.lutaml b/spec/fixtures/dsl/broken_diagram.lutaml deleted file mode 100644 index a171bf3..0000000 --- a/spec/fixtures/dsl/broken_diagram.lutaml +++ /dev/null @@ -1,34 +0,0 @@ -diagram MyView { - title "my diagram" - - class AddressClassProfile { - addressClassProfile - } - class AttributeProfile { - attributeProfile - } - - association BidirectionalAsscoiation { - owner_type aggregation - member_type direct - owner AddressClassProfile#addressClassProfile - member AttributeProfile#attributeProfile [0..*] - } - - association DirectAsscoiation { - member_type direct - owner AddressClassProfile - member AttributeProfile#attributeProfile - } - - class Foo { - +structuredidentifier[0..*]: StructuredIdentifierType - +technicalcommittee[1..*]: TechnicalCommitteeType - } - - association ReverseAsscoiation { - owner_type aggregation - owner AddressClassProfile#addressClassProfile - member AttributeProfile - } -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram.lutaml b/spec/fixtures/dsl/diagram.lutaml deleted file mode 100644 index c2a20e1..0000000 --- a/spec/fixtures/dsl/diagram.lutaml +++ /dev/null @@ -1,4 +0,0 @@ -diagram MyView { - //
- class Foo {} -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram_attributes.lutaml b/spec/fixtures/dsl/diagram_attributes.lutaml deleted file mode 100644 index cf99e5d..0000000 --- a/spec/fixtures/dsl/diagram_attributes.lutaml +++ /dev/null @@ -1,6 +0,0 @@ -diagram MyView { - fontname "Arial" - title "my diagram, another symbols: text." - class Foo {} - caption "Block elements of StandardDocument, adapted from BasicDocument. Another - symbol" -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram_blank_definion.lutaml b/spec/fixtures/dsl/diagram_blank_definion.lutaml deleted file mode 100644 index ad135f4..0000000 --- a/spec/fixtures/dsl/diagram_blank_definion.lutaml +++ /dev/null @@ -1,6 +0,0 @@ -diagram MyView { - class ImageMapAreaType { - definition { - } - } -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram_blank_entities.lutaml b/spec/fixtures/dsl/diagram_blank_entities.lutaml deleted file mode 100644 index b1ce62e..0000000 --- a/spec/fixtures/dsl/diagram_blank_entities.lutaml +++ /dev/null @@ -1,8 +0,0 @@ -diagram MyView { - class ImageMapAreaType { - } - enum SomeEnum { - } - data_type SomeEnum { - } -} diff --git a/spec/fixtures/dsl/diagram_class_assocation.lutaml b/spec/fixtures/dsl/diagram_class_assocation.lutaml deleted file mode 100644 index ed1b2b7..0000000 --- a/spec/fixtures/dsl/diagram_class_assocation.lutaml +++ /dev/null @@ -1,29 +0,0 @@ -diagram MyView { - title "my diagram" - - class AddressClassProfile { - addressClassProfile - } - class AttributeProfile { - attributeProfile - } - - association BidirectionalAsscoiation { - owner_type aggregation - member_type direct - owner AddressClassProfile#addressClassProfile - member AttributeProfile#attributeProfile [0..*] - } - - association DirectAsscoiation { - member_type direct - owner AddressClassProfile - member AttributeProfile#attributeProfile - } - - association ReverseAsscoiation { - owner_type aggregation - owner AddressClassProfile#addressClassProfile - member AttributeProfile - } -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram_class_fields.lutaml b/spec/fixtures/dsl/diagram_class_fields.lutaml deleted file mode 100644 index 9482024..0000000 --- a/spec/fixtures/dsl/diagram_class_fields.lutaml +++ /dev/null @@ -1,25 +0,0 @@ -diagram MyView { - title "my diagram" - - class Component {} - - class AddressClassProfile { - +addressClassProfile: CharacterString [0..1] - } - - class AttributeProfile { - imlicistAttributeProfile: CharacterString [0..1] - +attributeProfile: <> LocalizedString [0..1] - +attributeProfile1: <> 'LocalizedString' - -privateAttributeProfile: CharacterString [1] - ~friendlyAttributeProfile: <> "CharacterString" [1..*] - ~friendlyAttributeProfile1: <> "CharacterString" - #protectedAttributeProfile: CharacterString - type/text: String - slashType: slash/type - application/docbook+xml - application/tei+xml - text/x-asciidoc - application/x-isodoc+xml - } -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram_commented_includes.lutaml b/spec/fixtures/dsl/diagram_commented_includes.lutaml deleted file mode 100644 index 2876b96..0000000 --- a/spec/fixtures/dsl/diagram_commented_includes.lutaml +++ /dev/null @@ -1,5 +0,0 @@ -diagram MyView { - title "my diagram" - - ** include ../models/bipm_document/BipmCommitteeAcronym.lutaml -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram_comments.lutaml b/spec/fixtures/dsl/diagram_comments.lutaml deleted file mode 100644 index a471516..0000000 --- a/spec/fixtures/dsl/diagram_comments.lutaml +++ /dev/null @@ -1,28 +0,0 @@ -diagram MyView { - title "my diagram" - - ** My comment - - class Component {} - - *| - this is multiline - comment with {} special - chars/ - - +-|/ - |* - class AddressClassProfile { - // TODO: write attributes - +addressClassProfile: CharacterString [0..1] - } - - // TODO: description - class AttributeProfile { - ** this is attribute comment - imlicistAttributeProfile: CharacterString [0..1] - *| this is another comment line - with multiply lines - |* - } -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram_concept_model.lutaml b/spec/fixtures/dsl/diagram_concept_model.lutaml deleted file mode 100644 index bfea2d8..0000000 --- a/spec/fixtures/dsl/diagram_concept_model.lutaml +++ /dev/null @@ -1,132 +0,0 @@ -diagram Designations { - title 'Designation models' - association { - owner NormativeStatus - member_type direct - member Designation - } - association { - owner PrefixDesignation - member_type inheritance - member ExpressionDesignation - } - association { - owner SuffixDesignation - member_type inheritance - member ExpressionDesignation - } - association { - owner AbbreviationDesignation - member_type inheritance - member ExpressionDesignation - } - association { - owner GrammarInfo - member_type direct - member ExpressionDesignation - } - association { - owner AbbreviationType - member_type direct - member AbbreviationDesignation - } - association { - owner GrammarGender - member_type direct - member GrammarInfo - } - association { - owner GlossaristTextElementType - member_type inheritance - member TextElementType - } - association { - owner GlossaristTextElementType - member_type direct - member ExpressionDesignation - } - association { - owner TextElement - member_type inheritance - member GlossaristTextElement - } - association { - owner EmptySlot - member_type inheritance - member GlossaristTextElement - } - association { - owner GlossaristTextElement - member_type direct - member GlossaristTextElementType - } - class Designation { - +normativeStatus: 'NormativeStatus' - +absent: 'Boolean' [0..1] - +geographicArea: 'Iso3166Code' [0..*] - +sources: 'ConceptSource' [0..*] - } - enum NormativeStatus { - } - class ExpressionDesignation { - +text: 'GlossaristTextElementType' - +language: 'Iso639ThreeCharCode' - +script: 'Iso15924Code' [0..1] - +pronunciation: <> 'LocalizedString' [0..*] - +grammarInfo: 'GrammarInfo' [0..*] - } - association { - owner ExpressionDesignation - member_type inheritance - member Designation - } - class GrammarInfo { - +gender: 'GrammarGender' [0..*] - +isPreposition: 'Boolean' [0..1] - +isParticiple: 'Boolean' [0..1] - +isAdjective: 'Boolean' [0..1] - +isVerb: 'Boolean' [0..1] - +isAdverb: 'Boolean' [0..1] - +isNoun: 'Boolean' [0..1] - } - class SymbolDesignation { - +isInternational: 'Boolean' - } - association { - owner SymbolDesignation - member_type inheritance - member Designation - } - class PrefixDesignation { - } - class SuffixDesignation { - } - class AbbreviationDesignation { - +isInternational: 'Boolean' - +abbreviationType: 'AbbreviationType' [0..1] - } - enum AbbreviationType { - } - class LetterSymbolDesignation { - +text: <> 'LocalizedString' - +language: 'Iso639ThreeCharCode' - +script: 'Iso15924Code' [0..1] - } - association { - owner LetterSymbolDesignation - member_type inheritance - member SymbolDesignation - } - class GraphicalSymbolDesignation { - +text: <> 'LocalizedString' [0..1] - +image: 'Image' [0..1] - +isInternational: 'Boolean' - } - association { - owner GraphicalSymbolDesignation - member_type inheritance - member SymbolDesignation - } - enum GrammarGender { - } -} diff --git a/spec/fixtures/dsl/diagram_data_types.lutaml b/spec/fixtures/dsl/diagram_data_types.lutaml deleted file mode 100644 index 4800ee3..0000000 --- a/spec/fixtures/dsl/diagram_data_types.lutaml +++ /dev/null @@ -1,44 +0,0 @@ -diagram MyView { - title "my diagram" - - enum MyEnum {} - - enum AddressClassProfile <> { - +addressClassProfile: CharacterString - } - - data_type "Banking Information" { - definition { - Common code types used in banking. - } - "art code" { - definition { - The bank ART code. - } - } - "CCT Number" - } - - data_type DateTimeType { - definition { - Type of date time value. - } - year { - definition { - The value only provides year. - } - } - monthYear - dayMonthYear - } - - primitive Integer - - enum Profile { - imlicistAttributeProfile: CharacterString - +attributeProfile: CharacterString - -privateAttributeProfile: CharacterString - ~friendlyAttributeProfile: CharacterString - #protectedAttributeProfile: CharacterString - } -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram_definitions.lutaml b/spec/fixtures/dsl/diagram_definitions.lutaml deleted file mode 100644 index 470dc76..0000000 --- a/spec/fixtures/dsl/diagram_definitions.lutaml +++ /dev/null @@ -1,25 +0,0 @@ -diagram MyView { - title "my diagram" - - class AddressClassProfile { - definition { - this is multiline with `ascidoc` - comments - and list - \{foo\} \{name\} - } - +addressClassProfile: CharacterString [0..1] - } - - class AttributeProfile { - imlicistAttributeProfile: CharacterString [0..1] { - definition - { - this is attribute definition - with multiply lines - \{foo\} \{name\} - end definition - } - } - } -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram_includes.lutaml b/spec/fixtures/dsl/diagram_includes.lutaml deleted file mode 100644 index 02df26d..0000000 --- a/spec/fixtures/dsl/diagram_includes.lutaml +++ /dev/null @@ -1,6 +0,0 @@ -diagram MyView { - fontname "Arial" - title "my diagram" - include shared.lutaml - include shared1.lutaml -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram_multiply_classes.lutaml b/spec/fixtures/dsl/diagram_multiply_classes.lutaml deleted file mode 100644 index 5e68784..0000000 --- a/spec/fixtures/dsl/diagram_multiply_classes.lutaml +++ /dev/null @@ -1,7 +0,0 @@ -diagram MyView { - title "my diagram" - class Foo {} - class Doo {} - class Koo {} - class NamespacedClass <> {} -} \ No newline at end of file diff --git a/spec/fixtures/dsl/diagram_non_existing_include.lutaml b/spec/fixtures/dsl/diagram_non_existing_include.lutaml deleted file mode 100644 index 223b93b..0000000 --- a/spec/fixtures/dsl/diagram_non_existing_include.lutaml +++ /dev/null @@ -1,6 +0,0 @@ -diagram MyView { - fontname "Arial" - title "my diagram" - include none_existing.lutaml - include none_existing1.lutaml -} \ No newline at end of file diff --git a/spec/fixtures/dsl/shared.lutaml b/spec/fixtures/dsl/shared.lutaml deleted file mode 100644 index fc52fa4..0000000 --- a/spec/fixtures/dsl/shared.lutaml +++ /dev/null @@ -1,5 +0,0 @@ -class Foo { - //
-} -class Doo {} -class Koo {} \ No newline at end of file diff --git a/spec/fixtures/dsl/shared1.lutaml b/spec/fixtures/dsl/shared1.lutaml deleted file mode 100644 index 98135ee..0000000 --- a/spec/fixtures/dsl/shared1.lutaml +++ /dev/null @@ -1,4 +0,0 @@ -class AttributeProfile { - imlicistAttributeProfile: CharacterString [0..1] - +attributeProfile: <> LocalizedString [0..1] -} \ No newline at end of file diff --git a/spec/fixtures/generated_dot/AddressClassProfile.dot b/spec/fixtures/generated_dot/AddressClassProfile.dot deleted file mode 100644 index 4d9b140..0000000 --- a/spec/fixtures/generated_dot/AddressClassProfile.dot +++ /dev/null @@ -1,170 +0,0 @@ -digraph G { - graph [splines="ortho" pad=0.5 ranksep="1.2.equally" nodesep="1.2.equally"] - edge [color="gray50"] - node [shape="box" fontname="Helvetica-bold"] - - AddressProfile [ - shape="plain" - fontname="Helvetica" - label=< - - - - - - - - - - - - -
- -
AddressProfile
-
- -
- -
>] - - AddressClassProfile [ - shape="plain" - fontname="Helvetica" - label=< - - - - - - - - - - - - -
- -
AddressClassProfile
-
- -
- -
>] - - AddressComponentProfile [ - shape="plain" - fontname="Helvetica" - label=< - - - - - - - - - - - - -
- -
AddressComponentProfile
-
- -
- -
>] - - AttributeProfile [ - shape="plain" - fontname="Helvetica" - label=< - - - - - - - - - - - - -
- -
AttributeProfile
-
- -
- -
>] - - ProfileCompliantAddress [ - shape="plain" - fontname="Helvetica" - label=< - - - - - - - - - - - - -
- -
ProfileCompliantAddress
-
- -
- -
>] - - InterchangeAddressClassProfile [ - shape="plain" - fontname="Helvetica" - label=< - - - - - - - - - - - - -
- -
InterchangeAddressClassProfile
-
- -
- -
>] - - AddressProfile -> AddressComponentProfile [dir="back" label="defines ▶" arrowtail="onormal" arrowhead="odiamond" taillabel="+componentProfile 0..*"] - AddressProfile -> AddressClassProfile [dir="back" label="defines ▶" arrowtail="onormal" arrowhead="odiamond" taillabel="+addressProfile 0..*"] - AddressClassProfile -> AttributeProfile [dir="both" headlabel="+addressClassProfile" taillabel="+attributeProfile" arrowtail="odiamond" arrowhead="vee"] - AddressClassProfile -> ProfileCompliantAddress [dir="direct" label="◀ compliesWith" headlabel="+profile 1..1" arrowtail="onormal" arrowhead="vee"] - AddressComponentProfile -> AddressClassProfile [dir="direct" label="◀ uses" taillabel="+componentProfile" arrowtail="onormal" arrowhead="odiamond"] - AddressComponentProfile -> AttributeProfile [dir="both" headlabel="+addressClassProfile" taillabel="+attributeProfile" arrowtail="odiamond" arrowhead="vee"] - - - - InterchangeAddressClassProfile -> AddressClassProfile [dir="direct" arrowtail="onormal" arrowhead="onormal"] - - - - -} diff --git a/spec/fixtures/generated_dot/AddressProfile.dot b/spec/fixtures/generated_dot/AddressProfile.dot deleted file mode 100644 index e83aa9d..0000000 --- a/spec/fixtures/generated_dot/AddressProfile.dot +++ /dev/null @@ -1,34 +0,0 @@ -digraph G { - graph [splines="ortho" pad=0.5 ranksep="1.2.equally" nodesep="1.2.equally"] - edge [color="gray50"] - node [shape="box" fontname="Helvetica-bold"] - - AddressProfile [ - shape="plain" - fontname="Helvetica" - label=< - - - - - - - - - - - - -
- -
AddressProfile
-
- -
+country : iso3166Code[0..*]
-
- -
>] - - AddressProfile -> AddressComponentProfile [dir="back" label="defines ▶" arrowtail="onormal" arrowhead="odiamond" taillabel="+componentProfile 0..*"] - AddressProfile -> AddressClassProfile [dir="back" label="defines ▶" arrowtail="onormal" arrowhead="odiamond" taillabel="+addressProfile 0..*"] -} diff --git a/spec/lutaml/layout/graph_viz_engine_spec.rb b/spec/lutaml/layout/graph_viz_engine_spec.rb deleted file mode 100644 index 014ef6e..0000000 --- a/spec/lutaml/layout/graph_viz_engine_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -RSpec.describe Lutaml::Layout::GraphVizEngine do - describe "#render" do - subject(:render) do - described_class.new(input: input).render(type) - end - let(:input) do - File.read(fixtures_path("generated_dot/AddressClassProfile.dot")) - end - - context "when png output type" do - let(:type) { "png" } - let(:png_header) { "\x89PNG" } - - it "renders input as png binary string" do - expect(render[0..3]).to(eq(png_header)) - end - end - - context "when dot output type" do - let(:type) { "dot" } - - it "renders input as dot string" do - expect(render).to(match("digraph G {")) - end - end - end -end diff --git a/spec/lutaml/uml/formatter/graphviz_spec.rb b/spec/lutaml/uml/formatter/graphviz_spec.rb deleted file mode 100644 index 5109400..0000000 --- a/spec/lutaml/uml/formatter/graphviz_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -RSpec.describe Lutaml::Uml::Formatter::Graphviz do - describe ".format_document" do - subject(:format_document) do - described_class.new.format_document(input_document) - end - - context "when simple aggregation" do - let(:input_document) do - Lutaml::Uml::Parsers::Yaml - .parse(fixtures_path("datamodel/views/AddressProfile.yml")) - end - - let(:formatted_dot_content) do - File.read(fixtures_path("generated_dot/AddressProfile.dot")) - end - - it "generates the correct relationship graph" do - expect(format_document).to eq(formatted_dot_content) - end - end - - context "when aggregation with inheritance" do - let(:input_document) do - Lutaml::Uml::Parsers::Yaml - .parse(fixtures_path("datamodel/views/AddressClassProfile.yml")) - end - - let(:formatted_dot_content) do - File.read(fixtures_path("generated_dot/AddressClassProfile.dot")) - end - - it "generates the correct relationship graph" do - expect(format_document).to eq(formatted_dot_content) - end - end - end -end diff --git a/spec/lutaml/uml/parsers/dsl_spec.rb b/spec/lutaml/uml/parsers/dsl_spec.rb deleted file mode 100644 index c65ed4f..0000000 --- a/spec/lutaml/uml/parsers/dsl_spec.rb +++ /dev/null @@ -1,345 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -RSpec.describe Lutaml::Uml::Parsers::Dsl do - describe ".parse" do - subject(:parse) { described_class.parse(content) } - subject(:format_parsed_document) do - Lutaml::Uml::Formatter::Graphviz.new.format_document(parse) - end - - shared_examples "the correct graphviz formatting" do - it "does not raise error on graphviz formatting" do - expect { format_parsed_document }.to_not raise_error - end - end - - context "when simple diagram without attributes" do - let(:content) do - File.new(fixtures_path("dsl/diagram.lutaml")) - end - - it "creates Lutaml::Uml::Document object from supplied dsl" do - expect(parse).to be_instance_of(Lutaml::Uml::Document) - end - - it_behaves_like "the correct graphviz formatting" - end - - context "when diagram with attributes" do - let(:content) do - File.new(fixtures_path("dsl/diagram_attributes.lutaml")) - end - - it "creates Lutaml::Uml::Document object and sets its attributes" do - expect(parse).to be_instance_of(Lutaml::Uml::Document) - expect(parse.title).to eq("my diagram, another symbols: text.") - expect(parse.caption) - .to(eq("Block elements of StandardDocument, adapted from BasicDocument. Another - symbol")) - expect(parse.fontname).to eq("Arial") - end - - it_behaves_like "the correct graphviz formatting" - end - - context "when multiply classes entries" do - let(:content) do - File.new(fixtures_path("dsl/diagram_multiply_classes.lutaml")) - end - - it "creates Lutaml::Uml::Document object and creates dependent classes" do - classes = parse.classes - expect(parse).to be_instance_of(Lutaml::Uml::Document) - expect(parse.classes.length).to eq(4) - expect(by_name(classes, "NamespacedClass").keyword).to eq("MyNamespace") - end - - it_behaves_like "the correct graphviz formatting" - end - - context "when class with fields" do - let(:content) do - File.new(fixtures_path("dsl/diagram_class_fields.lutaml")) - end - - it "creates the correct classes and sets the \ - correct number of attributes" do - classes = parse.classes - expect(by_name(classes, "Component").attributes).to be_nil - expect(by_name(classes, "AddressClassProfile") - .attributes.length).to eq(1) - expect(by_name(classes, "AttributeProfile") - .attributes.length).to eq(13) - expect(by_name(classes, "AttributeProfile") - .attributes.map(&:name)) - .to(eq(["imlicistAttributeProfile", - "attributeProfile", - "attributeProfile1", - "privateAttributeProfile", - "friendlyAttributeProfile", - "friendlyAttributeProfile1", - "protectedAttributeProfile", - "type/text", - "slashType", - "application/docbook+xml", - "application/tei+xml", - "text/x-asciidoc", - "application/x-isodoc+xml"])) - end - - it "creates the correct attributes with the correct visibility" do - attributes = by_name(parse.classes, "AttributeProfile").attributes - expect(by_name(attributes, "imlicistAttributeProfile").visibility) - .to be_nil - expect(by_name(attributes, "imlicistAttributeProfile").keyword) - .to be_nil - expect(by_name(attributes, "attributeProfile").visibility) - .to eq("public") - expect(by_name(attributes, "attributeProfile").keyword) - .to eq("BasicDocument") - expect(by_name(attributes, "attributeProfile1").visibility) - .to eq("public") - expect(by_name(attributes, "attributeProfile1").keyword) - .to eq("BasicDocument") - expect(by_name(attributes, "privateAttributeProfile").visibility) - .to eq("private") - expect(by_name(attributes, "friendlyAttributeProfile").visibility) - .to eq("friendly") - expect(by_name(attributes, "friendlyAttributeProfile").keyword) - .to eq("Type") - expect(by_name(attributes, "protectedAttributeProfile").visibility) - .to eq("protected") - end - - it_behaves_like "the correct graphviz formatting" - end - - context "when association blocks exists" do - let(:content) do - File.new(fixtures_path("dsl/diagram_class_assocation.lutaml")) - end - - it "creates the correct number of associations" do - expect(parse.associations.length).to eq(3) - end - - context "when bidirectional asscoiation syntax " do - subject(:association) do - by_name(parse.associations, "BidirectionalAsscoiation") - end - - it "creates associations with the correct attributes" do - expect(association.owner_end_type).to(eq("aggregation")) - expect(association.member_end_type).to(eq("direct")) - expect(association.owner_end).to(eq("AddressClassProfile")) - expect(association.owner_end_attribute_name) - .to(eq("addressClassProfile")) - expect(association.member_end).to(eq("AttributeProfile")) - expect(association.member_end_attribute_name) - .to(eq("attributeProfile")) - expect(association.member_end_cardinality).to(eq("min" => "0", "max" => "*")) - end - end - - context "when direct asscoiation syntax " do - subject(:association) do - by_name(parse.associations, "DirectAsscoiation") - end - - it "creates associations with the correct attributes" do - expect(association.owner_end_type).to(be_nil) - expect(association.member_end_type).to(eq("direct")) - expect(association.owner_end).to(eq("AddressClassProfile")) - expect(association.owner_end_attribute_name).to(be_nil) - expect(association.member_end).to(eq("AttributeProfile")) - expect(association.member_end_attribute_name) - .to(eq("attributeProfile")) - expect(association.member_end_cardinality).to(be_nil) - end - end - - context "when reverse asscoiation syntax " do - subject(:association) do - by_name(parse.associations, "ReverseAsscoiation") - end - - it "creates associations with the correct attributes" do - expect(association.owner_end_type).to(eq("aggregation")) - expect(association.member_end_type).to(be_nil) - expect(association.owner_end).to(eq("AddressClassProfile")) - expect(association.owner_end_attribute_name) - .to(eq("addressClassProfile")) - expect(association.member_end).to(eq("AttributeProfile")) - expect(association.member_end_attribute_name).to(be_nil) - expect(association.member_end_cardinality).to(be_nil) - end - end - end - - context "when data_types entries" do - let(:content) do - File.new(fixtures_path("dsl/diagram_data_types.lutaml")) - end - - it "Generates the correct nodes for enums" do - enums = parse.enums - expect(by_name(enums, "MyEnum").attributes).to be_nil - expect(by_name(enums, "AddressClassProfile") - .attributes.length).to eq(1) - expect(by_name(enums, "Profile") - .attributes.length).to eq(5) - end - - it "Generates the correct nodes for data_types" do - data_types = parse.data_types - expect(by_name(data_types, "Banking Information") - .attributes.map(&:name)) - .to(eq(["art code", "CCT Number"])) - end - - it "Generates the correct nodes for primitives" do - data_types = parse.primitives - expect(by_name(data_types, "Integer")).to_not be_nil - end - - it_behaves_like "the correct graphviz formatting" - end - - context "when concept model generated lutaml file" do - let(:content) do - File.new(fixtures_path("dsl/diagram_concept_model.lutaml")) - end - - it "Generates the correct class/enums/associations list" do - document = parse - expect(document.classes.length).to(eq(9)) - expect(document.enums.length).to(eq(3)) - expect(document.associations.length).to(eq(16)) - end - - it "Generates the correct attributes list" do - attributes = by_name(parse.classes, "ExpressionDesignation").attributes - expect(attributes.length).to(eq(5)) - expect(attributes.map(&:name)) - .to(eq(%w[text language script pronunciation grammarInfo])) - expect(attributes.map(&:type)) - .to(eq(["GlossaristTextElementType", - "Iso639ThreeCharCode", - "Iso15924Code", - "LocalizedString", - "GrammarInfo"])) - end - - it_behaves_like "the correct graphviz formatting" - end - - context "when include directives is used" do - let(:content) do - File.new(fixtures_path("dsl/diagram_includes.lutaml")) - end - - it "includes supplied files into the document" do - expect(parse.classes.map(&:name)) - .to(eq(%w[Foo Doo Koo AttributeProfile])) - expect(by_name(parse.classes, "AttributeProfile") - .attributes.map(&:name)) - .to eq(["imlicistAttributeProfile", "attributeProfile"]) - end - - it_behaves_like "the correct graphviz formatting" - end - - context "when include directives is used" do - let(:content) do - File.new(fixtures_path("dsl/diagram_comments.lutaml")) - end - - it "create comments for document and classes" do - expect(parse.comments).to(eq(["My comment", - "this is multiline\n comment with {} special\n chars/\n\n +-|/"])) - expect(parse.classes.last.comments) - .to(eq(["this is attribute comment", - "this is another comment line\n with multiply lines"])) - end - - it_behaves_like "the correct graphviz formatting" - end - - context "when defninition directives included" do - let(:content) do - File.new(fixtures_path("dsl/diagram_definitions.lutaml")) - end - let(:class_definition) do - "this is multiline with `ascidoc`\ncomments\nand list\n{foo} {name}" - end - let(:attribute_definition) do - "this is attribute definition\nwith multiply lines\n{foo} {name}\nend definition" - end - - it "create comments for document and classes" do - expect(by_name(parse.classes, "AddressClassProfile").definition) - .to(eq(class_definition)) - expect(by_name(parse.classes, "AttributeProfile") - .attributes - .first - .definition) - .to(eq(attribute_definition)) - end - - it_behaves_like "the correct graphviz formatting" - end - - context "when defninition is blank" do - let(:content) do - File.new(fixtures_path("dsl/diagram_blank_definion.lutaml")) - end - - it "successfully renders" do - expect { parse }.to_not(raise_error) - end - end - - context "when there are blank definitions" do - let(:content) do - File.new(fixtures_path("dsl/diagram_blank_entities.lutaml")) - end - - it "successfully renders" do - expect { parse }.to_not(raise_error) - end - end - - context "when its a non existing include file" do - let(:content) do - File.new(fixtures_path("dsl/diagram_non_existing_include.lutaml")) - end - - it "successfully renders" do - expect { parse }.to_not(raise_error) - end - end - - context "when there are commented preprocessor lines" do - let(:content) do - File.new(fixtures_path("dsl/diagram_commented_includes.lutaml")) - end - - it "successfully renders" do - expect { parse }.to_not(raise_error) - end - end - - context "when broken lutaml file passed" do - let(:content) do - File.new(fixtures_path("dsl/broken_diagram.lutaml")) - end - - it "returns error object and prints line number" do - expect { described_class.parse(content, {}) } - .to(raise_error(Lutaml::Uml::Parsers::ParsingError, - /but got ":" at line 25 char 32/)) - end - end - end -end diff --git a/spec/lutaml/uml/parsers/yaml_spec.rb b/spec/lutaml/uml/parsers/yaml_spec.rb deleted file mode 100644 index 9f3a8e3..0000000 --- a/spec/lutaml/uml/parsers/yaml_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -RSpec.describe Lutaml::Uml::Parsers::Yaml do - describe ".parse" do - subject(:parse) { described_class.parse(yaml_conent) } - - let(:yaml_conent) do - fixtures_path("datamodel/views/TopDown.yml") - end - - it "creates Lutaml::Uml::Document object from yaml" do - expect(parse).to be_instance_of(Lutaml::Uml::Document) - expect(parse.classes.first).to be_instance_of(Lutaml::Uml::Class) - end - end -end diff --git a/spec/lutaml/uml/serializers/yaml_view_spec.rb b/spec/lutaml/uml/serializers/yaml_view_spec.rb deleted file mode 100644 index e23d794..0000000 --- a/spec/lutaml/uml/serializers/yaml_view_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" -require "lutaml/uml/serializers/yaml_view" - -RSpec.describe Lutaml::Uml::Serializers::YamlView do - describe "#new" do - subject(:serialize) { described_class.new(yaml_content) } - - let(:yaml_content) do - YAML.safe_load(File.read(fixtures_path("datamodel/views/TopDown.yml"))) - end - - it "Correctly parses passed yaml file" do - expect(serialize.name).to eq(yaml_content["name"]) - expect(serialize.title).to eq(yaml_content["title"]) - expect(serialize.caption).to eq(yaml_content["caption"]) - end - end -end diff --git a/spec/lutaml/uml_spec.rb b/spec/lutaml/uml_spec.rb deleted file mode 100644 index 7608291..0000000 --- a/spec/lutaml/uml_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe Lutaml::Uml do - it "has a version number" do - expect(Lutaml::Uml::VERSION).not_to be nil - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb deleted file mode 100644 index b40bb85..0000000 --- a/spec/spec_helper.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -require "bundler/setup" -require "lutaml/uml" - -RSpec.configure do |config| - # Enable flags like --only-failures and --next-failure - config.example_status_persistence_file_path = ".rspec_status" - - # Disable RSpec exposing methods globally on `Module` and `main` - config.disable_monkey_patching! - - config.expect_with :rspec do |c| - c.syntax = :expect - end -end - -def fixtures_path(path) - File.join(File.expand_path("./fixtures", __dir__), path) -end - -def by_name(entries, name) - entries.detect { |n| n.name == name } -end