lutaml 0.4.1.pre.alpha.1 → 0.5.2
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/Gemfile +2 -0
- data/README.adoc +3 -1
- data/lib/lutaml/command_line.rb +1 -0
- data/lib/lutaml/express/lutaml_path/document_wrapper.rb +3 -8
- data/lib/lutaml/express/lutaml_path/formatter.rb +14 -0
- data/lib/lutaml/lutaml_path/document_wrapper.rb +4 -3
- data/lib/lutaml/parser.rb +23 -14
- data/lib/lutaml/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c570c69bf1b1fce5a01012f692e017bd140f3298e576f2a1ac5aa28f79389e3c
|
4
|
+
data.tar.gz: a63175e2fa1b7c2dd147116924f7767aa197ac9da40dc2389d646da5d4b6cf1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa45c7df071a37185d9b3fc7ca78fc54c288591da1cbc9e823546d108d76ddf60d86a220165939ffba6c62300a07c8cb7f6e93dbe5b18e8b39ed83c040e0f4ec
|
7
|
+
data.tar.gz: 1939181b7331780c4b894ffb096af7ca332b3f0253d38b7a6f74c6d8b1760dfcc4f6f3d3268db4fd1fdfe6f01fa2046796b2c8febf0ef1cb694dc3a98c243567
|
data/Gemfile
CHANGED
data/README.adoc
CHANGED
@@ -37,7 +37,9 @@ In order to parse files supported by lutaml extensions, use Lutaml::Parser.parse
|
|
37
37
|
[source,ruby]
|
38
38
|
----
|
39
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
|
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)
|
41
43
|
----
|
42
44
|
|
43
45
|
== With cli tool
|
data/lib/lutaml/command_line.rb
CHANGED
@@ -1,20 +1,15 @@
|
|
1
1
|
require "lutaml/lutaml_path/document_wrapper"
|
2
|
-
require "
|
2
|
+
require "lutaml/express/lutaml_path/formatter"
|
3
3
|
|
4
4
|
module Lutaml
|
5
5
|
module Express
|
6
6
|
module LutamlPath
|
7
7
|
class DocumentWrapper < ::Lutaml::LutamlPath::DocumentWrapper
|
8
|
-
SOURCE_CODE_ATTRIBUTE_NAME = "sourcecode".freeze
|
9
|
-
|
10
8
|
protected
|
11
9
|
|
12
10
|
def serialize_document(repository)
|
13
|
-
repository
|
14
|
-
|
15
|
-
res[schema.id] = schema.to_hash(formatter: Expressir::ExpressExp::Formatter)
|
16
|
-
res["schemas"].push(res[schema.id])
|
17
|
-
end
|
11
|
+
repository
|
12
|
+
.to_hash(formatter: Formatter)
|
18
13
|
end
|
19
14
|
end
|
20
15
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "expressir/express_exp/formatter"
|
2
|
+
require "expressir/express_exp/schema_head_formatter"
|
3
|
+
require "expressir/express_exp/hyperlink_formatter"
|
4
|
+
|
5
|
+
module Lutaml
|
6
|
+
module Express
|
7
|
+
module LutamlPath
|
8
|
+
class Formatter < Expressir::ExpressExp::Formatter
|
9
|
+
include Expressir::ExpressExp::SchemaHeadFormatter
|
10
|
+
include Expressir::ExpressExp::HyperlinkFormatter
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module Lutaml
|
2
2
|
module LutamlPath
|
3
3
|
class DocumentWrapper
|
4
|
-
attr_reader :serialized_document
|
4
|
+
attr_reader :serialized_document, :original_document
|
5
5
|
|
6
6
|
def initialize(document)
|
7
|
+
@original_document = document
|
7
8
|
@serialized_document = serialize_document(document)
|
8
9
|
end
|
9
10
|
|
@@ -26,7 +27,7 @@ module Lutaml
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def serialize_to_hash(object)
|
29
|
-
return object if [String, Integer, Float, FalseClass, TrueClass, Symbol, NilClass].include?(object.class)
|
30
|
+
return object if [String, Integer, Float, FalseClass, TrueClass, Symbol, NilClass, Hash].include?(object.class)
|
30
31
|
|
31
32
|
object.instance_variables.each_with_object({}) do |var, res|
|
32
33
|
variable = object.instance_variable_get(var)
|
@@ -35,7 +36,7 @@ module Lutaml
|
|
35
36
|
serialize_to_hash(n)
|
36
37
|
end
|
37
38
|
else
|
38
|
-
if [String, Integer, Float, FalseClass, TrueClass, Symbol, NilClass].include?(variable.class) || var == :@parent
|
39
|
+
if [String, Integer, Float, FalseClass, TrueClass, Symbol, NilClass, Hash].include?(variable.class) || var == :@parent
|
39
40
|
variable
|
40
41
|
else
|
41
42
|
serialize_to_hash(variable)
|
data/lib/lutaml/parser.rb
CHANGED
@@ -2,39 +2,48 @@ require "lutaml/express"
|
|
2
2
|
require "lutaml/uml"
|
3
3
|
require "lutaml/uml/lutaml_path/document_wrapper"
|
4
4
|
require "lutaml/express/lutaml_path/document_wrapper"
|
5
|
+
require "expressir/express_exp/cache"
|
5
6
|
|
6
7
|
module Lutaml
|
7
8
|
class Parser
|
8
|
-
|
9
|
+
EXPRESS_CACHE_PARSE_TYPE = "exp.cache".freeze
|
10
|
+
|
11
|
+
attr_reader :parse_type, :file_list
|
9
12
|
|
10
13
|
class << self
|
11
|
-
def parse(
|
12
|
-
|
14
|
+
def parse(file_list, input_type = nil)
|
15
|
+
file_list = file_list.is_a?(Array) ? file_list : [file_list]
|
16
|
+
new(Array(file_list), input_type).parse
|
13
17
|
end
|
14
18
|
|
15
|
-
def parse_into_document(
|
16
|
-
|
19
|
+
def parse_into_document(file_list, input_type = nil)
|
20
|
+
file_list = file_list.is_a?(Array) ? file_list : [file_list]
|
21
|
+
new(Array(file_list), input_type).parse_into_document
|
17
22
|
end
|
18
23
|
end
|
19
24
|
|
20
|
-
def initialize(
|
21
|
-
@parse_type = input_type ? input_type : File.extname(
|
22
|
-
@
|
25
|
+
def initialize(file_list, input_type)
|
26
|
+
@parse_type = input_type ? input_type : File.extname(file_list.first.path)[1..-1]
|
27
|
+
@file_list = file_list
|
23
28
|
end
|
24
29
|
|
25
30
|
def parse
|
26
|
-
|
27
|
-
document_wrapper(
|
31
|
+
documents = parse_into_document
|
32
|
+
return document_wrapper(documents) if ["exp", EXPRESS_CACHE_PARSE_TYPE].include?(parse_type)
|
33
|
+
|
34
|
+
documents.map { |doc| document_wrapper(doc) }
|
28
35
|
end
|
29
36
|
|
30
37
|
def parse_into_document
|
31
38
|
case parse_type
|
32
39
|
when "exp"
|
33
|
-
|
40
|
+
Expressir::ExpressExp::Parser.from_files(file_list.map(&:path))
|
41
|
+
when EXPRESS_CACHE_PARSE_TYPE
|
42
|
+
Expressir::ExpressExp::Cache.from_file(file_list.first.path)
|
34
43
|
when "lutaml"
|
35
|
-
Lutaml::Uml::Parsers::Dsl.parse(file)
|
44
|
+
file_list.map { |file| Lutaml::Uml::Parsers::Dsl.parse(file) }
|
36
45
|
when "yml"
|
37
|
-
Lutaml::Uml::Parsers::Yaml.parse(file.path)
|
46
|
+
file_list.map { |file| Lutaml::Uml::Parsers::Yaml.parse(file.path) }
|
38
47
|
else
|
39
48
|
raise ArgumentError, "Unsupported file format"
|
40
49
|
end
|
@@ -43,7 +52,7 @@ module Lutaml
|
|
43
52
|
private
|
44
53
|
|
45
54
|
def document_wrapper(document)
|
46
|
-
if
|
55
|
+
if ["exp", EXPRESS_CACHE_PARSE_TYPE].include?(parse_type)
|
47
56
|
return Lutaml::Express::LutamlPath::DocumentWrapper.new(document)
|
48
57
|
end
|
49
58
|
|
data/lib/lutaml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lutaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lutaml-express
|
@@ -174,6 +174,7 @@ files:
|
|
174
174
|
- lib/lutaml.rb
|
175
175
|
- lib/lutaml/command_line.rb
|
176
176
|
- lib/lutaml/express/lutaml_path/document_wrapper.rb
|
177
|
+
- lib/lutaml/express/lutaml_path/formatter.rb
|
177
178
|
- lib/lutaml/formatter.rb
|
178
179
|
- lib/lutaml/formatter/base.rb
|
179
180
|
- lib/lutaml/formatter/graphviz.rb
|
@@ -202,9 +203,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
202
203
|
version: '0'
|
203
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
205
|
requirements:
|
205
|
-
- - "
|
206
|
+
- - ">="
|
206
207
|
- !ruby/object:Gem::Version
|
207
|
-
version:
|
208
|
+
version: '0'
|
208
209
|
requirements: []
|
209
210
|
rubygems_version: 3.0.3
|
210
211
|
signing_key:
|