lutaml 0.1.0 → 0.3.3

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: e7f00bf561618a5ec3d7b20029bad9a13d7ab890a2e68e913f240400a4883721
4
- data.tar.gz: bbd6aadab7e336af89b560596b5f4f9424c8888b1c9a6e4149ceced4ea4b247f
3
+ metadata.gz: a4cf5092c3121c8b3c2e3caa93d8b5fb9b041eb1bdd563e2ad7d5b803f16685f
4
+ data.tar.gz: 0e7e102b348acc3b3b7506ec8403f7e598611297c8fe0a3ba82fc4855686d0af
5
5
  SHA512:
6
- metadata.gz: 996c1f4909adcbc85713ca109bea104371d4c2f87a9c37171f93b8a01d0ea2e29091f0b4838fd06b6a2ec07eacb3bc735c4c991fdf5ee0804a676794db42532c
7
- data.tar.gz: cd43ed7577632c89afcad888c46c38392f4fb827fc248225ba5d6d2d997ab97a5afc672ceca8543caff29ad34d700b42f1e27ebf9fa4eed98aca854c1bf39b66
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
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ Gemfile.lock
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/Gemfile CHANGED
@@ -2,6 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in lutaml.gemspec
4
4
  gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "rspec", "~> 3.0"
@@ -1,30 +1,44 @@
1
- # Lutaml
1
+ = Lutaml
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lutaml`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ == Functionality
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Entry point for lutaml extensions.
6
6
 
7
- ## Installation
7
+ === Installation
8
8
 
9
- Add this line to your application's Gemfile:
9
+ With bundler:
10
10
 
11
- ```ruby
12
- gem 'lutaml'
13
- ```
11
+ [source,ruby]
12
+ ----
13
+ # Gemfile
14
+ gem "lutaml"
15
+ ----
14
16
 
15
- And then execute:
17
+ Then in console:
16
18
 
17
- $ bundle install
19
+ [source,console]
20
+ ----
21
+ $ bundle
22
+ ----
18
23
 
19
- Or install it yourself as:
24
+ With RubyGems:
20
25
 
21
- $ gem install lutaml
26
+ [source,console]
27
+ ----
28
+ $ gem install lutaml
29
+ ----
22
30
 
23
- ## Usage
31
+ === Usage
24
32
 
25
- TODO: Write usage instructions here
33
+ In order to parse files supported by lutaml extensions, use Lutaml::Parser.parse method(currently only .exp are supported):
26
34
 
27
- ## Development
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
- ## Code of Conduct
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
@@ -3,4 +3,4 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,6 +1,5 @@
1
1
  require "lutaml/version"
2
+ require "lutaml/parser"
2
3
 
3
4
  module Lutaml
4
- class Error < StandardError; end
5
- # Your code goes here...
6
5
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Lutaml
2
- VERSION = "0.1.0"
2
+ VERSION = "0.3.3".freeze
3
3
  end
@@ -1,4 +1,4 @@
1
- require_relative 'lib/lutaml/version'
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 = Dir.chdir(File.expand_path('..', __FILE__)) do
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.1.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: 2020-06-20 00:00:00.000000000 Z
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.md
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: []