lutaml 0.4.1.pre.alpha.1 → 0.4.1.pre.alpha.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: 0e2accd48e5932fbf111f54429604e7709a98418d6b9c97af40f29c8547a7238
4
+ data.tar.gz: 6561a16f4d783ddc50812af99e3da854dc2a8673be5e2cc9e7adcffa1678099f
5
5
  SHA512:
6
- metadata.gz: 34dd93e727898bd84c2257dd8d0e10d7f731775d11efc9f9109a2113a382779c00fb1b0be9bcffd174e2610503e12993c0d2306bb629d2f700f970206deddb90
7
- data.tar.gz: f754762c5197831a3cceba0a46cbe2868ae13e40b69f05e1e5d6c08c4ea4c8b69cb045c960833a5d1bbdcfb7fb0316d382795099330325725e16feae736fab33
6
+ metadata.gz: 3006890a278d837602f7c3149c46b7810a7f5e367100862eac17ac7e54ef2bf18623b9bb8a98483b12cec3fe52bfbef1e3f3c40b7231b7d669c31b0b5e3548f1
7
+ data.tar.gz: c509f969284fc89e5a4d3293426a71ff861aa8283f33193114887d55d2173427a988998db906d18ea94e1a821db07147a213f892052241dd383c6e36556fa2b0
@@ -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 "expressir/express_exp/hyperlink_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: Expressir::ExpressExp::HyperlinkFormatter)['schemas']
18
13
  end
19
14
  end
20
15
  end
data/lib/lutaml/parser.rb CHANGED
@@ -5,36 +5,40 @@ require "lutaml/express/lutaml_path/document_wrapper"
5
5
 
6
6
  module Lutaml
7
7
  class Parser
8
- attr_reader :parse_type, :file
8
+ attr_reader :parse_type, :file_list
9
9
 
10
10
  class << self
11
- def parse(file, input_type = nil)
12
- new(file, input_type).parse
11
+ def parse(file_list, input_type = nil)
12
+ file_list = file_list.is_a?(Array) ? file_list : [file_list]
13
+ new(Array(file_list), input_type).parse
13
14
  end
14
15
 
15
- def parse_into_document(file, input_type = nil)
16
- new(file, input_type).parse_into_document
16
+ def parse_into_document(file_list, input_type = nil)
17
+ file_list = file_list.is_a?(Array) ? file_list : [file_list]
18
+ new(Array(file_list), input_type).parse_into_document
17
19
  end
18
20
  end
19
21
 
20
- def initialize(file, input_type)
21
- @parse_type = input_type ? input_type : File.extname(file.path)[1..-1]
22
- @file = file
22
+ def initialize(file_list, input_type)
23
+ @parse_type = input_type ? input_type : File.extname(file_list.first.path)[1..-1]
24
+ @file_list = file_list
23
25
  end
24
26
 
25
27
  def parse
26
- document = parse_into_document
27
- document_wrapper(document)
28
+ documents = parse_into_document
29
+ return [document_wrapper(documents)] if parse_type == "exp"
30
+
31
+ documents.map { |doc| document_wrapper(doc) }
28
32
  end
29
33
 
30
34
  def parse_into_document
31
35
  case parse_type
32
36
  when "exp"
33
- Lutaml::Express::Parsers::Exp.parse(file)
37
+ Expressir::ExpressExp::Parser.from_files(file_list.map(&:path))
34
38
  when "lutaml"
35
- Lutaml::Uml::Parsers::Dsl.parse(file)
39
+ file_list.map { |file| Lutaml::Uml::Parsers::Dsl.parse(file) }
36
40
  when "yml"
37
- Lutaml::Uml::Parsers::Yaml.parse(file.path)
41
+ file_list.map { |file| Lutaml::Uml::Parsers::Yaml.parse(file.path) }
38
42
  else
39
43
  raise ArgumentError, "Unsupported file format"
40
44
  end
@@ -1,3 +1,3 @@
1
1
  module Lutaml
2
- VERSION = "0.4.1-alpha.1".freeze
2
+ VERSION = "0.4.1-alpha.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.4.1.pre.alpha.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-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-express