lutaml 0.1.0 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +39 -0
- data/.github/workflows/ubuntu.yml +38 -0
- data/.github/workflows/windows.yml +41 -0
- data/.gitignore +1 -0
- data/Gemfile +0 -3
- data/{README.md → README.adoc} +31 -17
- data/Rakefile +1 -1
- data/lib/lutaml.rb +1 -2
- data/lib/lutaml/express/lutaml_path/document_wrapper.rb +59 -0
- data/lib/lutaml/lutaml_path/document_wrapper.rb +42 -0
- data/lib/lutaml/parser.rb +23 -0
- data/lib/lutaml/uml/lutaml_path/document_wrapper.rb +15 -0
- data/lib/lutaml/version.rb +1 -1
- data/lutaml.gemspec +6 -5
- metadata +55 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4cf5092c3121c8b3c2e3caa93d8b5fb9b041eb1bdd563e2ad7d5b803f16685f
|
4
|
+
data.tar.gz: 0e7e102b348acc3b3b7506ec8403f7e598611297c8fe0a3ba82fc4855686d0af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5ee064152d5f79c6f1e37ea3fa9f81fdd494b03108868396839d7c09200d5757a3303d187776d3bdfd8bb895b17e9a73720bdea1bd2d919f4ff1c276375b269
|
7
|
+
data.tar.gz: 50fef95d71aa35883365b2e5fd7889dafc2ba4a7b6bed62333f8e4ba8ebe281ec45550f0a8b08871573b4c8757f8cbdc94488a08fc0df3df490b8f74f5d4dbd2
|
@@ -0,0 +1,39 @@
|
|
1
|
+
name: macos
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
paths-ignore:
|
8
|
+
- .github/workflows/ubuntu.yml
|
9
|
+
- .github/workflows/windows.yml
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
test-macos:
|
13
|
+
name: Test on Ruby ${{ matrix.ruby }} macOS
|
14
|
+
runs-on: macos-latest
|
15
|
+
continue-on-error: ${{ matrix.experimental }}
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby: [ '2.6', '2.5' ]
|
20
|
+
experimental: [false]
|
21
|
+
include:
|
22
|
+
- ruby: '2.7'
|
23
|
+
experimental: true
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@master
|
26
|
+
- name: Install build tools
|
27
|
+
run: |
|
28
|
+
brew install automake libtool
|
29
|
+
- name: Use Ruby
|
30
|
+
uses: actions/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
33
|
+
- name: Update gems
|
34
|
+
run: |
|
35
|
+
sudo gem install bundler --force
|
36
|
+
bundle install --jobs 4 --retry 3
|
37
|
+
- name: Run specs
|
38
|
+
run: |
|
39
|
+
bundle exec rake
|
@@ -0,0 +1,38 @@
|
|
1
|
+
name: ubuntu
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
tags:
|
7
|
+
- '*'
|
8
|
+
pull_request:
|
9
|
+
paths-ignore:
|
10
|
+
- .github/workflows/macos.yml
|
11
|
+
- .github/workflows/windows.yml
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
test-linux:
|
15
|
+
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
16
|
+
runs-on: ubuntu-latest
|
17
|
+
continue-on-error: ${{ matrix.experimental }}
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
ruby: [ '2.6', '2.5' ]
|
22
|
+
experimental: [false]
|
23
|
+
include:
|
24
|
+
- ruby: '2.7'
|
25
|
+
experimental: true
|
26
|
+
steps:
|
27
|
+
- uses: actions/checkout@master
|
28
|
+
- name: Use Ruby
|
29
|
+
uses: actions/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby-version: ${{ matrix.ruby }}
|
32
|
+
- name: Update gems
|
33
|
+
run: |
|
34
|
+
gem install bundler
|
35
|
+
bundle install --jobs 4 --retry 3
|
36
|
+
- name: Run specs
|
37
|
+
run: |
|
38
|
+
bundle exec rake
|
@@ -0,0 +1,41 @@
|
|
1
|
+
name: windows
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
paths-ignore:
|
8
|
+
- .github/workflows/macos.yml
|
9
|
+
- .github/workflows/ubuntu.yml
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
test-windows:
|
13
|
+
name: Test on Ruby ${{ matrix.ruby }} Windows
|
14
|
+
runs-on: windows-latest
|
15
|
+
continue-on-error: ${{ matrix.experimental }}
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby: [ '2.6', '2.5' ]
|
20
|
+
experimental: [false]
|
21
|
+
# Does not supported yet:
|
22
|
+
# Ruby (< 2.7.dev, >= 2.3), which is required by gem 'nokogiri (~> 1.10)', is not
|
23
|
+
# available in the local ruby installation
|
24
|
+
# include:
|
25
|
+
# - ruby: '2.7'
|
26
|
+
# experimental: true
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@master
|
29
|
+
- name: Use Ruby
|
30
|
+
uses: actions/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
33
|
+
- name: Update gems
|
34
|
+
shell: pwsh
|
35
|
+
run: |
|
36
|
+
gem install bundler
|
37
|
+
bundle config --local path vendor/bundle
|
38
|
+
bundle install --jobs 4 --retry 3
|
39
|
+
- name: Run specs
|
40
|
+
run: |
|
41
|
+
bundle exec rake
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/{README.md → README.adoc}
RENAMED
@@ -1,30 +1,44 @@
|
|
1
|
-
|
1
|
+
= Lutaml
|
2
2
|
|
3
|
-
|
3
|
+
== Functionality
|
4
4
|
|
5
|
-
|
5
|
+
Entry point for lutaml extensions.
|
6
6
|
|
7
|
-
|
7
|
+
=== Installation
|
8
8
|
|
9
|
-
|
9
|
+
With bundler:
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
[source,ruby]
|
12
|
+
----
|
13
|
+
# Gemfile
|
14
|
+
gem "lutaml"
|
15
|
+
----
|
14
16
|
|
15
|
-
|
17
|
+
Then in console:
|
16
18
|
|
17
|
-
|
19
|
+
[source,console]
|
20
|
+
----
|
21
|
+
$ bundle
|
22
|
+
----
|
18
23
|
|
19
|
-
|
24
|
+
With RubyGems:
|
20
25
|
|
21
|
-
|
26
|
+
[source,console]
|
27
|
+
----
|
28
|
+
$ gem install lutaml
|
29
|
+
----
|
22
30
|
|
23
|
-
|
31
|
+
=== Usage
|
24
32
|
|
25
|
-
|
33
|
+
In order to parse files supported by lutaml extensions, use Lutaml::Parser.parse method(currently only .exp are supported):
|
26
34
|
|
27
|
-
|
35
|
+
[source,ruby]
|
36
|
+
----
|
37
|
+
# example.exp is an EXPRESS repository file
|
38
|
+
Lutaml::Parser.parse(File.new("example.exp")) # will produce Lutaml::LutamlPath::DocumentWrapper object with serialized express repository
|
39
|
+
----
|
40
|
+
|
41
|
+
== Development
|
28
42
|
|
29
43
|
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.
|
30
44
|
|
@@ -35,6 +49,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
35
49
|
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).
|
36
50
|
|
37
51
|
|
38
|
-
|
52
|
+
== Code of Conduct
|
39
53
|
|
40
|
-
Everyone interacting in the Lutaml 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).
|
54
|
+
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).
|
data/Rakefile
CHANGED
data/lib/lutaml.rb
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
require "lutaml/lutaml_path/document_wrapper"
|
2
|
+
require "expressir/express_exp/formatter"
|
3
|
+
|
4
|
+
module Lutaml
|
5
|
+
module Express
|
6
|
+
module LutamlPath
|
7
|
+
class DocumentWrapper < ::Lutaml::LutamlPath::DocumentWrapper
|
8
|
+
SCHEMA_ATTRIBUTES = %w[
|
9
|
+
id
|
10
|
+
constants
|
11
|
+
declarations
|
12
|
+
entities
|
13
|
+
functions
|
14
|
+
interfaces
|
15
|
+
procedures
|
16
|
+
remarks
|
17
|
+
rules
|
18
|
+
subtype_constraints
|
19
|
+
types
|
20
|
+
version
|
21
|
+
].freeze
|
22
|
+
SOURCE_CODE_ATTRIBUTE_NAME = "sourcecode".freeze
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def serialize_document(repository)
|
27
|
+
repository.schemas.each_with_object({}) do |schema, res|
|
28
|
+
res["schemas"] ||= []
|
29
|
+
serialized_schema = SCHEMA_ATTRIBUTES
|
30
|
+
.each_with_object({}) do |name, nested_res|
|
31
|
+
attr_value = schema.send(name)
|
32
|
+
nested_res[name] = serialize_value(attr_value)
|
33
|
+
if name == "entities"
|
34
|
+
nested_res[name] = merge_source_code_attr(nested_res[name],
|
35
|
+
attr_value)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
res[schema.id] = serialized_schema
|
39
|
+
serialized_schema = serialized_schema
|
40
|
+
.merge(SOURCE_CODE_ATTRIBUTE_NAME =>
|
41
|
+
entity_source_code(schema))
|
42
|
+
res["schemas"].push(serialized_schema)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def merge_source_code_attr(serialized_entries, entities)
|
47
|
+
serialized_entries.map do |serialized|
|
48
|
+
entity = entities.detect { |n| n.id == serialized["id"] }
|
49
|
+
serialized.merge(SOURCE_CODE_ATTRIBUTE_NAME => entity_source_code(entity))
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def entity_source_code(entity)
|
54
|
+
Expressir::ExpressExp::Formatter.format(entity)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Lutaml
|
2
|
+
module LutamlPath
|
3
|
+
class DocumentWrapper
|
4
|
+
attr_reader :serialized_document
|
5
|
+
|
6
|
+
def initialize(document)
|
7
|
+
@serialized_document = serialize_document(document)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_liquid
|
11
|
+
serialized_document
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def serialize_document(_path)
|
17
|
+
raise ArgumentError, "implement #serialize_document!"
|
18
|
+
end
|
19
|
+
|
20
|
+
def serialize_value(attr_value)
|
21
|
+
if attr_value.is_a?(Array)
|
22
|
+
return attr_value.map(&method(:serialize_to_hash))
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_value
|
26
|
+
end
|
27
|
+
|
28
|
+
def serialize_to_hash(object)
|
29
|
+
return object if [String, Integer, Float].include?(object.class)
|
30
|
+
|
31
|
+
object.instance_variables.each_with_object({}) do |var, res|
|
32
|
+
variable = object.instance_variable_get(var)
|
33
|
+
res[var.to_s.gsub("@", "")] = if variable.is_a?(Array)
|
34
|
+
variable.map { |n| serialize_to_hash(n) }
|
35
|
+
else
|
36
|
+
variable
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# require "lutaml/express"
|
2
|
+
require "lutaml/uml"
|
3
|
+
require "lutaml/uml/lutaml_path/document_wrapper"
|
4
|
+
# require "lutaml/express/lutaml_path/document_wrapper"
|
5
|
+
|
6
|
+
module Lutaml
|
7
|
+
module Parser
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def parse(file)
|
11
|
+
case File.extname(file.path)[1..-1]
|
12
|
+
# when "exp"
|
13
|
+
# Lutaml::Express::LutamlPath::DocumentWrapper
|
14
|
+
# .new(Lutaml::Express::Parsers::Exp.parse(file))
|
15
|
+
when "lutaml"
|
16
|
+
Lutaml::Uml::LutamlPath::DocumentWrapper
|
17
|
+
.new(Lutaml::Uml::Parsers::Dsl.parse(file))
|
18
|
+
else
|
19
|
+
raise ArgumentError, "Unsupported file format"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "lutaml/lutaml_path/document_wrapper"
|
2
|
+
|
3
|
+
module Lutaml
|
4
|
+
module Uml
|
5
|
+
module LutamlPath
|
6
|
+
class DocumentWrapper < ::Lutaml::LutamlPath::DocumentWrapper
|
7
|
+
protected
|
8
|
+
|
9
|
+
def serialize_document(document)
|
10
|
+
serialize_to_hash(document)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/lutaml/version.rb
CHANGED
data/lutaml.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "lib/lutaml/version"
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "lutaml"
|
@@ -17,21 +17,22 @@ Gem::Specification.new do |spec|
|
|
17
17
|
|
18
18
|
# Specify which files should be added to the gem when it is released.
|
19
19
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
20
|
-
spec.files
|
20
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
21
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
22
|
end
|
23
23
|
spec.bindir = "exe"
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ["lib"]
|
26
26
|
|
27
|
+
# spec.add_runtime_dependency "lutaml-express", "~> 0.1.3"
|
28
|
+
spec.add_runtime_dependency "lutaml-uml", "~> 0.2.5"
|
27
29
|
spec.add_runtime_dependency "thor", "~> 1.0"
|
28
|
-
# spec.add_runtime_dependency "activesupport", "~> 5.0"
|
29
|
-
# spec.add_runtime_dependency "lutaml-uml"
|
30
|
-
# spec.add_runtime_dependency "lutaml-sysml"
|
31
30
|
spec.add_development_dependency "nokogiri", "~> 1.10"
|
32
31
|
|
33
32
|
spec.add_development_dependency "bundler", "~> 2.0"
|
33
|
+
spec.add_development_dependency "byebug"
|
34
34
|
spec.add_development_dependency "pry", "~> 0.12.2"
|
35
35
|
spec.add_development_dependency "rake", "~> 10.0"
|
36
36
|
spec.add_development_dependency "rspec", "~> 3.0"
|
37
|
+
spec.add_development_dependency "rubocop", "~> 0.54.0"
|
37
38
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lutaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lutaml-uml
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.5
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: thor
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +66,20 @@ dependencies:
|
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: pry
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +122,20 @@ dependencies:
|
|
94
122
|
- - "~>"
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.54.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.54.0
|
97
139
|
description: 'LutaML: data models in textual form'
|
98
140
|
email:
|
99
141
|
- open.source@ribose.com'
|
@@ -101,16 +143,23 @@ executables: []
|
|
101
143
|
extensions: []
|
102
144
|
extra_rdoc_files: []
|
103
145
|
files:
|
146
|
+
- ".github/workflows/macos.yml"
|
147
|
+
- ".github/workflows/ubuntu.yml"
|
148
|
+
- ".github/workflows/windows.yml"
|
104
149
|
- ".gitignore"
|
105
150
|
- ".rspec"
|
106
151
|
- ".travis.yml"
|
107
152
|
- CODE_OF_CONDUCT.md
|
108
153
|
- Gemfile
|
109
|
-
- README.
|
154
|
+
- README.adoc
|
110
155
|
- Rakefile
|
111
156
|
- bin/console
|
112
157
|
- bin/setup
|
113
158
|
- lib/lutaml.rb
|
159
|
+
- lib/lutaml/express/lutaml_path/document_wrapper.rb
|
160
|
+
- lib/lutaml/lutaml_path/document_wrapper.rb
|
161
|
+
- lib/lutaml/parser.rb
|
162
|
+
- lib/lutaml/uml/lutaml_path/document_wrapper.rb
|
114
163
|
- lib/lutaml/version.rb
|
115
164
|
- lutaml.gemspec
|
116
165
|
homepage: https://github.com/lutaml/lutaml
|
@@ -120,7 +169,7 @@ metadata:
|
|
120
169
|
homepage_uri: https://github.com/lutaml/lutaml
|
121
170
|
source_code_uri: https://github.com/lutaml/lutaml
|
122
171
|
changelog_uri: https://github.com/lutaml/lutaml/releases
|
123
|
-
post_install_message:
|
172
|
+
post_install_message:
|
124
173
|
rdoc_options: []
|
125
174
|
require_paths:
|
126
175
|
- lib
|
@@ -136,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
185
|
version: '0'
|
137
186
|
requirements: []
|
138
187
|
rubygems_version: 3.0.3
|
139
|
-
signing_key:
|
188
|
+
signing_key:
|
140
189
|
specification_version: 4
|
141
190
|
summary: 'LutaML: data models in textual form'
|
142
191
|
test_files: []
|