expressir 1.3.3-x86_64-linux-musl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +7 -0
  2. data/.cross_rubies +28 -0
  3. data/.github/workflows/codeql.yml +47 -0
  4. data/.github/workflows/rake.yml +448 -0
  5. data/.github/workflows/release.yml +189 -0
  6. data/.github/workflows/stress.yml +53 -0
  7. data/.gitignore +23 -0
  8. data/.gitmodules +6 -0
  9. data/.hound.yml +3 -0
  10. data/.rspec +2 -0
  11. data/.rubocop.yml +18 -0
  12. data/.yardopts +11 -0
  13. data/Gemfile +4 -0
  14. data/README.adoc +155 -0
  15. data/Rakefile +17 -0
  16. data/bin/console +11 -0
  17. data/bin/rspec +29 -0
  18. data/bin/setup +8 -0
  19. data/docs/development.md +90 -0
  20. data/exe/expressir +22 -0
  21. data/exe/format +18 -0
  22. data/exe/format-test +81 -0
  23. data/exe/generate-parser +51 -0
  24. data/expressir.gemspec +48 -0
  25. data/lib/expressir/cli/ui.rb +36 -0
  26. data/lib/expressir/cli.rb +21 -0
  27. data/lib/expressir/config.rb +23 -0
  28. data/lib/expressir/express/2.7/express_parser.so +0 -0
  29. data/lib/expressir/express/3.0/express_parser.so +0 -0
  30. data/lib/expressir/express/3.1/express_parser.so +0 -0
  31. data/lib/expressir/express/3.2/express_parser.so +0 -0
  32. data/lib/expressir/express/cache.rb +51 -0
  33. data/lib/expressir/express/formatter.rb +1608 -0
  34. data/lib/expressir/express/hyperlink_formatter.rb +36 -0
  35. data/lib/expressir/express/model_visitor.rb +24 -0
  36. data/lib/expressir/express/parser.rb +83 -0
  37. data/lib/expressir/express/resolve_references_model_visitor.rb +31 -0
  38. data/lib/expressir/express/schema_head_formatter.rb +23 -0
  39. data/lib/expressir/express/visitor.rb +2591 -0
  40. data/lib/expressir/model/cache.rb +17 -0
  41. data/lib/expressir/model/data_type.rb +9 -0
  42. data/lib/expressir/model/data_types/aggregate.rb +31 -0
  43. data/lib/expressir/model/data_types/array.rb +31 -0
  44. data/lib/expressir/model/data_types/bag.rb +25 -0
  45. data/lib/expressir/model/data_types/binary.rb +22 -0
  46. data/lib/expressir/model/data_types/boolean.rb +10 -0
  47. data/lib/expressir/model/data_types/enumeration.rb +25 -0
  48. data/lib/expressir/model/data_types/enumeration_item.rb +26 -0
  49. data/lib/expressir/model/data_types/generic.rb +26 -0
  50. data/lib/expressir/model/data_types/generic_entity.rb +26 -0
  51. data/lib/expressir/model/data_types/integer.rb +10 -0
  52. data/lib/expressir/model/data_types/list.rb +28 -0
  53. data/lib/expressir/model/data_types/logical.rb +10 -0
  54. data/lib/expressir/model/data_types/number.rb +10 -0
  55. data/lib/expressir/model/data_types/real.rb +19 -0
  56. data/lib/expressir/model/data_types/select.rb +28 -0
  57. data/lib/expressir/model/data_types/set.rb +25 -0
  58. data/lib/expressir/model/data_types/string.rb +22 -0
  59. data/lib/expressir/model/declaration.rb +9 -0
  60. data/lib/expressir/model/declarations/attribute.rb +47 -0
  61. data/lib/expressir/model/declarations/constant.rb +34 -0
  62. data/lib/expressir/model/declarations/entity.rb +53 -0
  63. data/lib/expressir/model/declarations/function.rb +67 -0
  64. data/lib/expressir/model/declarations/interface.rb +28 -0
  65. data/lib/expressir/model/declarations/interface_item.rb +23 -0
  66. data/lib/expressir/model/declarations/interfaced_item.rb +37 -0
  67. data/lib/expressir/model/declarations/parameter.rb +34 -0
  68. data/lib/expressir/model/declarations/procedure.rb +64 -0
  69. data/lib/expressir/model/declarations/remark_item.rb +21 -0
  70. data/lib/expressir/model/declarations/rule.rb +71 -0
  71. data/lib/expressir/model/declarations/schema.rb +117 -0
  72. data/lib/expressir/model/declarations/schema_version.rb +22 -0
  73. data/lib/expressir/model/declarations/schema_version_item.rb +22 -0
  74. data/lib/expressir/model/declarations/subtype_constraint.rb +40 -0
  75. data/lib/expressir/model/declarations/type.rb +45 -0
  76. data/lib/expressir/model/declarations/unique_rule.rb +31 -0
  77. data/lib/expressir/model/declarations/variable.rb +34 -0
  78. data/lib/expressir/model/declarations/where_rule.rb +31 -0
  79. data/lib/expressir/model/expression.rb +9 -0
  80. data/lib/expressir/model/expressions/aggregate_initializer.rb +19 -0
  81. data/lib/expressir/model/expressions/aggregate_initializer_item.rb +22 -0
  82. data/lib/expressir/model/expressions/binary_expression.rb +53 -0
  83. data/lib/expressir/model/expressions/entity_constructor.rb +22 -0
  84. data/lib/expressir/model/expressions/function_call.rb +22 -0
  85. data/lib/expressir/model/expressions/interval.rb +34 -0
  86. data/lib/expressir/model/expressions/query_expression.rb +35 -0
  87. data/lib/expressir/model/expressions/unary_expression.rb +27 -0
  88. data/lib/expressir/model/identifier.rb +34 -0
  89. data/lib/expressir/model/literal.rb +9 -0
  90. data/lib/expressir/model/literals/binary.rb +19 -0
  91. data/lib/expressir/model/literals/integer.rb +19 -0
  92. data/lib/expressir/model/literals/logical.rb +23 -0
  93. data/lib/expressir/model/literals/real.rb +19 -0
  94. data/lib/expressir/model/literals/string.rb +22 -0
  95. data/lib/expressir/model/model_element.rb +208 -0
  96. data/lib/expressir/model/reference.rb +9 -0
  97. data/lib/expressir/model/references/attribute_reference.rb +22 -0
  98. data/lib/expressir/model/references/group_reference.rb +22 -0
  99. data/lib/expressir/model/references/index_reference.rb +27 -0
  100. data/lib/expressir/model/references/simple_reference.rb +24 -0
  101. data/lib/expressir/model/repository.rb +23 -0
  102. data/lib/expressir/model/statement.rb +9 -0
  103. data/lib/expressir/model/statements/alias.rb +35 -0
  104. data/lib/expressir/model/statements/assignment.rb +22 -0
  105. data/lib/expressir/model/statements/case.rb +25 -0
  106. data/lib/expressir/model/statements/case_action.rb +22 -0
  107. data/lib/expressir/model/statements/compound.rb +19 -0
  108. data/lib/expressir/model/statements/escape.rb +10 -0
  109. data/lib/expressir/model/statements/if.rb +25 -0
  110. data/lib/expressir/model/statements/null.rb +10 -0
  111. data/lib/expressir/model/statements/procedure_call.rb +22 -0
  112. data/lib/expressir/model/statements/repeat.rb +47 -0
  113. data/lib/expressir/model/statements/return.rb +19 -0
  114. data/lib/expressir/model/statements/skip.rb +10 -0
  115. data/lib/expressir/model/supertype_expression.rb +9 -0
  116. data/lib/expressir/model/supertype_expressions/binary_supertype_expression.rb +29 -0
  117. data/lib/expressir/model/supertype_expressions/oneof_supertype_expression.rb +19 -0
  118. data/lib/expressir/model.rb +79 -0
  119. data/lib/expressir/version.rb +3 -0
  120. data/lib/expressir.rb +44 -0
  121. data/rakelib/antlr4-native.rake +173 -0
  122. data/rakelib/cross-ruby.rake +403 -0
  123. data/spec/acceptance/version_spec.rb +30 -0
  124. data/spec/expressir/express/cache_spec.rb +89 -0
  125. data/spec/expressir/express/formatter_spec.rb +171 -0
  126. data/spec/expressir/express/parser_spec.rb +141 -0
  127. data/spec/expressir/model/model_element_spec.rb +318 -0
  128. data/spec/spec_helper.rb +24 -0
  129. data/spec/support/console_helper.rb +29 -0
  130. data/spec/syntax/multiple.exp +23 -0
  131. data/spec/syntax/multiple.yaml +198 -0
  132. data/spec/syntax/multiple_formatted.exp +71 -0
  133. data/spec/syntax/multiple_hyperlink_formatted.exp +71 -0
  134. data/spec/syntax/multiple_schema_head_hyperlink_formatted.exp +13 -0
  135. data/spec/syntax/remark.exp +193 -0
  136. data/spec/syntax/remark.yaml +471 -0
  137. data/spec/syntax/remark_formatted.exp +228 -0
  138. data/spec/syntax/single.exp +4 -0
  139. data/spec/syntax/single.yaml +18 -0
  140. data/spec/syntax/single_formatted.exp +10 -0
  141. data/spec/syntax/single_formatted.yaml +36 -0
  142. data/spec/syntax/syntax.exp +333 -0
  143. data/spec/syntax/syntax.yaml +3509 -0
  144. data/spec/syntax/syntax_formatted.exp +902 -0
  145. data/spec/syntax/syntax_hyperlink_formatted.exp +902 -0
  146. data/spec/syntax/syntax_schema_head_formatted.exp +18 -0
  147. metadata +392 -0
@@ -0,0 +1,189 @@
1
+ name: release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ next_version:
7
+ description: |
8
+ Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
9
+ required: true
10
+ default: 'patch'
11
+ push:
12
+ tags: [ v* ]
13
+
14
+ concurrency:
15
+ group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
16
+ cancel-in-progress: true
17
+
18
+ env:
19
+ BUNDLER_VER: 2.4.22
20
+
21
+ jobs:
22
+ bump:
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ with:
27
+ submodules: recursive
28
+
29
+ - uses: ruby/setup-ruby@master
30
+ with:
31
+ ruby-version: '3.1'
32
+ bundler: ${{ env.BUNDLER_VER }}
33
+
34
+ - if: ${{ github.event_name == 'workflow_dispatch' }} # unfortunatelly cannot keep this condition on job level
35
+ run: |
36
+ git config --global user.name github-actions
37
+ git config --global user.email github-actions@github.com
38
+ gem install gem-release
39
+ gem bump --version ${{ github.event.inputs.next_version }} --tag --push
40
+
41
+ pack:
42
+ runs-on: ubuntu-latest
43
+ needs: bump
44
+ strategy:
45
+ fail-fast: false
46
+ matrix:
47
+ platform: [ linux-gnu, linux-musl, windows, darwin ]
48
+ steps:
49
+ - uses: actions/checkout@v4
50
+ with:
51
+ submodules: recursive
52
+ ref: main # https://github.com/actions/checkout/issues/439#issuecomment-830862188
53
+
54
+ - uses: ruby/setup-ruby@master
55
+ with:
56
+ ruby-version: '3.1'
57
+ # bundler-cache: true important to not use cache because it leads to "cannot find -lrice"
58
+ # more info https://github.com/lutaml/expressir/runs/2097658383?check_suite_focus=true#step:7:2126
59
+
60
+ - run: bundle install --jobs 4 --retry 3
61
+
62
+ - name: Build gem and save version
63
+ if: matrix.platform == 'linux-gnu'
64
+ run: |
65
+ gem build expressir.gemspec | grep -o 'Version: .*' | awk '{print $2}' > version
66
+
67
+ - if: matrix.platform == 'linux-gnu'
68
+ uses: actions/upload-artifact@v4
69
+ with:
70
+ name: pkg-ruby
71
+ path: expressir-*.gem
72
+
73
+ - if: matrix.platform == 'linux-gnu'
74
+ uses: actions/upload-artifact@v4
75
+ with:
76
+ name: version
77
+ path: version
78
+
79
+ - name: Enable swap
80
+ run: |
81
+ sudo fallocate -l 15g /compile.swap
82
+ sudo chmod 600 /compile.swap
83
+ sudo mkswap /compile.swap
84
+ sudo swapon /compile.swap
85
+ sudo swapon --all --verbose
86
+
87
+ # build gem WITH pre-built native extension
88
+ - run: bundle exec rake gem:${{ matrix.platform }}
89
+
90
+ - uses: actions/upload-artifact@v4
91
+ with:
92
+ name: pkg-${{ matrix.platform }}
93
+ path: pkg/*.gem
94
+
95
+ publish:
96
+ runs-on: ubuntu-latest
97
+ needs: pack
98
+ steps:
99
+ - uses: actions/download-artifact@v4
100
+ with:
101
+ name: pkg-ruby
102
+ path: pkg
103
+
104
+ - uses: actions/download-artifact@v4
105
+ with:
106
+ name: pkg-linux-gnu
107
+ path: pkg
108
+
109
+ - uses: actions/download-artifact@v4
110
+ with:
111
+ name: pkg-linux-musl
112
+ path: pkg
113
+
114
+ - uses: actions/download-artifact@v4
115
+ with:
116
+ name: pkg-windows
117
+ path: pkg
118
+
119
+ - uses: actions/download-artifact@v4
120
+ with:
121
+ name: pkg-darwin
122
+ path: pkg
123
+
124
+ - uses: ruby/setup-ruby@master
125
+ with:
126
+ ruby-version: '3.1'
127
+
128
+ - name: Publish to rubygems.org
129
+ env:
130
+ RUBYGEMS_API_KEY: ${{ secrets.LUTAML_CI_RUBYGEMS_API_KEY }}
131
+ run: |
132
+ ls -l pkg/
133
+ mkdir -p ~/.gem
134
+ cat > ~/.gem/credentials << EOF
135
+ ---
136
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
137
+ EOF
138
+ chmod 0600 ~/.gem/credentials
139
+ gem signin
140
+ for gem in pkg/*.gem; do gem push $gem -V; done
141
+ sleep 15
142
+
143
+ verify:
144
+ name: Verify published gem on ${{ matrix.os }}
145
+ needs: publish
146
+ runs-on: ${{ matrix.os }}
147
+ strategy:
148
+ fail-fast: false
149
+ matrix:
150
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
151
+ steps:
152
+ - name: Install Ruby
153
+ uses: ruby/setup-ruby@master
154
+ with:
155
+ ruby-version: 3.1
156
+ bundler-cache: true
157
+ bundler: ${{ env.BUNDLER_VER }}
158
+
159
+ - name: Download version
160
+ uses: actions/download-artifact@v4
161
+ with:
162
+ name: version
163
+
164
+ - name: Install gem
165
+ run: gem install expressir -v $(cat version)
166
+
167
+ - name: Verify
168
+ run: expressir version
169
+
170
+ verify-alpine:
171
+ name: Verify published gem on alpine
172
+ needs: publish
173
+ runs-on: ubuntu-latest
174
+ container:
175
+ image: alpine:3.17
176
+ steps:
177
+ - name: Install packages
178
+ run: apk --no-cache add bash build-base git ruby-dev gcc g++ automake
179
+
180
+ - name: Download version
181
+ uses: actions/download-artifact@v4
182
+ with:
183
+ name: version
184
+
185
+ - name: Install gem
186
+ run: gem install expressir -v $(cat version)
187
+
188
+ - name: Verify
189
+ run: expressir version
@@ -0,0 +1,53 @@
1
+ name: stress
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ concurrency:
7
+ group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
8
+ cancel-in-progress: true
9
+
10
+ env:
11
+ BUNDLER_VER: 2.4.22
12
+ GC_STRESS: true
13
+
14
+ jobs:
15
+ rake:
16
+ name: test on ruby-${{ matrix.ruby }} ${{ matrix.os }}
17
+ runs-on: ${{ matrix.os }}
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby: [ '3.2', '3.1', '3.0', '2.7' ]
22
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
23
+
24
+ steps:
25
+ - name: Checkout
26
+ uses: actions/checkout@v4
27
+ with:
28
+ submodules: recursive
29
+
30
+ - name: Setup packages
31
+ if: startsWith(matrix.os, 'macos')
32
+ run: brew install autoconf automake libtool
33
+
34
+ - name: Install Ruby
35
+ uses: ruby/setup-ruby@master
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+ bundler: ${{ env.BUNDLER_VER }}
39
+ # Rice gem has issues with bundler cache
40
+ # more info https://github.com/lutaml/expressir/runs/2097658383?check_suite_focus=true#step:7:2126
41
+ # but it is not the only issue
42
+ bundler-cache: false
43
+
44
+ - name: Bundle
45
+ run: bundle install --jobs 4 --retry 3
46
+
47
+ - name: Build native extension
48
+ run: bundle exec rake compile
49
+
50
+ - name: Run tests
51
+ run: |
52
+ bundle exec rake
53
+ cat .rspec_status
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
10
+ /.idea
11
+ /.vscode
12
+ /lib/expressir/express/express_parser.bundle
13
+ /lib/expressir/express/express_parser.so
14
+ /lib/expressir/express/*/express_parser.bundle
15
+ /lib/expressir/express/*/express_parser.so
16
+ /spec/syntax/*-pretty.exp
17
+ /ext/express_parser/rice-embed
18
+
19
+ # rspec failure tracking
20
+ .rspec_status
21
+
22
+ # rubocop guide
23
+ .rubocop-https---*
data/.gitmodules ADDED
@@ -0,0 +1,6 @@
1
+ [submodule "ext/express_parser/antlr4-upstream"]
2
+ path = ext/express_parser/antlr4-upstream
3
+ url = https://github.com/antlr/antlr4
4
+ [submodule "ext/express-grammar"]
5
+ path = ext/express-grammar
6
+ url = https://github.com/lutaml/express-grammar
data/.hound.yml ADDED
@@ -0,0 +1,3 @@
1
+ ruby:
2
+ enabled: true
3
+ config_file: .rubocop.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.7
6
+ NewCops: enable
7
+ SuggestExtensions: false
8
+ Exclude:
9
+ - 'vendor/**/*'
10
+ - 'expressir.gemspec'
11
+ - 'tmp/**/*'
12
+ - 'pkg/**/*'
13
+ - 'exe/format-test'
14
+ - 'lib/expressir/express/**/*'
15
+ - 'lib/expressir/model/**/*'
16
+
17
+ Layout/LineLength:
18
+ Max: 160
data/.yardopts ADDED
@@ -0,0 +1,11 @@
1
+ # macro must be defined first, see https://stackoverflow.com/a/10344776/1823988
2
+ lib/expressir/model/model_element.rb
3
+ lib/expressir/model/data_type.rb
4
+ lib/expressir/model/declaration.rb
5
+ lib/expressir/model/expression.rb
6
+ lib/expressir/model/literal.rb
7
+ lib/expressir/model/reference.rb
8
+ lib/expressir/model/statement.rb
9
+ lib/expressir/model/supertype_expression.rb
10
+
11
+ lib/**/*.rb
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in reeper.gemspec
4
+ gemspec
data/README.adoc ADDED
@@ -0,0 +1,155 @@
1
+ = Expressir: EXPRESS in Ruby
2
+
3
+ image:https://img.shields.io/gem/v/expressir.svg["Gem Version", link="https://rubygems.org/gems/expressir"]
4
+ // image:https://codeclimate.com/github/lutaml/expressir/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/lutaml/expressir"]
5
+ image:https://github.com/lutaml/expressir/workflows/rake/badge.svg["Build Status", link="https://github.com/lutaml/expressir/actions?workflow=rake"]
6
+
7
+ == Purpose
8
+
9
+ Expressir ("`EXPRESS in Ruby`") is a Ruby parser for EXPRESS and
10
+ a set of Ruby tools for accessing ISO EXPRESS data models.
11
+
12
+ == Architecture
13
+
14
+ Expressir consists of 3 parts:
15
+
16
+ . Parsers. A parser allows Expressir to read EXPRESS files, including:
17
+
18
+ ** EXPRESS data modelling language (ISO 10303-11:2007)
19
+ ** EXPRESS data modelling language in XML (STEPmod)
20
+ ** EXPRESS XML (ISO 10303-28:2007)
21
+ "`Industrial automation systems and integration — Product data representation and exchange — Part 28: Implementation methods: XML representations of EXPRESS schemas and data, using XML schemas`")
22
+
23
+ . Data model. The data model (`lib/expressir/express`) is the Ruby data model that fully represents an EXPRESS data model.
24
+
25
+ . Converters. A converter transforms the EXPRESS Ruby data model into an interoperable export format, including:
26
+ ** EXPRESS data modelling language (ISO 10303-11:2007)
27
+ ** W3C OWL
28
+ ** OMG SysML (XMI 2.1, XMI 2.5)
29
+ ** OMG UML 2 (XMI 2.1)
30
+ ** OMG UML 2 for Eclipse (XMI 2.1)
31
+
32
+
33
+ == Usage
34
+
35
+ This gem ships with a CLI tool. To check what's available you can simply run
36
+ the script directly from `exe/expressir`, by default it will display some usage
37
+ instructions.
38
+
39
+ [source, sh]
40
+ ----
41
+ ./exe/expressir
42
+
43
+ Commands:
44
+ expressir help [COMMAND] # Describe available commands or one specific command
45
+ expressir version # The Expressir Version
46
+ ----
47
+
48
+ == Development
49
+
50
+ We are following Sandi Metz's Rules for this gem, you can read
51
+ the http://robots.thoughtbot.com/post/50655960596/sandi-metz-rules-for-developers[description of the rules here] All new code should follow these rules.
52
+ If you make changes in a pre-existing file that violates these rules you should
53
+ fix the violations as part of your contribution.
54
+
55
+ === Setup
56
+
57
+ Clone the repository.
58
+
59
+ [source, sh]
60
+ ----
61
+ git clone https://github.com/metanorma/expressir
62
+ ----
63
+
64
+ Setup your environment.
65
+
66
+ [source, sh]
67
+ ----
68
+ bin/setup
69
+ ----
70
+
71
+ Run the test suite
72
+
73
+ [source, sh]
74
+ ----
75
+ bin/rspec
76
+ ----
77
+
78
+ === Grammar updates
79
+ EXPRESS grammar is lined as git submodule to ext/express-grammar
80
+ Shoudl you update it, run ```rake generate```. This command will generate source code for updated native extension using antlr4-native gem.
81
+ Please note that we create several classes on top of antlr4-native output so using embedded rake task is a real requirement.
82
+
83
+ When new extension is gnerated and tested plase check in updated C++ files to git (```rake generate``` is NOT a CI step,
84
+ extension source files are pulled from the repo).
85
+
86
+ == Installation
87
+
88
+ Add this line to your application's `Gemfile`:
89
+
90
+ [source, sh]
91
+ ----
92
+ gem "expressir"
93
+ ----
94
+
95
+ And then execute:
96
+
97
+ [source, sh]
98
+ ----
99
+ $ bundle install
100
+ ----
101
+
102
+ Or install it yourself as:
103
+
104
+ [source, sh]
105
+ ----
106
+ $ gem install expressir
107
+ ----
108
+
109
+
110
+ == Contributing
111
+
112
+ First, thank you for contributing! We love pull requests from everyone. By
113
+ participating in this project, you hereby grant
114
+ https://www.ribose.com[Ribose Inc.] the right to grant or transfer an unlimited
115
+ number of non exclusive licenses or sub-licenses to third parties, under the
116
+ copyright covering the contribution to use the contribution by all means.
117
+
118
+ Here are a few technical guidelines to follow:
119
+
120
+ * Open an https://github.com/lutaml/expressir/issues[issues] to discuss a new
121
+ feature.
122
+ * Write tests to support your new feature.
123
+ * Make sure the entire test suite passes locally and on CI.
124
+ * Open a Pull Request.
125
+ * https://github.com/thoughtbot/guides/tree/master/protocol/git#write-a-feature[Squash your commits] after receiving feedback.
126
+ * Party!
127
+
128
+
129
+ == License
130
+
131
+ Expressir is distributed under the BSD 2-clause license.
132
+
133
+ Expressir is built on code originally from the NIST Reeper project.
134
+
135
+ The https://www.nist.gov/services-resources/software/reeper[NIST Reeper license]
136
+ is reproduced below:
137
+
138
+ [quote]
139
+ ____
140
+ This software was funded by NIST and developed by EuroSTEP.
141
+ Pursuant to title 17 Section 105 of the United States Code this
142
+ software is not subject to copyright protection and is in the public
143
+ domain.
144
+
145
+ We would appreciate acknowledgment if the software is used. Links to
146
+ non-Federal Government Web sites do not imply NIST endorsement of any
147
+ particular product, service, organization, company, information
148
+ provider, or content.
149
+ ____
150
+
151
+
152
+ == Credits
153
+
154
+ Expressir is created using the structure and examples provided by
155
+ the NIST Reeper software on https://sourceforge.net/p/reeper/[Sourceforge].
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rake/extensiontask"
4
+ require "rubocop/rake_task"
5
+ require "yard"
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task default: :spec
10
+
11
+ GEMSPEC = Gem::Specification.load("expressir.gemspec")
12
+
13
+ RuboCop::RakeTask.new
14
+
15
+ Gem::PackageTask.new(GEMSPEC).define
16
+
17
+ YARD::Rake::YardocTask.new
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "reeper"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("bundle", __dir__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,90 @@
1
+ ## Development Plan
2
+
3
+ This document is a draft to understand the basic of the original library, and
4
+ how the whole tool chain is working at the moment. Once, we've an understanding
5
+ then let's look at the potential area of improvement, and plan out a high level
6
+ plan to start the development.
7
+
8
+ ### What is it, expressir?
9
+
10
+ * Expressir is a ruby tool to harvest iso express data model
11
+ * Express is one of the language to represent data model
12
+ * Expressir tool is used to manipulate iso express data model
13
+ * The input for the expressir is a standard xml document
14
+ * XML Spec: http://stepmod.sourceforge.net/express_model_spec/
15
+ * Expressir does the job of representing express model as ruby class
16
+ * REXML-based parser that reads EXPRESS as XML and creates the dictionary (i.e.
17
+ instances of the EXPRESS Ruby Classes) and then calls a mapper, that may be
18
+ specified as an option at runtime
19
+ * Mappers that read the EXPRESS dictionary and perform the conversion to the
20
+ desired language or format
21
+ * Express to UML2 Mapper - Convert the express model to UML2
22
+ * Express to OWL Structure - Convert the express model to OWL Structure
23
+ * Ruby API generator for express language
24
+ * Current Ruby API is super slow, it takes 2 hours to generate 400 entity
25
+
26
+ ### How does the original version work?
27
+
28
+ At the core the `expressir.rb` is responsible for everything at moment, it takes
29
+ an Express XML file as an input and then it parses that XML file and build the
30
+ correct ruby interface for further processing.
31
+
32
+ This `expressir.rb` also expect one mapping file `deafult to mapping.rb`, and it
33
+ also expect the file to specify a custom method `map_from_express` to take the
34
+ `Ruby Express Representation` and convert this ruby representation to the
35
+ desire output format.
36
+
37
+ The library also provides couple mapping for UM2, OWL and SysML, so anyone can
38
+ export their data to any of those format if necessary, and the use cases for
39
+ those library are as following:
40
+
41
+ ```ruby
42
+ ruby expressir.rb expxml=<schema.xml> map=<mapping_owl.rb>
43
+ ```
44
+
45
+ ### What are potential improvement area?
46
+
47
+ * The interface is not well defined, someone needs to dig deeper to understand
48
+ just the basic of the library and how to use for their use cases. This is
49
+ something that could be improved as initial step.
50
+ * At the moment, these are some ruby files, so potentially we could group those
51
+ together as a CLI tool and group some of the common functionality, and provide
52
+ a straight forward interface for users.
53
+ * The good part about this library is author had the extensibility in mind from
54
+ the beginning, so we should keep that functionality as flexible as possible.
55
+ * There are lot of boilerplate code in the library, but it's understandable as
56
+ it was written quite long time ago, so maybe most of the tool was not even
57
+ available back then, so this is the another area we could improve.
58
+ * Another improvement we could do in terms of actual codebase, we should be able
59
+ to refactor this library and cleanup as much as possible.
60
+
61
+ ### What are the initial changes?
62
+
63
+ Initially, we can start by creating a ruby cli gem, group these functionality
64
+ together. This could be named as `expressir`, and this gem will be shipped with an
65
+ executable called `expressir`.
66
+
67
+ Second of all, let's add some dedicated interface for the default type, so user
68
+ does not need to know all the details but the name of the interface, for example
69
+ we could expose the transformation as follows:
70
+
71
+ ```sh
72
+ # Convert to owl
73
+ expressir express2owl file=[express_xml_file] [**options]
74
+
75
+ # Convert to UML
76
+ expressir express2uml file=[express_xml_file] [**options]
77
+
78
+ # Convert to SysML
79
+ expressir express2sysml file=[express_xml_file] [**options]
80
+
81
+ # Custom conversion
82
+ expressir express2custom file=[express_xml_file] mapping=[custom_mapping.rb]
83
+ ```
84
+
85
+ Third of all once this library is functional as the original version then we
86
+ will go through each of the existing types, and refactor those as necessary.
87
+
88
+ ### References
89
+
90
+ * https://martinfowler.com/bliki/MovingToNokogiri.html
data/exe/expressir ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ # resolve bin path, ignoring symlinks
5
+ require "pathname"
6
+ bin_file = Pathname.new(__FILE__).realpath
7
+
8
+ # add self to libpath
9
+ $:.unshift File.expand_path("../../lib", bin_file)
10
+
11
+ # Fixes https://github.com/rubygems/rubygems/issues/1420
12
+ require "rubygems/specification"
13
+
14
+ module Gem
15
+ class Specification
16
+ def this; self; end
17
+ end
18
+ end
19
+
20
+ # start up the CLI
21
+ require "expressir"
22
+ Expressir::Cli.start(ARGV)
data/exe/format ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "yaml"
4
+ require "expressir/express/parser"
5
+ require "expressir/express/formatter"
6
+ require "expressir/express/schema_head_formatter"
7
+ require "expressir/express/hyperlink_formatter"
8
+
9
+ exp_files = ARGV
10
+
11
+ repository = Expressir::Express::Parser.from_files(exp_files)
12
+ formatter = Class.new(Expressir::Express::Formatter) do
13
+ include Expressir::Express::SchemaHeadFormatter
14
+ include Expressir::Express::HyperlinkFormatter
15
+ end
16
+ result = repository.to_hash(formatter: formatter, skip_empty: true)
17
+
18
+ puts YAML.dump(result)