stepmod-utils 0.6.8 → 0.6.9
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 +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile +6 -3
- data/exe/stepmod-convert-express-description +1 -1
- data/exe/stepmod-convert-express-resource +1 -1
- data/lib/stepmod/utils/cleaner.rb +4 -3
- data/lib/stepmod/utils/concept.rb +33 -17
- data/lib/stepmod/utils/converters/a.rb +1 -1
- data/lib/stepmod/utils/converters/arm.rb +1 -1
- data/lib/stepmod/utils/converters/base.rb +3 -3
- data/lib/stepmod/utils/converters/clause_ref.rb +1 -1
- data/lib/stepmod/utils/converters/comment.rb +1 -1
- data/lib/stepmod/utils/converters/dd.rb +1 -1
- data/lib/stepmod/utils/converters/def.rb +2 -2
- data/lib/stepmod/utils/converters/definition.rb +1 -1
- data/lib/stepmod/utils/converters/description.rb +1 -1
- data/lib/stepmod/utils/converters/dl.rb +1 -1
- data/lib/stepmod/utils/converters/dt.rb +1 -1
- data/lib/stepmod/utils/converters/em.rb +2 -2
- data/lib/stepmod/utils/converters/em_express_description.rb +5 -1
- data/lib/stepmod/utils/converters/eqn.rb +2 -2
- data/lib/stepmod/utils/converters/example.rb +1 -1
- data/lib/stepmod/utils/converters/express_figure.rb +2 -1
- data/lib/stepmod/utils/converters/express_g.rb +1 -1
- data/lib/stepmod/utils/converters/express_note.rb +1 -1
- data/lib/stepmod/utils/converters/express_ref.rb +1 -1
- data/lib/stepmod/utils/converters/express_ref_express_description.rb +2 -1
- data/lib/stepmod/utils/converters/ext_description.rb +2 -1
- data/lib/stepmod/utils/converters/ext_descriptions.rb +2 -1
- data/lib/stepmod/utils/converters/figure.rb +2 -2
- data/lib/stepmod/utils/converters/fund_cons.rb +1 -1
- data/lib/stepmod/utils/converters/introduction.rb +1 -1
- data/lib/stepmod/utils/converters/li.rb +2 -2
- data/lib/stepmod/utils/converters/module_ref.rb +1 -1
- data/lib/stepmod/utils/converters/module_ref_express_description.rb +2 -2
- data/lib/stepmod/utils/converters/note.rb +1 -1
- data/lib/stepmod/utils/converters/ol.rb +2 -2
- data/lib/stepmod/utils/converters/resource.rb +1 -1
- data/lib/stepmod/utils/converters/schema.rb +1 -1
- data/lib/stepmod/utils/converters/schema_diag.rb +1 -1
- data/lib/stepmod/utils/converters/stepmod_ext_description.rb +2 -1
- data/lib/stepmod/utils/converters/strong.rb +2 -2
- data/lib/stepmod/utils/converters/sub.rb +8 -3
- data/lib/stepmod/utils/converters/sup.rb +8 -3
- data/lib/stepmod/utils/converters/synonym.rb +1 -1
- data/lib/stepmod/utils/converters/table.rb +2 -2
- data/lib/stepmod/utils/converters/term.rb +1 -1
- data/lib/stepmod/utils/converters/text.rb +2 -2
- data/lib/stepmod/utils/converters/tr.rb +2 -2
- data/lib/stepmod/utils/smrl_description_converter.rb +2 -2
- data/lib/stepmod/utils/smrl_resource_converter.rb +2 -2
- data/lib/stepmod/utils/stepmod_definition_converter.rb +2 -2
- data/lib/stepmod/utils/stepmod_file_annotator.rb +11 -11
- data/lib/stepmod/utils/term.rb +36 -14
- data/lib/stepmod/utils/terms_extractor.rb +17 -13
- data/lib/stepmod/utils/version.rb +1 -1
- data/stepmod-utils.gemspec +14 -17
- metadata +20 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b84fbdfaf0322f4f207043d9f7f8034a58539f33c030846c593f6c3cac8b7c8
|
4
|
+
data.tar.gz: 8689dceb2e71c4401732e5e5e1c522be9bca434de6014f2054e54ef85e3e9845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebc46e61ce576382b898913fc348ba473e52fb23a7fb65677ac6436a93d5bfcf1a9208e64f3d25c38a0e57eac7718384589dabfebac2925deb3fb6e39ba4d529
|
7
|
+
data.tar.gz: d075afeb2933647f9b6fc2fe32a32f2dcf49f4a7dc0ed12fa750f4ae4f02aac115a5e08581bacd68869a14c3c02fc3a4c794e0676bd6dc2dae02411398fd385c
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -5,7 +5,10 @@ source "https://rubygems.org"
|
|
5
5
|
gemspec
|
6
6
|
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
7
7
|
|
8
|
-
gem "concurrent-ruby"
|
8
|
+
gem "concurrent-ruby"
|
9
9
|
gem "pry"
|
10
|
-
gem "rake"
|
11
|
-
gem "rspec"
|
10
|
+
gem "rake"
|
11
|
+
gem "rspec"
|
12
|
+
gem "rubocop"
|
13
|
+
gem "rubocop-performance"
|
14
|
+
gem "rubocop-rails"
|
@@ -11,7 +11,7 @@ $:.unshift File.expand_path("../../lib", bin_file)
|
|
11
11
|
require "bundler/setup"
|
12
12
|
require "stepmod/utils/smrl_description_converter"
|
13
13
|
|
14
|
-
Coradoc::Input::
|
14
|
+
Coradoc::Input::Html.config.unknown_tags = :bypass
|
15
15
|
|
16
16
|
input_content = ARGF.read
|
17
17
|
|
@@ -11,7 +11,7 @@ $:.unshift File.expand_path("../../lib", bin_file)
|
|
11
11
|
require "bundler/setup"
|
12
12
|
require "stepmod/utils/smrl_resource_converter"
|
13
13
|
|
14
|
-
Coradoc::Input::
|
14
|
+
Coradoc::Input::Html.config.unknown_tags = :bypass
|
15
15
|
|
16
16
|
input_content = ARGF.read
|
17
17
|
|
@@ -2,13 +2,13 @@ require "coradoc/input/html/cleaner"
|
|
2
2
|
|
3
3
|
module Stepmod
|
4
4
|
module Utils
|
5
|
-
class Cleaner < Coradoc::Input::
|
5
|
+
class Cleaner < Coradoc::Input::Html::Cleaner
|
6
6
|
def tidy(string)
|
7
7
|
super
|
8
8
|
.gsub(/^ +/, "")
|
9
9
|
.gsub(/\*\s([,.])/, '*\1') # remove space between * and comma or dot.
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
# Find non-asterisk content that is enclosed by two or
|
13
13
|
# more asterisks. Ensure that only one whitespace occurs
|
14
14
|
# in the border area.
|
@@ -23,7 +23,8 @@ module Stepmod
|
|
23
23
|
result = string.dup
|
24
24
|
patterns.each do |pattern, value|
|
25
25
|
result = result.gsub(pattern) do |match|
|
26
|
-
preserve_border_whitespaces(match,
|
26
|
+
preserve_border_whitespaces(match,
|
27
|
+
default_border: Coradoc::Input::Html.config.tag_border) do
|
27
28
|
match.strip.sub(" #{value}", value).sub("#{value} ", value)
|
28
29
|
end
|
29
30
|
end
|
@@ -3,16 +3,17 @@ require "glossarist"
|
|
3
3
|
module Stepmod
|
4
4
|
module Utils
|
5
5
|
class Concept < Glossarist::LocalizedConcept
|
6
|
-
|
6
|
+
CUSTOM_ATTRIBUTES = %w(
|
7
7
|
reference_clause
|
8
8
|
reference_anchor
|
9
9
|
converted_definition
|
10
10
|
file_path
|
11
11
|
schema
|
12
12
|
part
|
13
|
-
domain
|
14
13
|
document
|
15
|
-
)
|
14
|
+
).freeze
|
15
|
+
|
16
|
+
attr_accessor(*CUSTOM_ATTRIBUTES)
|
16
17
|
|
17
18
|
# TODO: converted_definition is not supposed to be an attribute, it is
|
18
19
|
# supposed to be a method!
|
@@ -45,14 +46,20 @@ file_path:, language_code: "eng")
|
|
45
46
|
# TODO: `designations:` should include the `alt:[...]` terms here,
|
46
47
|
# they are now only included in definition_xml_converted_definition.
|
47
48
|
new(
|
48
|
-
|
49
|
-
|
49
|
+
data: Glossarist::ConceptData.new(
|
50
|
+
{
|
51
|
+
terms: designation,
|
52
|
+
definition: [
|
53
|
+
Glossarist::DetailedDefinition.new({ content: definition }),
|
54
|
+
],
|
55
|
+
language_code: language_code,
|
56
|
+
},
|
57
|
+
),
|
50
58
|
converted_definition: converted_definition,
|
51
59
|
id: "#{reference_anchor}.#{reference_clause}",
|
52
60
|
reference_anchor: reference_anchor,
|
53
61
|
reference_clause: reference_clause,
|
54
62
|
file_path: file_path,
|
55
|
-
language_code: language_code,
|
56
63
|
)
|
57
64
|
end
|
58
65
|
|
@@ -80,7 +87,9 @@ file_path:, language_code: "eng")
|
|
80
87
|
designations << { "designation" => alt, "type" => "expression" }
|
81
88
|
end
|
82
89
|
|
83
|
-
designations
|
90
|
+
designations.map do |des|
|
91
|
+
Glossarist::Designation::Base.from_yaml(des.to_yaml)
|
92
|
+
end
|
84
93
|
end
|
85
94
|
|
86
95
|
def definition_xml_definition(definition_xml, reference_anchor)
|
@@ -106,24 +115,19 @@ file_path:, language_code: "eng")
|
|
106
115
|
end
|
107
116
|
|
108
117
|
def definition_xml_converted_definition(designation, definition)
|
109
|
-
accepted_designation = designation.select
|
110
|
-
|
111
|
-
end
|
112
|
-
|
113
|
-
alt_designations = designation.reject do |des|
|
114
|
-
des["normative_status"] == "preferred"
|
115
|
-
end
|
118
|
+
accepted_designation = designation.select(&:preferred?)
|
119
|
+
alt_designations = designation.reject(&:preferred?)
|
116
120
|
|
117
121
|
if alt_designations.length.positive?
|
118
122
|
alt_designations_text = alt_designations.map do |d|
|
119
|
-
d
|
123
|
+
d.designation.strip
|
120
124
|
end.join(",")
|
121
125
|
|
122
126
|
alt_notation = "alt:[#{alt_designations_text}]"
|
123
127
|
end
|
124
128
|
|
125
129
|
result = <<~TEXT
|
126
|
-
=== #{accepted_designation.map { |d| d
|
130
|
+
=== #{accepted_designation.map { |d| d.designation.strip }.join(',')}
|
127
131
|
TEXT
|
128
132
|
|
129
133
|
if alt_notation
|
@@ -140,6 +144,14 @@ file_path:, language_code: "eng")
|
|
140
144
|
end
|
141
145
|
end
|
142
146
|
|
147
|
+
def initialize(hash = {})
|
148
|
+
super(hash)
|
149
|
+
|
150
|
+
CUSTOM_ATTRIBUTES.each do |attr|
|
151
|
+
public_send("#{attr}=", hash[attr] || hash[attr.to_sym])
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
143
155
|
def to_h
|
144
156
|
super.merge({
|
145
157
|
"domain" => domain,
|
@@ -149,9 +161,13 @@ file_path:, language_code: "eng")
|
|
149
161
|
}.compact)
|
150
162
|
end
|
151
163
|
|
164
|
+
def domain
|
165
|
+
data.domain
|
166
|
+
end
|
167
|
+
|
152
168
|
def to_mn_adoc
|
153
169
|
<<~TEXT
|
154
|
-
// STEPmod path:#{file_path.empty? ? '' : " #{file_path}"}
|
170
|
+
// STEPmod path:#{file_path.to_s.empty? ? '' : " #{file_path}"}
|
155
171
|
#{converted_definition}
|
156
172
|
|
157
173
|
[.source]
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "coradoc"
|
2
|
+
require "coradoc/input/html"
|
3
3
|
|
4
4
|
module Stepmod
|
5
5
|
module Utils
|
6
6
|
module Converters
|
7
|
-
class Base < Coradoc::Input::
|
7
|
+
class Base < Coradoc::Input::Html::Converters::Base
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
@@ -78,8 +78,8 @@ module Stepmod
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
Coradoc::Input::
|
82
|
-
Coradoc::Input::
|
81
|
+
Coradoc::Input::Html::Converters.register :def, Def.new
|
82
|
+
Coradoc::Input::Html::Converters.register :description, Def.new
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -14,8 +14,8 @@ module Stepmod
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
Coradoc::Input::
|
18
|
-
Coradoc::Input::
|
17
|
+
Coradoc::Input::Html::Converters.register :em, Em.new
|
18
|
+
Coradoc::Input::Html::Converters.register :cite, Em.new
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -8,6 +8,10 @@ module Stepmod
|
|
8
8
|
italic_converted(node, state)
|
9
9
|
end
|
10
10
|
|
11
|
+
def to_coradoc(node, state = {})
|
12
|
+
italic_converted(node, state)
|
13
|
+
end
|
14
|
+
|
11
15
|
private
|
12
16
|
|
13
17
|
def italic_converted(node, state)
|
@@ -44,7 +48,7 @@ module Stepmod
|
|
44
48
|
end
|
45
49
|
end
|
46
50
|
|
47
|
-
Coradoc::Input::
|
51
|
+
Coradoc::Input::Html::Converters.register :i, Em.new
|
48
52
|
end
|
49
53
|
end
|
50
54
|
end
|
@@ -123,8 +123,8 @@ module Stepmod
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
Coradoc::Input::
|
127
|
-
Coradoc::Input::
|
126
|
+
Coradoc::Input::Html::Converters.register :eqn, Eqn.new
|
127
|
+
Coradoc::Input::Html::Converters.register :bigeqn, Eqn.new
|
128
128
|
end
|
129
129
|
end
|
130
130
|
end
|
@@ -7,7 +7,8 @@ module Stepmod
|
|
7
7
|
"<<express:#{parts.join('.').strip},#{parts.last.strip}>>"
|
8
8
|
end
|
9
9
|
end
|
10
|
-
Coradoc::Input::
|
10
|
+
Coradoc::Input::Html::Converters.register :express_ref,
|
11
|
+
ExpressRefExpressDescription.new
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -5,7 +5,7 @@ require "coradoc/input/html/converters/figure"
|
|
5
5
|
module Stepmod
|
6
6
|
module Utils
|
7
7
|
module Converters
|
8
|
-
class Figure < Coradoc::Input::
|
8
|
+
class Figure < Coradoc::Input::Html::Converters::Figure
|
9
9
|
def self.pattern(state, id)
|
10
10
|
if state[:schema_and_entity].nil?
|
11
11
|
raise StandardError.new("[figure]: no state given, #{id}")
|
@@ -43,7 +43,7 @@ module Stepmod
|
|
43
43
|
end
|
44
44
|
|
45
45
|
# This replaces the converter
|
46
|
-
Coradoc::Input::
|
46
|
+
Coradoc::Input::Html::Converters.register :figure, Figure.new
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Stepmod
|
4
4
|
module Utils
|
5
5
|
module Converters
|
6
|
-
class Li < Coradoc::Input::
|
6
|
+
class Li < Coradoc::Input::Html::Converters::Li
|
7
7
|
def to_coradoc(node, state = {})
|
8
8
|
li = super
|
9
9
|
li.content = li.content.map do |content|
|
@@ -14,7 +14,7 @@ module Stepmod
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
Coradoc::Input::
|
17
|
+
Coradoc::Input::Html::Converters.register :li, Li.new
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -45,8 +45,8 @@ module Stepmod
|
|
45
45
|
# puts "[module_ref] #{result}"
|
46
46
|
end
|
47
47
|
end
|
48
|
-
Coradoc::Input::
|
49
|
-
|
48
|
+
Coradoc::Input::Html::Converters.register :module_ref,
|
49
|
+
ModuleRefExpressDescription.new
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Stepmod
|
4
4
|
module Utils
|
5
5
|
module Converters
|
6
|
-
class Ol < Coradoc::Input::
|
6
|
+
class Ol < Coradoc::Input::Html::Converters::Ol
|
7
7
|
LIST_TAGS = ["ol", "ul", "dir"].freeze
|
8
8
|
|
9
9
|
def to_coradoc(node, state = {})
|
@@ -15,7 +15,7 @@ module Stepmod
|
|
15
15
|
end
|
16
16
|
|
17
17
|
Ol::LIST_TAGS.each do |tag|
|
18
|
-
Coradoc::Input::
|
18
|
+
Coradoc::Input::Html::Converters.register tag.to_sym, Ol.new
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -66,8 +66,8 @@ module Stepmod
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
Coradoc::Input::
|
70
|
-
Coradoc::Input::
|
69
|
+
Coradoc::Input::Html::Converters.register :strong, Strong.new
|
70
|
+
Coradoc::Input::Html::Converters.register :b, Strong.new
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -3,9 +3,14 @@
|
|
3
3
|
module Stepmod
|
4
4
|
module Utils
|
5
5
|
module Converters
|
6
|
-
class Sub < Coradoc::Input::
|
6
|
+
class Sub < Coradoc::Input::Html::Converters::Sub
|
7
7
|
def to_coradoc(node, state = {})
|
8
|
-
state[:equation]
|
8
|
+
if state[:equation]
|
9
|
+
stem_notation(treat_children(node,
|
10
|
+
state))
|
11
|
+
else
|
12
|
+
super(node, state)
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
11
16
|
private
|
@@ -15,7 +20,7 @@ module Stepmod
|
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
18
|
-
Coradoc::Input::
|
23
|
+
Coradoc::Input::Html::Converters.register :sub, Sub.new
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -3,9 +3,14 @@
|
|
3
3
|
module Stepmod
|
4
4
|
module Utils
|
5
5
|
module Converters
|
6
|
-
class Sup < Coradoc::Input::
|
6
|
+
class Sup < Coradoc::Input::Html::Converters::Sup
|
7
7
|
def to_coradoc(node, state = {})
|
8
|
-
state[:equation]
|
8
|
+
if state[:equation]
|
9
|
+
stem_notation(treat_children(node,
|
10
|
+
state))
|
11
|
+
else
|
12
|
+
super(node, state)
|
13
|
+
end
|
9
14
|
end
|
10
15
|
|
11
16
|
def stem_notation(content)
|
@@ -13,7 +18,7 @@ module Stepmod
|
|
13
18
|
end
|
14
19
|
end
|
15
20
|
|
16
|
-
Coradoc::Input::
|
21
|
+
Coradoc::Input::Html::Converters.register :sup, Sup.new
|
17
22
|
end
|
18
23
|
end
|
19
24
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Stepmod
|
4
4
|
module Utils
|
5
5
|
module Converters
|
6
|
-
class Table < Coradoc::Input::
|
6
|
+
class Table < Coradoc::Input::Html::Converters::Table
|
7
7
|
def self.pattern(state, id)
|
8
8
|
if state[:schema_and_entity].nil?
|
9
9
|
raise StandardError.new("[table]: no state given, #{id}")
|
@@ -72,7 +72,7 @@ module Stepmod
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
Coradoc::Input::
|
75
|
+
Coradoc::Input::Html::Converters.register :table, Table.new
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Stepmod
|
4
4
|
module Utils
|
5
5
|
module Converters
|
6
|
-
class Text < Coradoc::Input::
|
6
|
+
class Text < Coradoc::Input::Html::Converters::Text
|
7
7
|
def to_coradoc(node, state = {})
|
8
8
|
if node.text.strip.empty?
|
9
9
|
treat_empty(node, state)
|
@@ -64,7 +64,7 @@ module Stepmod
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
Coradoc::Input::
|
67
|
+
Coradoc::Input::Html::Converters.register :text, Text.new
|
68
68
|
end
|
69
69
|
end
|
70
70
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Stepmod
|
4
4
|
module Utils
|
5
5
|
module Converters
|
6
|
-
class Tr < Coradoc::Input::
|
6
|
+
class Tr < Coradoc::Input::Html::Converters::Tr
|
7
7
|
def to_coradoc(node, state = {})
|
8
8
|
content = super(node, state)
|
9
9
|
line_break = content.header ? "\n\n" : "\n"
|
@@ -11,7 +11,7 @@ module Stepmod
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
Coradoc::Input::
|
14
|
+
Coradoc::Input::Html::Converters.register :tr, Tr.new
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -34,8 +34,8 @@ module Stepmod
|
|
34
34
|
|
35
35
|
root || (return "")
|
36
36
|
|
37
|
-
Coradoc::Input::
|
38
|
-
result = Coradoc::Input::
|
37
|
+
Coradoc::Input::Html.config.with(options) do
|
38
|
+
result = Coradoc::Input::Html::Converters.lookup(root.name).convert(root,
|
39
39
|
options)
|
40
40
|
Stepmod::Utils::Cleaner.new.tidy(result)
|
41
41
|
end
|
@@ -51,8 +51,8 @@ module Stepmod
|
|
51
51
|
|
52
52
|
root || (return "")
|
53
53
|
|
54
|
-
Coradoc::Input::
|
55
|
-
result = Coradoc::Input::
|
54
|
+
Coradoc::Input::Html.config.with(options) do
|
55
|
+
result = Coradoc::Input::Html::Converters.lookup(root.name).convert(root,
|
56
56
|
options)
|
57
57
|
|
58
58
|
Stepmod::Utils::Cleaner.new.tidy(result)
|
@@ -50,8 +50,8 @@ module Stepmod
|
|
50
50
|
|
51
51
|
return "" unless root
|
52
52
|
|
53
|
-
Coradoc::Input::
|
54
|
-
result = Coradoc::Input::
|
53
|
+
Coradoc::Input::Html.config.with(options) do
|
54
|
+
result = Coradoc::Input::Html::Converters.lookup(root.name).convert(root,
|
55
55
|
options)
|
56
56
|
return "" unless result
|
57
57
|
|
@@ -58,7 +58,7 @@ module Stepmod
|
|
58
58
|
def replace_schema_string_with_version(content)
|
59
59
|
m = content.match(SCHEMA_VERSION_MATCH_REGEX)
|
60
60
|
result = build_schema_string_with_version
|
61
|
-
unless m[
|
61
|
+
unless m["trailing"].nil?
|
62
62
|
result = "#{result}#{m['trailing']}"
|
63
63
|
end
|
64
64
|
|
@@ -178,19 +178,19 @@ module Stepmod
|
|
178
178
|
|
179
179
|
unless bib_file && File.exist?(bib_file)
|
180
180
|
raise StandardError.new(
|
181
|
-
"bib_file for #{schema_name} does not exist: #{bib_file}"
|
181
|
+
"bib_file for #{schema_name} does not exist: #{bib_file}",
|
182
182
|
)
|
183
183
|
end
|
184
184
|
|
185
185
|
output_express << prepend_bibdata(
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
186
|
+
converted_description || "",
|
187
|
+
# bib_file will not be present for resouces
|
188
|
+
# that are not in resource_docs cache.
|
189
|
+
# e.g hierarchy_schema
|
190
|
+
bib_file,
|
191
|
+
@schema_name,
|
192
|
+
match,
|
193
|
+
)
|
194
194
|
|
195
195
|
if is_missing_version(output_express)
|
196
196
|
puts "[annotator-WARNING] schema (#{@schema_name}) missing version string. "\
|
@@ -252,7 +252,7 @@ processed_images_cache)
|
|
252
252
|
#{Stepmod::Utils::SmrlDescriptionConverter.convert(
|
253
253
|
wrapper,
|
254
254
|
no_notes_examples: true,
|
255
|
-
descriptions_file: descriptions_file
|
255
|
+
descriptions_file: descriptions_file,
|
256
256
|
)}
|
257
257
|
DESCRIPTION
|
258
258
|
|
data/lib/stepmod/utils/term.rb
CHANGED
@@ -8,8 +8,14 @@ module Stepmod
|
|
8
8
|
|
9
9
|
def to_mn_adoc
|
10
10
|
mn_adoc = ["=== #{definition.map(&:content).join}"]
|
11
|
-
|
12
|
-
|
11
|
+
|
12
|
+
designations.each do |designation|
|
13
|
+
mn_adoc << if designation.type == "abbreviation" && designation.acronym
|
14
|
+
"\nalt:[#{designation.designation}]"
|
15
|
+
else
|
16
|
+
"\n\n#{designation.designation}"
|
17
|
+
end
|
18
|
+
end
|
13
19
|
|
14
20
|
mn_adoc.join
|
15
21
|
end
|
@@ -18,26 +24,42 @@ module Stepmod
|
|
18
24
|
def from_h(hash)
|
19
25
|
_, definition, acronym = treat_acronym(hash["definition"])
|
20
26
|
|
21
|
-
|
27
|
+
concept_data = Glossarist::ConceptData.new(
|
28
|
+
{
|
29
|
+
definition: [
|
30
|
+
Glossarist::DetailedDefinition.new({ content: definition }),
|
31
|
+
],
|
32
|
+
terms: [],
|
33
|
+
},
|
34
|
+
)
|
35
|
+
|
36
|
+
add_designations(concept_data, hash["synonyms"]) if hash["synonyms"]
|
22
37
|
|
23
|
-
|
24
|
-
|
38
|
+
if acronym
|
39
|
+
acronym = designation_object(acronym.gsub(/\(|\)/, ""),
|
40
|
+
"abbreviation")
|
41
|
+
acronym.acronym = true
|
42
|
+
concept_data.terms << acronym
|
43
|
+
end
|
25
44
|
|
26
|
-
new(
|
45
|
+
new({ data: concept_data })
|
27
46
|
end
|
28
47
|
|
29
48
|
private
|
30
49
|
|
31
|
-
def add_designations(
|
32
|
-
|
33
|
-
|
50
|
+
def add_designations(concept_data, synonyms)
|
51
|
+
synonyms.each do |synonym|
|
52
|
+
concept_data.terms << designation_object(synonym)
|
53
|
+
end
|
34
54
|
end
|
35
55
|
|
36
|
-
def
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
56
|
+
def designation_object(value, type = "expression")
|
57
|
+
Glossarist::Designation::Base.from_yaml(
|
58
|
+
{
|
59
|
+
"designation" => value,
|
60
|
+
"type" => type,
|
61
|
+
}.to_yaml,
|
62
|
+
)
|
41
63
|
end
|
42
64
|
|
43
65
|
def treat_acronym(term_def)
|
@@ -8,7 +8,7 @@ require "expressir/express/parser"
|
|
8
8
|
require "indefinite_article"
|
9
9
|
require "pubid-iso"
|
10
10
|
|
11
|
-
Coradoc::Input::
|
11
|
+
Coradoc::Input::Html.config.unknown_tags = :bypass
|
12
12
|
|
13
13
|
module Stepmod
|
14
14
|
module Utils
|
@@ -374,16 +374,21 @@ document:)
|
|
374
374
|
|
375
375
|
notes = [old_definition].reject { |note| redundant_note?(note) }
|
376
376
|
|
377
|
-
Stepmod::Utils::Concept.
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
377
|
+
Stepmod::Utils::Concept.from_yaml({
|
378
|
+
data: {
|
379
|
+
terms: [
|
380
|
+
{
|
381
|
+
"type" => "expression",
|
382
|
+
"normative_status" => "preferred",
|
383
|
+
"designation" => entity.id,
|
384
|
+
},
|
385
|
+
],
|
386
|
+
domain: domain,
|
387
|
+
notes: notes.map { |note| { "content" => note } },
|
388
|
+
definition: [{ "content" => definition.strip }],
|
389
|
+
language_code: "eng",
|
390
|
+
id: "#{bibdata.part}-#{@sequence}",
|
391
|
+
},
|
387
392
|
id: "#{bibdata.part}-#{@sequence}",
|
388
393
|
sources: [
|
389
394
|
{
|
@@ -396,12 +401,11 @@ document:)
|
|
396
401
|
# "link" => "https://www.iso.org/standard/32858.html",
|
397
402
|
},
|
398
403
|
],
|
399
|
-
notes: notes,
|
400
404
|
language_code: "eng",
|
401
405
|
part: bibdata.part,
|
402
406
|
schema: schema,
|
403
407
|
document: document,
|
404
|
-
)
|
408
|
+
}.to_yaml)
|
405
409
|
end
|
406
410
|
# rubocop:enable Metrics/MethodLength
|
407
411
|
|
data/stepmod-utils.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
spec.files = `git ls-files`.split("\n")
|
20
20
|
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
21
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 3.
|
21
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
|
22
22
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -31,20 +31,17 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
|
-
spec.
|
35
|
-
spec.
|
36
|
-
spec.
|
37
|
-
spec.
|
38
|
-
spec.
|
39
|
-
spec.
|
40
|
-
spec.
|
41
|
-
spec.
|
42
|
-
spec.
|
43
|
-
spec.
|
44
|
-
spec.
|
45
|
-
spec.
|
46
|
-
spec.
|
47
|
-
spec.add_development_dependency "rubocop"
|
48
|
-
spec.add_development_dependency "rubocop-performance"
|
49
|
-
spec.add_development_dependency "rubocop-rails"
|
34
|
+
spec.add_dependency "concurrent-ruby"
|
35
|
+
spec.add_dependency "coradoc", "~> 1.1.7"
|
36
|
+
spec.add_dependency "down"
|
37
|
+
spec.add_dependency "expressir"
|
38
|
+
spec.add_dependency "glossarist", "~> 2.0"
|
39
|
+
spec.add_dependency "indefinite_article"
|
40
|
+
spec.add_dependency "octokit"
|
41
|
+
spec.add_dependency "plurimath"
|
42
|
+
spec.add_dependency "ptools"
|
43
|
+
spec.add_dependency "pubid-iso"
|
44
|
+
spec.add_dependency "shale"
|
45
|
+
spec.add_dependency "thor", ">= 0.20"
|
46
|
+
spec.add_dependency "unitsml"
|
50
47
|
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.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: coradoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.7
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.7
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: down
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +72,14 @@ dependencies:
|
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.0
|
75
|
+
version: '2.0'
|
62
76
|
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.0
|
82
|
+
version: '2.0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: indefinite_article
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,20 +150,6 @@ dependencies:
|
|
136
150
|
- - ">="
|
137
151
|
- !ruby/object:Gem::Version
|
138
152
|
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: coradoc
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :runtime
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: shale
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,48 +192,6 @@ dependencies:
|
|
192
192
|
- - ">="
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: rubocop
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - ">="
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
202
|
-
type: :development
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - ">="
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
209
|
-
- !ruby/object:Gem::Dependency
|
210
|
-
name: rubocop-performance
|
211
|
-
requirement: !ruby/object:Gem::Requirement
|
212
|
-
requirements:
|
213
|
-
- - ">="
|
214
|
-
- !ruby/object:Gem::Version
|
215
|
-
version: '0'
|
216
|
-
type: :development
|
217
|
-
prerelease: false
|
218
|
-
version_requirements: !ruby/object:Gem::Requirement
|
219
|
-
requirements:
|
220
|
-
- - ">="
|
221
|
-
- !ruby/object:Gem::Version
|
222
|
-
version: '0'
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: rubocop-rails
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - ">="
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: '0'
|
230
|
-
type: :development
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - ">="
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: '0'
|
237
195
|
description: 'Stepmod-utils is a toolkit that works on STEPmod data.
|
238
196
|
|
239
197
|
'
|
@@ -398,14 +356,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
398
356
|
requirements:
|
399
357
|
- - ">="
|
400
358
|
- !ruby/object:Gem::Version
|
401
|
-
version: 3.
|
359
|
+
version: 3.1.0
|
402
360
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
403
361
|
requirements:
|
404
362
|
- - ">="
|
405
363
|
- !ruby/object:Gem::Version
|
406
364
|
version: '0'
|
407
365
|
requirements: []
|
408
|
-
rubygems_version: 3.
|
366
|
+
rubygems_version: 3.5.22
|
409
367
|
signing_key:
|
410
368
|
specification_version: 4
|
411
369
|
summary: Stepmod-utils is a toolkit that works on STEPmod data.
|