stepmod-utils 0.3.15 → 0.3.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +3 -20
- data/.github/workflows/release.yml +6 -28
- data/README.adoc +2 -40
- data/exe/stepmod-extract-terms +1 -1
- data/lib/stepmod/utils/converters/term.rb +10 -10
- data/lib/stepmod/utils/term.rb +38 -0
- data/lib/stepmod/utils/terms_extractor.rb +9 -37
- data/lib/stepmod/utils/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e40fc2ba271e4bd8e0859cb307831ead927b7bc12154b5845f528694ad18c8f8
|
4
|
+
data.tar.gz: e1b6f691a70d1e6531a7f841b5a998d49d6c376a84a9da340246b2920bd8459d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5e62c15d95982deb33e03af65b9720cdb34746adfa36bf5945a2823fb0be9800beff3e8cf4b3e4acd34ebf940bacb0ff2b4a83b31af27e8d01cba2599fcc537
|
7
|
+
data.tar.gz: c9efdfa5eed962291c9454227e8d2c7c22b4ba665c88745d059f77cdfb5ae2bdb414d32d7c1ee957aec10db634c1f0fbc388851360ae4edb9bf9d721f740dca3
|
data/.github/workflows/rake.yml
CHANGED
@@ -10,23 +10,6 @@ on:
|
|
10
10
|
|
11
11
|
jobs:
|
12
12
|
rake:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
strategy:
|
17
|
-
fail-fast: false
|
18
|
-
matrix:
|
19
|
-
ruby: [ '3.0', '2.7', '2.6', '2.5' ]
|
20
|
-
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
|
-
experimental: [ false ]
|
22
|
-
steps:
|
23
|
-
- uses: actions/checkout@v2
|
24
|
-
with:
|
25
|
-
submodules: true
|
26
|
-
|
27
|
-
- uses: ruby/setup-ruby@v1
|
28
|
-
with:
|
29
|
-
ruby-version: ${{ matrix.ruby }}
|
30
|
-
bundler-cache: true
|
31
|
-
|
32
|
-
- run: bundle exec rake
|
13
|
+
uses: metanorma/metanorma-build-scripts/.github/workflows/generic-rake.yml@main
|
14
|
+
secrets:
|
15
|
+
pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
@@ -15,32 +15,10 @@ on:
|
|
15
15
|
|
16
16
|
jobs:
|
17
17
|
release:
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
uses: metanorma/metanorma-build-scripts/.github/workflows/rubygems-release.yml@main
|
19
|
+
with:
|
20
|
+
next_version: ${{ github.event.inputs.next_version }}
|
21
|
+
event_name: ${{ github.event_name }}
|
22
|
+
secrets:
|
23
|
+
rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
|
21
24
|
|
22
|
-
- uses: ruby/setup-ruby@v1
|
23
|
-
with:
|
24
|
-
ruby-version: '2.6'
|
25
|
-
bundler-cache: true
|
26
|
-
|
27
|
-
- run: gem install gem-release
|
28
|
-
|
29
|
-
- run: |
|
30
|
-
git config user.name github-actions
|
31
|
-
git config user.email github-actions@github.com
|
32
|
-
|
33
|
-
- if: github.event_name == 'workflow_dispatch' && github.event.inputs.next_version != 'skip'
|
34
|
-
run: gem bump --version ${{ github.event.inputs.next_version }} --tag --push
|
35
|
-
|
36
|
-
- name: publish to rubygems.org
|
37
|
-
env:
|
38
|
-
RUBYGEMS_API_KEY: ${{secrets.METANORMA_CI_RUBYGEMS_API_KEY}}
|
39
|
-
run: |
|
40
|
-
gem install gem-release
|
41
|
-
envsubst << 'EOF' > ~/.gem/credentials
|
42
|
-
---
|
43
|
-
:rubygems_api_key: ${RUBYGEMS_API_KEY}
|
44
|
-
EOF
|
45
|
-
chmod 0600 ~/.gem/credentials
|
46
|
-
gem release
|
data/README.adoc
CHANGED
@@ -14,11 +14,6 @@ The `stepmod-utils` Ruby gem provides a number of tools to work with the STEPmod
|
|
14
14
|
repository.
|
15
15
|
|
16
16
|
|
17
|
-
== CVS to Git migration procedures
|
18
|
-
|
19
|
-
include::migrating_from_cvs.adoc[]
|
20
|
-
|
21
|
-
|
22
17
|
== Installation
|
23
18
|
|
24
19
|
[source,ruby]
|
@@ -116,48 +111,15 @@ expg_image:contract_schemaexpg1.xml[]
|
|
116
111
|
expg_image:contract_schemaexpg2.xml[]
|
117
112
|
----
|
118
113
|
|
114
|
+
== Git repository
|
119
115
|
|
120
|
-
|
121
|
-
|
122
|
-
If the STEPmod repository is a CVS repository, it will display the
|
123
|
-
working and repository revisions as comments.
|
124
|
-
|
125
|
-
WARNING: CVS revision detection can be *slow*! Be patient.
|
126
|
-
|
127
|
-
Sample output:
|
128
|
-
|
129
|
-
[source,sh]
|
130
|
-
----
|
131
|
-
[stepmod-utils] INFO: STEPmod directory set to ../x/stepmod/.
|
132
|
-
[stepmod-utils] INFO: STEPmod directory is a CVS repository and will detect revisions.
|
133
|
-
[stepmod-utils] INFO: [CVS] Detecting file revisions can be slow, please be patient!
|
134
|
-
[stepmod-utils] INFO: Detecting paths...
|
135
|
-
[stepmod-utils] INFO: Processing XML file data/business_object_models/managed_model_based_3d_engineering/business_object_model.xml
|
136
|
-
[stepmod-utils] INFO: Detecting CVS revision...
|
137
|
-
[stepmod-utils] INFO: CVS working rev (1.148), repo rev (1.148)
|
138
|
-
[stepmod-utils] INFO: Completed processing XML file data/business_object_models/managed_model_based_3d_engineering/business_object_model.xml
|
139
|
-
[stepmod-utils] INFO: Processing XML file data/business_object_models/managed_model_based_3d_engineering_domain/business_object_model.xml
|
140
|
-
[stepmod-utils] INFO: Detecting CVS revision...
|
141
|
-
[stepmod-utils] INFO: CVS working rev (1.31), repo rev (1.31)
|
142
|
-
[stepmod-utils] INFO: Completed processing XML file data/business_object_models/managed_model_based_3d_engineering_domain/business_object_model.xml
|
143
|
-
...
|
144
|
-
stepmod/data/business_object_models/managed_model_based_3d_engineering_domain/business_object_model.xml
|
145
|
-
[stepmod-utils] INFO: written to: 031-generated-terms.adoc
|
146
|
-
[stepmod-utils] INFO: written to: 991-generated-bibliography.adoc
|
147
|
-
----
|
148
|
-
|
149
|
-
|
150
|
-
== Non-CVS repository
|
151
|
-
|
152
|
-
If the STEPmod repository is not a CVS repository, or if the `cvs` executable
|
153
|
-
cannot be found, term extract will still work.
|
116
|
+
If the STEPmod repository is a Git repository, term extract will work.
|
154
117
|
|
155
118
|
Sample output:
|
156
119
|
|
157
120
|
[source,sh]
|
158
121
|
----
|
159
122
|
[stepmod-utils] INFO: STEPmod directory set to ../iso-10303-stepmod.
|
160
|
-
[stepmod-utils] INFO: STEPmod directory is not a CVS repository, skipping revision detection.
|
161
123
|
[stepmod-utils] INFO: Detecting paths...
|
162
124
|
[stepmod-utils] INFO: Processing XML file data/application_protocols/boundary_representation_for_iso_14306_open_jt/application_protocol.xml
|
163
125
|
[stepmod-utils] INFO: skipped ISO/CD 10303-243 as it is not IS, DIS or TS
|
data/exe/stepmod-extract-terms
CHANGED
@@ -30,7 +30,7 @@ options = {}
|
|
30
30
|
OptionParser.new do |opts|
|
31
31
|
opts.banner = "Usage: #{$0} [options]"
|
32
32
|
|
33
|
-
opts.on("-p", "--path STEPMOD_DATA_PATH", String, "Path to STEPmod
|
33
|
+
opts.on("-p", "--path STEPMOD_DATA_PATH", String, "Path to STEPmod data directory") do |path|
|
34
34
|
options[:stepmod_dir] = path
|
35
35
|
end
|
36
36
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "stepmod/utils/converters/synonym"
|
4
|
+
require "stepmod/utils/term"
|
5
|
+
require "glossarist"
|
4
6
|
|
5
7
|
module Stepmod
|
6
8
|
module Utils
|
@@ -22,22 +24,20 @@ module Stepmod
|
|
22
24
|
unless first_child &&
|
23
25
|
node.text.split(";").length == 2 &&
|
24
26
|
defined?(Stepmod::Utils::Converters::Synonym)
|
25
|
-
|
27
|
+
|
28
|
+
return Stepmod::Utils::Term.from_h(
|
29
|
+
"definition" => treat_children(node, state).strip,
|
30
|
+
).to_mn_adoc
|
26
31
|
end
|
27
32
|
|
28
33
|
term_def, alt = node.text.split(";")
|
29
34
|
alt_xml = Nokogiri::XML::Text.new(alt, Nokogiri::XML::Document.new)
|
30
35
|
converted_alt = Stepmod::Utils::Converters::Synonym.new.convert(alt_xml)
|
31
|
-
"=== #{treat_acronym(term_def)}\n\n#{converted_alt}"
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def treat_acronym(term_def)
|
37
|
-
return term_def.strip if term_def !~ /.+\(.+?\)$/
|
38
36
|
|
39
|
-
|
40
|
-
|
37
|
+
Stepmod::Utils::Term.from_h(
|
38
|
+
"definition" => term_def,
|
39
|
+
"synonyms" => [converted_alt],
|
40
|
+
).to_mn_adoc
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "glossarist"
|
2
|
+
|
3
|
+
module Stepmod
|
4
|
+
module Utils
|
5
|
+
class Term < Glossarist::LocalizedConcept
|
6
|
+
# Term acronym
|
7
|
+
attr_accessor :acronym
|
8
|
+
|
9
|
+
def to_mn_adoc
|
10
|
+
mn_adoc = ["=== #{definition}"]
|
11
|
+
mn_adoc << "\nalt:[#{acronym}]" if acronym
|
12
|
+
mn_adoc << "\n\n#{designations.join(", ")}" if designations&.any?
|
13
|
+
|
14
|
+
mn_adoc.join
|
15
|
+
end
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def from_h(hash)
|
19
|
+
_, definition, acronym = treat_acronym(hash["definition"])
|
20
|
+
|
21
|
+
hash["definition"] = definition
|
22
|
+
hash["acronym"] = acronym.gsub(/\(|\)/, "") if acronym
|
23
|
+
hash["designations"] = hash["synonyms"]
|
24
|
+
|
25
|
+
super(hash.reject { |k, _| k == "synonyms" })
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def treat_acronym(term_def)
|
31
|
+
return [nil, term_def.strip, nil] unless term_def.match?(/.+\(.+?\)$/)
|
32
|
+
|
33
|
+
term_def.match(/(.+?)(\(.+\))$/).to_a
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -20,7 +20,6 @@ module Stepmod
|
|
20
20
|
:resource_concepts,
|
21
21
|
:parsed_bibliography,
|
22
22
|
:encountered_terms,
|
23
|
-
:cvs_mode,
|
24
23
|
:part_concepts,
|
25
24
|
:part_resources,
|
26
25
|
:part_modules,
|
@@ -60,25 +59,7 @@ module Stepmod
|
|
60
59
|
end
|
61
60
|
|
62
61
|
def call
|
63
|
-
# If we are using the stepmod CVS repository, provide the revision number per file
|
64
|
-
@cvs_mode = if Dir.exists?(stepmod_path.join("CVS"))
|
65
|
-
require "ptools"
|
66
|
-
# ptools provides File.which
|
67
|
-
File.which("cvs")
|
68
|
-
end
|
69
|
-
|
70
62
|
log "INFO: STEPmod directory set to #{stepmod_dir}."
|
71
|
-
|
72
|
-
if cvs_mode
|
73
|
-
log "INFO: STEPmod directory is a \
|
74
|
-
CVS repository and will detect revisions."
|
75
|
-
log "INFO: [CVS] Detecting file revisions can be slow, \
|
76
|
-
please be patient!"
|
77
|
-
else
|
78
|
-
log "INFO: STEPmod directory is not a CVS repository, \
|
79
|
-
skipping revision detection."
|
80
|
-
end
|
81
|
-
|
82
63
|
log "INFO: Detecting paths..."
|
83
64
|
|
84
65
|
repo_index = Nokogiri::XML(File.read(@index_path)).root
|
@@ -161,24 +142,15 @@ module Stepmod
|
|
161
142
|
next
|
162
143
|
end
|
163
144
|
|
164
|
-
revision_string = "
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
working_rev = status.split(/\n/).grep(/Working revision:/)
|
174
|
-
.first.match(/revision:\s+(.+)$/)[1]
|
175
|
-
repo_rev = status.split(/\n/).grep(/Repository revision:/)
|
176
|
-
.first.match(/revision:\t(.+)\t/)[1]
|
177
|
-
log "INFO: CVS working rev (#{working_rev}), \
|
178
|
-
repo rev (#{repo_rev})"
|
179
|
-
revision_string = "\n// CVS working rev: (#{working_rev}), repo rev (#{repo_rev})\n" +
|
180
|
-
"// CVS: revision #{working_rev == repo_rev ? 'up to date' : 'differs'}"
|
181
|
-
end
|
145
|
+
revision_string = ""
|
146
|
+
|
147
|
+
# Run `cvs status` to find out version
|
148
|
+
log "INFO: Detecting Git SHA..."
|
149
|
+
Dir.chdir(stepmod_path) do
|
150
|
+
git_sha = `git rev-parse HEAD`
|
151
|
+
|
152
|
+
unless git_sha.empty?
|
153
|
+
revision_string = "\n// Git: SHA #{git_sha}"
|
182
154
|
end
|
183
155
|
end
|
184
156
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stepmod-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -213,6 +213,7 @@ files:
|
|
213
213
|
- lib/stepmod/utils/smrl_resource_converter.rb
|
214
214
|
- lib/stepmod/utils/stepmod_definition_converter.rb
|
215
215
|
- lib/stepmod/utils/stepmod_file_annotator.rb
|
216
|
+
- lib/stepmod/utils/term.rb
|
216
217
|
- lib/stepmod/utils/terms_extractor.rb
|
217
218
|
- lib/stepmod/utils/version.rb
|
218
219
|
- resource_example.xml
|