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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0fb38c39db845a0b6ff3358d7dea3b0b5f687c50109ee6318438a7787453e5e
4
- data.tar.gz: 7ac3bdf768eeac0805f19fd41703632ed12460c4216b98c5a4b689dc99491033
3
+ metadata.gz: e40fc2ba271e4bd8e0859cb307831ead927b7bc12154b5845f528694ad18c8f8
4
+ data.tar.gz: e1b6f691a70d1e6531a7f841b5a998d49d6c376a84a9da340246b2920bd8459d
5
5
  SHA512:
6
- metadata.gz: 799b824cd2eec2efe7d3c5a7972ac21ead6af9b493e13e7ec78a3cfb6417e3576835e5aead8ac07ca264ae3513758cb212259d7ed0e0cb9713acb025393c26e6
7
- data.tar.gz: 2b95f4f76fb19b09695d6cceddce5d854a4843bdfab62d645363b9fa379ad8616c8e1c361802264703c00684b9a3f7242c0aa22b6448ec8cc2e555cea85e797e
6
+ metadata.gz: e5e62c15d95982deb33e03af65b9720cdb34746adfa36bf5945a2823fb0be9800beff3e8cf4b3e4acd34ebf940bacb0ff2b4a83b31af27e8d01cba2599fcc537
7
+ data.tar.gz: c9efdfa5eed962291c9454227e8d2c7c22b4ba665c88745d059f77cdfb5ae2bdb414d32d7c1ee957aec10db634c1f0fbc388851360ae4edb9bf9d721f740dca3
@@ -10,23 +10,6 @@ on:
10
10
 
11
11
  jobs:
12
12
  rake:
13
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
- runs-on: ${{ matrix.os }}
15
- continue-on-error: ${{ matrix.experimental }}
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
- runs-on: ubuntu-latest
19
- steps:
20
- - uses: actions/checkout@v2
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
- == CVS revision detection
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
@@ -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 CVS data directory") do |path|
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
- return "=== #{treat_acronym(treat_children(node, state).strip)}"
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
- _, term_text, term_acronym = term_def.match(/(.+?)(\(.+\))$/).to_a
40
- "#{term_text.strip}\nalt:[#{term_acronym.gsub(/\(|\)/, '')}]"
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 = "\n// CVS: revision not detected"
165
- if cvs_mode
166
- # Run `cvs status` to find out version
167
-
168
- log "INFO: Detecting CVS revision..."
169
- Dir.chdir(stepmod_path) do
170
- status = `cvs status #{fpath}`
171
-
172
- unless status.empty?
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
 
@@ -1,5 +1,5 @@
1
1
  module Stepmod
2
2
  module Utils
3
- VERSION = "0.3.15".freeze
3
+ VERSION = "0.3.16".freeze
4
4
  end
5
5
  end
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.15
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: 2021-11-16 00:00:00.000000000 Z
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