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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f585ad7b175177afe9ac1e3c9a243a7d7f5b4f471eab0268db07c5416071ed7
4
- data.tar.gz: 04ea818d961eb1b594f41417a73785d4be620acc81301a1da8f98faa9dae4b2d
3
+ metadata.gz: c570c69bf1b1fce5a01012f692e017bd140f3298e576f2a1ac5aa28f79389e3c
4
+ data.tar.gz: a63175e2fa1b7c2dd147116924f7767aa197ac9da40dc2389d646da5d4b6cf1c
5
5
  SHA512:
6
- metadata.gz: 34dd93e727898bd84c2257dd8d0e10d7f731775d11efc9f9109a2113a382779c00fb1b0be9bcffd174e2610503e12993c0d2306bb629d2f700f970206deddb90
7
- data.tar.gz: f754762c5197831a3cceba0a46cbe2868ae13e40b69f05e1e5d6c08c4ea4c8b69cb045c960833a5d1bbdcfb7fb0316d382795099330325725e16feae736fab33
6
+ metadata.gz: aa45c7df071a37185d9b3fc7ca78fc54c288591da1cbc9e823546d108d76ddf60d86a220165939ffba6c62300a07c8cb7f6e93dbe5b18e8b39ed83c040e0f4ec
7
+ data.tar.gz: 1939181b7331780c4b894ffb096af7ca332b3f0253d38b7a6f74c6d8b1760dfcc4f6f3d3268db4fd1fdfe6f01fa2046796b2c8febf0ef1cb694dc3a98c243567
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ gem "expressir"
4
+
3
5
  # Specify your gem's dependencies in lutaml.gemspec
4
6
  gemspec
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
@@ -88,6 +88,7 @@ module Lutaml
88
88
 
89
89
  document = Lutaml::Parser
90
90
  .parse_into_document(File.new(input_path), @input_format)
91
+ .first
91
92
  result = @formatter.format(document)
92
93
 
93
94
  if @output_path
@@ -1,20 +1,15 @@
1
1
  require "lutaml/lutaml_path/document_wrapper"
2
- require "expressir/express_exp/formatter"
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.schemas.each_with_object({}) do |schema, res|
14
- res["schemas"] ||= []
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
- attr_reader :parse_type, :file
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(file, input_type = nil)
12
- new(file, input_type).parse
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(file, input_type = nil)
16
- new(file, input_type).parse_into_document
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(file, input_type)
21
- @parse_type = input_type ? input_type : File.extname(file.path)[1..-1]
22
- @file = file
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
- document = parse_into_document
27
- document_wrapper(document)
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
- Lutaml::Express::Parsers::Exp.parse(file)
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 parse_type == "exp"
55
+ if ["exp", EXPRESS_CACHE_PARSE_TYPE].include?(parse_type)
47
56
  return Lutaml::Express::LutamlPath::DocumentWrapper.new(document)
48
57
  end
49
58
 
@@ -1,3 +1,3 @@
1
1
  module Lutaml
2
- VERSION = "0.4.1-alpha.1".freeze
2
+ VERSION = "0.5.2".freeze
3
3
  end
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.1.pre.alpha.1
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-02-09 00:00:00.000000000 Z
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: 1.3.1
208
+ version: '0'
208
209
  requirements: []
209
210
  rubygems_version: 3.0.3
210
211
  signing_key: