lutaml 0.4.0 → 0.4.1.pre.alpha

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: 84bb179e752bc157f0de4a59ea8cf88e9bd1fe4430726dcefcf63269d12c86fb
4
- data.tar.gz: a5f8917e80a33814b9cc6a9e3556b335da72fe05fd73e4d54dc294d1c4b6a27f
3
+ metadata.gz: 9856bef749609c2186daef72d9cac2275abdf35dee480be0658700d20e0f9e31
4
+ data.tar.gz: f5a0c9decbf6188da822b39655ee14d048387783b28d92a5fa280781e6c02a16
5
5
  SHA512:
6
- metadata.gz: 64b11704d20aff55c53cb6b1d857d346a6e9016b84b091581372c38b100a3d21d499685550e8d5a8b132e4cc7de5e8da37c3efd14ae325d119a207a76fc0feea
7
- data.tar.gz: f9800bc7e40536370807a3e4a3429d60dfa1f2fd728054adf6c9a8e73ba813b20bad80e22c85323309089eb41e1455806381513c139de1a99cc804ebb37378f2
6
+ metadata.gz: f4ccdf6b1a8ef299ce9a255b9615595f68ed6d07159808983451fe637cbda6747d71a03171c49d21f0b2797346e0daca0a9e94a8e55ca9614e734d54588a2b65
7
+ data.tar.gz: 37e385085efc088644b1d582144e5436ad5e4310899f25f4fbfafa090302410d8ce3343601a9c2250b4ac57f3a073b1c996bdbcd982602d6c58a7fc0197c3321
@@ -5,20 +5,6 @@ module Lutaml
5
5
  module Express
6
6
  module LutamlPath
7
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
8
  SOURCE_CODE_ATTRIBUTE_NAME = "sourcecode".freeze
23
9
 
24
10
  protected
@@ -26,20 +12,27 @@ module Lutaml
26
12
  def serialize_document(repository)
27
13
  repository.schemas.each_with_object({}) do |schema, res|
28
14
  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)
15
+ res[schema.id] = serialize_value(schema).merge(SOURCE_CODE_ATTRIBUTE_NAME => entity_source_code(schema))
16
+ res["schemas"].push(res[schema.id])
17
+ end
18
+ end
19
+
20
+ def serialize_value(object)
21
+ object.instance_variables.each_with_object({}) do |var, res|
22
+ variable = object.instance_variable_get(var)
23
+ if variable.respond_to?(:to_hash)
24
+ res[var.to_s.gsub("@", "")] = variable.to_hash.merge(SOURCE_CODE_ATTRIBUTE_NAME => entity_source_code(variable))
25
+ elsif variable.is_a?(Array)
26
+ res[var.to_s.gsub("@", "")] = variable.map do |entity|
27
+ if entity.respond_to?(:to_hash)
28
+ entity.to_hash.merge(SOURCE_CODE_ATTRIBUTE_NAME => entity_source_code(entity))
29
+ else
30
+ entity
31
+ end
36
32
  end
33
+ else
34
+ res[var.to_s.gsub("@", "")] = variable
37
35
  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
36
  end
44
37
  end
45
38
 
@@ -22,11 +22,11 @@ module Lutaml
22
22
  return attr_value.map(&method(:serialize_to_hash))
23
23
  end
24
24
 
25
- attr_value
25
+ serialize_to_hash(attr_value)
26
26
  end
27
27
 
28
28
  def serialize_to_hash(object)
29
- return object if [String, Integer, Float].include?(object.class)
29
+ return object if [String, Integer, Float, FalseClass, TrueClass, Symbol, NilClass].include?(object.class)
30
30
 
31
31
  object.instance_variables.each_with_object({}) do |var, res|
32
32
  variable = object.instance_variable_get(var)
@@ -35,7 +35,11 @@ module Lutaml
35
35
  serialize_to_hash(n)
36
36
  end
37
37
  else
38
- variable
38
+ if [String, Integer, Float, FalseClass, TrueClass, Symbol, NilClass].include?(variable.class) || var == :@parent
39
+ variable
40
+ else
41
+ serialize_to_hash(variable)
42
+ end
39
43
  end
40
44
  end
41
45
  end
data/lib/lutaml/parser.rb CHANGED
@@ -1,7 +1,7 @@
1
- # require "lutaml/express"
1
+ require "lutaml/express"
2
2
  require "lutaml/uml"
3
3
  require "lutaml/uml/lutaml_path/document_wrapper"
4
- # require "lutaml/express/lutaml_path/document_wrapper"
4
+ require "lutaml/express/lutaml_path/document_wrapper"
5
5
 
6
6
  module Lutaml
7
7
  class Parser
@@ -29,8 +29,8 @@ module Lutaml
29
29
 
30
30
  def parse_into_document
31
31
  case parse_type
32
- # when "exp"
33
- # Lutaml::Express::Parsers::Exp.parse(file)
32
+ when "exp"
33
+ Lutaml::Express::Parsers::Exp.parse(file)
34
34
  when "lutaml"
35
35
  Lutaml::Uml::Parsers::Dsl.parse(file)
36
36
  when "yml"
@@ -1,3 +1,3 @@
1
1
  module Lutaml
2
- VERSION = "0.4.0".freeze
2
+ VERSION = "0.4.1-alpha".freeze
3
3
  end
data/lutaml.gemspec CHANGED
@@ -27,7 +27,7 @@ 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.add_runtime_dependency "lutaml-express", "~> 0.1.3"
30
+ spec.add_runtime_dependency "lutaml-express", "~> 0.1.3"
31
31
  spec.add_runtime_dependency "lutaml-uml", "~> 0.2.5"
32
32
  spec.add_runtime_dependency "thor", "~> 1.0"
33
33
  spec.add_development_dependency "nokogiri", "~> 1.10"
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.0
4
+ version: 0.4.1.pre.alpha
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-01-18 00:00:00.000000000 Z
11
+ date: 2021-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lutaml-express
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.3
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: lutaml-uml
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -188,9 +202,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
188
202
  version: '0'
189
203
  required_rubygems_version: !ruby/object:Gem::Requirement
190
204
  requirements:
191
- - - ">="
205
+ - - ">"
192
206
  - !ruby/object:Gem::Version
193
- version: '0'
207
+ version: 1.3.1
194
208
  requirements: []
195
209
  rubygems_version: 3.0.3
196
210
  signing_key: