lutaml 0.2.0 → 0.3.0

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: dd52cb5d4a4e29687299339e3cd9af05720f81348d5a307ae1d07bf2514bd022
4
- data.tar.gz: 373158747e92e76c14efd7bbfc6d42a9ecebe164ebb5d14f035840a85666ce5d
3
+ metadata.gz: 7354339d27eea082d413223752e3937abef47f1ecc9fde7a72608b1a665577c0
4
+ data.tar.gz: 79c2ba8775508bcf5936a533c63ee7fa525295e6424fb25049806bfc2c3cdd92
5
5
  SHA512:
6
- metadata.gz: ad0a113798e024375f25c0f580c09b8e17f1b8d8ea60ab1edc67dbfb5250ae9cb6151b44a4f6cd090159d177d08c40361c7b536a1832053f01a5784d580f91da
7
- data.tar.gz: 6f0e0043a0c0a240763c95d0041ff6ccb462fb81773ecc1f4c5d4dc376942fdebe39f6c9fc5c30df96e8a95a061147cfa2b139dda968aabd6161abeb216f7a66
6
+ metadata.gz: 655622623e88e8ce43318a7df0d2538b66e3cd3bcb13f3b2d8b6f596df095b500dd5fe3896d54efc758a47d086dbf250b4f70ae46c1157cc2ee5342f4e61d20c
7
+ data.tar.gz: edb8143e8237d40c814f4490c121fb234142b2109eef0200955bd495a06543982b9b3618f55ab1187c47fa50c32620979389dd0e45e9c5bf19abc03c6fa1ceb1
@@ -0,0 +1,36 @@
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', '2.4' ]
20
+ experimental: [false]
21
+ include:
22
+ - ruby: '2.7'
23
+ experimental: true
24
+ steps:
25
+ - uses: actions/checkout@master
26
+ - name: Use Ruby
27
+ uses: actions/setup-ruby@v1
28
+ with:
29
+ ruby-version: ${{ matrix.ruby }}
30
+ - name: Update gems
31
+ run: |
32
+ sudo gem install bundler --force
33
+ bundle install --jobs 4 --retry 3
34
+ - name: Run specs
35
+ run: |
36
+ 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', '2.4' ]
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', '2.4' ]
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
@@ -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).
@@ -1,7 +1,6 @@
1
1
  require "lutaml/version"
2
+ require "lutaml/parser"
2
3
  require "lutaml/lutaml_path/document_wrapper"
3
4
 
4
5
  module Lutaml
5
- class Error < StandardError; end
6
- # Your code goes here...
7
6
  end
@@ -1,5 +1,3 @@
1
- require "jmespath"
2
-
3
1
  module Lutaml
4
2
  module LutamlPath
5
3
  class DocumentWrapper
@@ -9,11 +7,8 @@ module Lutaml
9
7
  @serialized_document = serialize_document(document)
10
8
  end
11
9
 
12
- # Method for traversing document` structure
13
- # example for lutaml: wrapper.find('//#main-doc/main-class/nested-class')
14
- # Need to return descendant of Lutaml::LutamlPath::EntryWrapper
15
- def find(path)
16
- JMESPath.search(path, serialized_document)
10
+ def to_liquid
11
+ serialized_document
17
12
  end
18
13
 
19
14
  protected
@@ -21,6 +16,25 @@ module Lutaml
21
16
  def serialize_document(_path)
22
17
  raise ArgumentError, "implement #serialize_document!"
23
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
+ object.instance_variables.each_with_object({}) do |var, res|
30
+ variable = object.instance_variable_get(var)
31
+ res[var.to_s.gsub("@", "")] = if variable.is_a?(Array)
32
+ variable.map { |n| serialize_to_hash(n) }
33
+ else
34
+ variable
35
+ end
36
+ end
37
+ end
24
38
  end
25
39
  end
26
40
  end
@@ -0,0 +1,17 @@
1
+ require "lutaml/express"
2
+
3
+ module Lutaml
4
+ module Parser
5
+ module_function
6
+
7
+ def parse(file)
8
+ case File.extname(file.path)[1..-1]
9
+ when "exp"
10
+ Lutaml::Express::LutamlPath::DocumentWrapper
11
+ .new(Lutaml::Express::Parsers::Exp.parse(file))
12
+ else
13
+ raise ArgumentError, "Unsupported file format"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module Lutaml
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
@@ -28,10 +28,12 @@ Gem::Specification.new do |spec|
28
28
  # spec.add_runtime_dependency "activesupport", "~> 5.0"
29
29
  # spec.add_runtime_dependency "lutaml-uml"
30
30
  # spec.add_runtime_dependency "lutaml-sysml"
31
+ spec.add_runtime_dependency "lutaml-express", "~> 0.1.0"
31
32
  spec.add_development_dependency "jmespath", "~> 1.4"
32
33
  spec.add_development_dependency "nokogiri", "~> 1.10"
33
34
 
34
35
  spec.add_development_dependency "bundler", "~> 2.0"
36
+ spec.add_development_dependency "byebug"
35
37
  spec.add_development_dependency "pry", "~> 0.12.2"
36
38
  spec.add_development_dependency "rake", "~> 10.0"
37
39
  spec.add_development_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: lutaml-express
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: jmespath
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: pry
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -129,17 +157,21 @@ executables: []
129
157
  extensions: []
130
158
  extra_rdoc_files: []
131
159
  files:
160
+ - ".github/workflows/macos.yml"
161
+ - ".github/workflows/ubuntu.yml"
162
+ - ".github/workflows/windows.yml"
132
163
  - ".gitignore"
133
164
  - ".rspec"
134
165
  - ".travis.yml"
135
166
  - CODE_OF_CONDUCT.md
136
167
  - Gemfile
137
- - README.md
168
+ - README.adoc
138
169
  - Rakefile
139
170
  - bin/console
140
171
  - bin/setup
141
172
  - lib/lutaml.rb
142
173
  - lib/lutaml/lutaml_path/document_wrapper.rb
174
+ - lib/lutaml/parser.rb
143
175
  - lib/lutaml/version.rb
144
176
  - lutaml.gemspec
145
177
  homepage: https://github.com/lutaml/lutaml