lutaml 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e98f32430c5e68002bab47d845cb50bf8bddb3c7fb47313b16b3e90a0488786
4
- data.tar.gz: 39843ef90934f8425b092cf1a3b312f8d1257d0a4cf18f4c7286c435c0545f20
3
+ metadata.gz: 98c639beedce6095e724dd236e5dc3037d74b58cf1624ff7c6c8d262a32c6e98
4
+ data.tar.gz: 3e51d0cef9b57a0e7f22922e6de07cdecef034ab03dd8fa9869f8aa35fc36c7e
5
5
  SHA512:
6
- metadata.gz: 68ab2ddac51f434300e1ffab94c441799b9cf053e7aab4e8e1b2811d22462077969fa2f66f1a48dce0e1f09ac68edb6a1cb87dfda96bf189712ac0b91ba335f2
7
- data.tar.gz: af15335cecd82f6be6f5dc4138b82f829459b39f8f4033ee0baeb001b5eeab73a0e87dd80dc31d34a241726231661d755fad20aa99161862299ecd505280f672
6
+ metadata.gz: 023b5fe40356139612aa5426c76cd72971a7763f182bb1d6c4e13e8d718e2a875352b1fbfcd0d03b126fc3313e359c8ade3fb03d681e03db735ec344f7876050
7
+ data.tar.gz: ff7e1f727d0709a88e3d88b41cd89d544c7f0a38ed145b0791c7aa15b0bca7446da485ec85adb2180a5c1108cd056265c6e5b47826ebbf77061ab01a3eaa326f
@@ -1,5 +1,3 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
1
  name: rake
4
2
 
5
3
  on:
@@ -7,6 +5,7 @@ on:
7
5
  branches: [ master, main ]
8
6
  tags: [ v* ]
9
7
  pull_request:
8
+ workflow_dispatch:
10
9
 
11
10
  jobs:
12
11
  rake:
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "expressir"
4
-
5
3
  # Specify your gem's dependencies in lutaml.gemspec
6
4
  gemspec
data/README.adoc CHANGED
@@ -1,74 +1,105 @@
1
- = Lutaml
1
+ = LutaML: Ruby library for accessing data models
2
2
 
3
- == Functionality
3
+ == Purpose
4
4
 
5
- Entry point for lutaml extensions.
5
+ LutaML aims to be a universal data model accessor that allows parsing
6
+ data models in multiple languages, including:
6
7
 
7
- === Installation
8
+ * EXPRESS (https://www.expresslang.org[EXPRESS Language Foundation], ISO 10303-11)
9
+ * XMI (from OMG)
10
+ * UML in LutaML format
8
11
 
9
- With bundler:
12
+
13
+ == Install
14
+
15
+ With bundler, in `Gemfile`:
10
16
 
11
17
  [source,ruby]
12
18
  ----
13
- # Gemfile
14
19
  gem "lutaml"
15
20
  ----
16
21
 
17
- Then in console:
22
+ Directly:
18
23
 
19
24
  [source,console]
20
25
  ----
21
- $ bundle
26
+ $ gem install lutaml
22
27
  ----
23
28
 
24
- With RubyGems:
29
+ == Usage
25
30
 
26
- [source,console]
27
- ----
28
- $ gem install lutaml
29
- ----
31
+ === Parsing
30
32
 
31
- === Usage
33
+ The `Lutaml::Parser.parse` method provides a single point of entry for parsing
34
+ data model files.
32
35
 
33
- == From ruby
36
+ The return object is always a `Lutaml::LutamlPath::DocumentWrapper` object,
37
+ where `#original_document` returns the native parsed models.
34
38
 
35
- In order to parse files supported by lutaml extensions, use Lutaml::Parser.parse method.
39
+ [source,ruby]
40
+ ----
41
+ # example.exp is an EXPRESS schema file
42
+ wrapper = Lutaml::Parser.parse([File.new("example.exp")])
43
+ # => returns a Lutaml::LutamlPath::DocumentWrapper object
44
+ wrapper.original_document
45
+ # => returns the original Expressir::Repository object
46
+ ----
36
47
 
37
48
  [source,ruby]
38
49
  ----
39
- # example.exp is an EXPRESS repository file
40
- Lutaml::Parser.parse([File.new("example.exp")]) # will produce Lutaml::LutamlPath::DocumentWrapper object with serialized express repository
41
- # example.yaml is an EXPRESS cache file
42
- Lutaml::Parser.parse([File.new("example.yaml")], ::Lutaml::Parser::EXPRESS_CACHE_PARSE_TYPE)
50
+ # example.exp.yaml is an EXPRESS cache file created with Expressir
51
+ wrapper = Lutaml::Parser.parse([File.new("example.exp.yaml")], ::Lutaml::Parser::EXPRESS_CACHE_PARSE_TYPE)
52
+ # => returns the DocumentWrapper but with the repository loaded from the Expressir cache file
43
53
  ----
44
54
 
45
- == With cli tool
46
55
 
47
- There is a cli tool available for parsing lutaml/exp files(also yaml datastruct files are supported).
56
+ === Selecting EXPRESS schemas
48
57
 
49
- [source,bash]
50
- ----
51
- # Will generate `test.dot` file in the current directory
52
- $: lutaml -o . test.lutaml
58
+ LutaML supports the `ModelElement#to_hash(..., select_proc:)` functionality
59
+ of Expressir, allowing Expressir to only call `to_hash` on schemas that
60
+ fit a dynamic criteria.
53
61
 
54
- # Will generate `test.png` file in the `assets` directory
55
- $: lutaml -o assets -t png test.lutaml
62
+ The criteria is set via a Ruby `Proc` object, as follows.
63
+
64
+ [source,ruby]
65
+ ----
66
+ # Sets the filter
67
+ filtered_schemas = ["action_schema", "date_time_schema"]
68
+
69
+ # Sets the Proc
70
+ wrapper.select_proc = Proc.new do |value|
71
+ if value.is_a?(Expressir::Model::Declarations::Schema)
72
+ filtered_schemas.include?(value.id)
73
+ else
74
+ true
75
+ end
76
+ end
77
+
78
+ serialized = wrapper.to_liquid
79
+ # => returns the filtered to_hash method
56
80
  ----
57
81
 
58
- For additional info refer to `lutaml --help output`
59
82
 
83
+ === CLI
60
84
 
61
- == Development
85
+ There is a command-line interface available for parsing supported data model files.
62
86
 
63
- 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.
87
+ * EXPRESS `*.exp`
88
+ * LutaML UML `*.lutaml`
89
+ * LutaML YAML datastruct files
64
90
 
65
- 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).
91
+ [source,bash]
92
+ ----
93
+ # Will generate `test.dot` file in the current directory
94
+ $ lutaml -o . test.lutaml
66
95
 
67
- ## Contributing
96
+ # Will generate `test.png` file in the `assets` directory
97
+ $ lutaml -o assets -t png test.lutaml
98
+ ----
68
99
 
69
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lutaml. 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/blob/master/CODE_OF_CONDUCT.md).
100
+ For additional info refer to `lutaml --help output`.
70
101
 
71
102
 
72
- == Code of Conduct
103
+ == Copyright and license
73
104
 
74
- 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/blob/master/CODE_OF_CONDUCT.md).
105
+ Copyright Ribose. BSD-3 License.
data/exe/lutaml CHANGED
@@ -12,11 +12,13 @@ $:.unshift File.expand_path("../../lib", bin_file)
12
12
  # Fixes https://github.com/rubygems/rubygems/issues/1420
13
13
  require "rubygems/specification"
14
14
 
15
- class Gem::Specification
16
- def this; self; end
15
+ module Gem
16
+ class Specification
17
+ def this; self; end
18
+ end
17
19
  end
18
20
 
19
21
  require "lutaml"
20
22
  require "lutaml/command_line"
21
23
 
22
- Lutaml::CommandLine.run(ARGV.dup, STDOUT)
24
+ Lutaml::CommandLine.run(ARGV.dup, $stdout)
@@ -21,7 +21,7 @@ module Lutaml
21
21
  new(attributes, out_object).run(args)
22
22
  end
23
23
 
24
- def initialize(attributes = {}, out_object = STDOUT)
24
+ def initialize(attributes = {}, out_object = $stdout)
25
25
  @formatter = ::Lutaml::Formatter::Graphviz.new
26
26
  @verbose = false
27
27
  @option_parser = OptionParser.new
@@ -70,11 +70,15 @@ module Lutaml
70
70
 
71
71
  def run(original_args)
72
72
  args = original_args.dup
73
- if args.length.zero? || args.first.strip == "help"
73
+ if args.empty? || args.first.strip == "help"
74
74
  print_help
75
75
  exit
76
76
  end
77
- @option_parser.parse!(args) rescue nil
77
+ begin
78
+ @option_parser.parse!(args)
79
+ rescue StandardError
80
+ nil
81
+ end
78
82
  @paths = args
79
83
  @formatter.type = @type
80
84
 
@@ -5,11 +5,16 @@ module Lutaml
5
5
  module Express
6
6
  module LutamlPath
7
7
  class DocumentWrapper < ::Lutaml::LutamlPath::DocumentWrapper
8
+ attr_accessor :select_proc
9
+
8
10
  protected
9
11
 
10
12
  def serialize_document(repository)
11
- repository
12
- .to_hash(formatter: Formatter, include_empty: true)
13
+ repository.to_hash(
14
+ formatter: Formatter,
15
+ include_empty: true,
16
+ select_proc: select_proc,
17
+ )
13
18
  end
14
19
  end
15
20
  end
@@ -11,4 +11,4 @@ module Lutaml
11
11
  end
12
12
  end
13
13
  end
14
- end
14
+ end
@@ -44,7 +44,7 @@ module Lutaml
44
44
  when ::Lutaml::Uml::Node::Method then format_method(node)
45
45
  when ::Lutaml::Uml::Node::Relationship then format_relationship(node)
46
46
  when ::Lutaml::Uml::Node::ClassRelationship
47
- then format_class_relationship(node)
47
+ format_class_relationship(node)
48
48
  when ::Lutaml::Uml::Node::ClassNode then format_class(node)
49
49
  when Lutaml::Uml::Document then format_document(node)
50
50
  end
@@ -17,11 +17,11 @@ module Lutaml
17
17
  end
18
18
 
19
19
  ACCESS_SYMBOLS = {
20
- "public" => "+",
20
+ "public" => "+",
21
21
  "protected" => "#",
22
- "private" => "-",
22
+ "private" => "-",
23
23
  }.freeze
24
- DEFAULT_CLASS_FONT = "Helvetica".freeze
24
+ DEFAULT_CLASS_FONT = "Helvetica"
25
25
 
26
26
  VALID_TYPES = %i[
27
27
  dot
@@ -65,9 +65,7 @@ module Lutaml
65
65
  @type = :dot
66
66
  end
67
67
 
68
- attr_reader :graph
69
- attr_reader :edge
70
- attr_reader :node
68
+ attr_reader :graph, :edge, :node
71
69
 
72
70
  def type=(value)
73
71
  super
@@ -147,13 +145,13 @@ module Lutaml
147
145
  if node.owner_end_attribute_name
148
146
  attributes["headlabel"] = format_label(
149
147
  node.owner_end_attribute_name,
150
- node.owner_end_cardinality
148
+ node.owner_end_cardinality,
151
149
  )
152
150
  end
153
151
  if node.member_end_attribute_name
154
152
  attributes["taillabel"] = format_label(
155
153
  node.member_end_attribute_name,
156
- node.member_end_cardinality
154
+ node.member_end_cardinality,
157
155
  )
158
156
  end
159
157
 
@@ -5,11 +5,10 @@ module Lutaml
5
5
 
6
6
  def initialize(document)
7
7
  @original_document = document
8
- @serialized_document = serialize_document(document)
9
8
  end
10
9
 
11
10
  def to_liquid
12
- serialized_document
11
+ @serialized_document ||= serialize_document(@original_document)
13
12
  end
14
13
 
15
14
  protected
@@ -27,7 +26,8 @@ module Lutaml
27
26
  end
28
27
 
29
28
  def serialize_to_hash(object)
30
- return object if [String, Integer, Float, FalseClass, TrueClass, Symbol, NilClass, Hash].include?(object.class)
29
+ return object if [String, Integer, Float, FalseClass, TrueClass,
30
+ Symbol, NilClass, Hash].include?(object.class)
31
31
 
32
32
  object.instance_variables.each_with_object({}) do |var, res|
33
33
  variable = object.instance_variable_get(var)
@@ -35,12 +35,10 @@ module Lutaml
35
35
  variable.map do |n|
36
36
  serialize_to_hash(n)
37
37
  end
38
+ elsif [String, Integer, Float, FalseClass, TrueClass, Symbol, NilClass, Hash].include?(variable.class) || var == :@parent
39
+ variable
38
40
  else
39
- if [String, Integer, Float, FalseClass, TrueClass, Symbol, NilClass, Hash].include?(variable.class) || var == :@parent
40
- variable
41
- else
42
- serialize_to_hash(variable)
43
- end
41
+ serialize_to_hash(variable)
44
42
  end
45
43
  end
46
44
  end
data/lib/lutaml/parser.rb CHANGED
@@ -24,13 +24,14 @@ module Lutaml
24
24
  end
25
25
 
26
26
  def initialize(file_list, input_type)
27
- @parse_type = input_type ? input_type : File.extname(file_list.first.path)[1..-1]
27
+ @parse_type = input_type || File.extname(file_list.first.path)[1..-1]
28
28
  @file_list = file_list
29
29
  end
30
30
 
31
31
  def parse
32
32
  documents = parse_into_document
33
- return document_wrapper(documents) if ["exp", EXPRESS_CACHE_PARSE_TYPE].include?(parse_type)
33
+ return document_wrapper(documents) if ["exp",
34
+ EXPRESS_CACHE_PARSE_TYPE].include?(parse_type)
34
35
 
35
36
  documents.map { |doc| document_wrapper(doc) }
36
37
  end
@@ -41,7 +42,7 @@ module Lutaml
41
42
  Expressir::Express::Parser.from_files(file_list.map(&:path))
42
43
  when EXPRESS_CACHE_PARSE_TYPE
43
44
  Expressir::Express::Cache.from_file(file_list.first.path)
44
- when 'xmi'
45
+ when "xmi"
45
46
  file_list.map { |file| Lutaml::XMI::Parsers::XML.parse(file) }
46
47
  when "lutaml"
47
48
  file_list.map { |file| Lutaml::Uml::Parsers::Dsl.parse(file) }
@@ -1,3 +1,3 @@
1
1
  module Lutaml
2
- VERSION = "0.7.5".freeze
2
+ VERSION = "0.7.6".freeze
3
3
  end
data/lutaml.gemspec CHANGED
@@ -27,16 +27,17 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
+ spec.required_ruby_version = ">= 2.7.0"
31
+
32
+ spec.add_runtime_dependency "expressir", "~> 1.3"
30
33
  spec.add_runtime_dependency "lutaml-express"
31
34
  spec.add_runtime_dependency "lutaml-uml"
32
35
  spec.add_runtime_dependency "lutaml-xmi"
33
- spec.add_runtime_dependency "thor", "~> 1.0"
34
36
  spec.add_runtime_dependency "nokogiri", "~> 1.10"
37
+ spec.add_runtime_dependency "thor", "~> 1.0"
35
38
 
36
- spec.add_development_dependency "bundler", "~> 2.0"
37
- spec.add_development_dependency "byebug"
38
39
  spec.add_development_dependency "pry", "~> 0.12.2"
39
- spec.add_development_dependency "rake", "~> 10.0"
40
- spec.add_development_dependency "rspec", "~> 3.0"
41
- spec.add_development_dependency "rubocop", "~> 0.54.0"
40
+ spec.add_development_dependency "rake", "~> 13.0"
41
+ spec.add_development_dependency "rspec", "~> 3.11"
42
+ spec.add_development_dependency "rubocop", "~> 1.58"
42
43
  end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-20 00:00:00.000000000 Z
11
+ date: 2024-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: lutaml-express
14
+ name: expressir
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
- name: lutaml-uml
28
+ name: lutaml-express
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: lutaml-xmi
42
+ name: lutaml-uml
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: thor
56
+ name: lutaml-xmi
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1.0'
61
+ version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1.0'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: nokogiri
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,33 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.10'
83
83
  - !ruby/object:Gem::Dependency
84
- name: bundler
84
+ name: thor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '2.0'
90
- type: :development
89
+ version: '1.0'
90
+ type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '2.0'
97
- - !ruby/object:Gem::Dependency
98
- name: byebug
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
96
+ version: '1.0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: pry
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -128,42 +114,42 @@ dependencies:
128
114
  requirements:
129
115
  - - "~>"
130
116
  - !ruby/object:Gem::Version
131
- version: '10.0'
117
+ version: '13.0'
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
- version: '10.0'
124
+ version: '13.0'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: rspec
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
129
  - - "~>"
144
130
  - !ruby/object:Gem::Version
145
- version: '3.0'
131
+ version: '3.11'
146
132
  type: :development
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
136
  - - "~>"
151
137
  - !ruby/object:Gem::Version
152
- version: '3.0'
138
+ version: '3.11'
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: rubocop
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
143
  - - "~>"
158
144
  - !ruby/object:Gem::Version
159
- version: 0.54.0
145
+ version: '1.58'
160
146
  type: :development
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
150
  - - "~>"
165
151
  - !ruby/object:Gem::Version
166
- version: 0.54.0
152
+ version: '1.58'
167
153
  description: 'LutaML: data models in textual form'
168
154
  email:
169
155
  - open.source@ribose.com'
@@ -178,7 +164,6 @@ files:
178
164
  - ".hound.yml"
179
165
  - ".rspec"
180
166
  - ".rubocop.yml"
181
- - ".travis.yml"
182
167
  - CODE_OF_CONDUCT.md
183
168
  - Gemfile
184
169
  - README.adoc
@@ -215,14 +200,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
200
  requirements:
216
201
  - - ">="
217
202
  - !ruby/object:Gem::Version
218
- version: '0'
203
+ version: 2.7.0
219
204
  required_rubygems_version: !ruby/object:Gem::Requirement
220
205
  requirements:
221
206
  - - ">="
222
207
  - !ruby/object:Gem::Version
223
208
  version: '0'
224
209
  requirements: []
225
- rubygems_version: 3.1.6
210
+ rubygems_version: 3.3.27
226
211
  signing_key:
227
212
  specification_version: 4
228
213
  summary: 'LutaML: data models in textual form'
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.6.5
6
- before_install: gem install bundler -v 2.1.4