stepmod-utils 0.3.2 → 0.3.8
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 +1 -11
- data/.github/workflows/release.yml +7 -5
- data/.hound.yml +5 -0
- data/.rubocop.yml +10 -0
- data/Gemfile +3 -3
- data/Rakefile +1 -1
- data/exe/stepmod-annotate-all +17 -11
- data/exe/stepmod-build-resource-docs-cache +8 -7
- data/exe/stepmod-convert-express-description +6 -4
- data/exe/stepmod-convert-express-resource +6 -4
- data/exe/stepmod-extract-terms +69 -236
- data/exe/stepmod-find-express-files +8 -7
- data/lib/stepmod/utils/bibdata.rb +31 -35
- data/lib/stepmod/utils/cleaner.rb +3 -3
- data/lib/stepmod/utils/concept.rb +86 -30
- data/lib/stepmod/utils/converters/a.rb +7 -10
- data/lib/stepmod/utils/converters/blockquote.rb +4 -4
- data/lib/stepmod/utils/converters/br.rb +1 -1
- data/lib/stepmod/utils/converters/bypass.rb +33 -33
- data/lib/stepmod/utils/converters/clause_ref.rb +3 -3
- data/lib/stepmod/utils/converters/code.rb +1 -1
- data/lib/stepmod/utils/converters/comment.rb +5 -3
- data/lib/stepmod/utils/converters/dd.rb +2 -2
- data/lib/stepmod/utils/converters/def.rb +30 -22
- data/lib/stepmod/utils/converters/drop.rb +2 -2
- data/lib/stepmod/utils/converters/dt.rb +2 -2
- data/lib/stepmod/utils/converters/em.rb +1 -1
- data/lib/stepmod/utils/converters/em_express_description.rb +1 -1
- data/lib/stepmod/utils/converters/eqn.rb +28 -26
- data/lib/stepmod/utils/converters/example.rb +12 -2
- data/lib/stepmod/utils/converters/express_g.rb +10 -9
- data/lib/stepmod/utils/converters/express_ref.rb +2 -2
- data/lib/stepmod/utils/converters/express_ref_express_description.rb +3 -2
- data/lib/stepmod/utils/converters/ext_description.rb +4 -2
- data/lib/stepmod/utils/converters/figure.rb +20 -0
- data/lib/stepmod/utils/converters/fund_cons.rb +1 -1
- data/lib/stepmod/utils/converters/head.rb +3 -2
- data/lib/stepmod/utils/converters/hr.rb +2 -2
- data/lib/stepmod/utils/converters/ignore.rb +3 -3
- data/lib/stepmod/utils/converters/introduction.rb +1 -1
- data/lib/stepmod/utils/converters/module_ref.rb +11 -7
- data/lib/stepmod/utils/converters/note.rb +12 -2
- data/lib/stepmod/utils/converters/ol.rb +5 -5
- data/lib/stepmod/utils/converters/p.rb +2 -2
- data/lib/stepmod/utils/converters/pass_through.rb +2 -2
- data/lib/stepmod/utils/converters/q.rb +1 -1
- data/lib/stepmod/utils/converters/schema.rb +1 -1
- data/lib/stepmod/utils/converters/stem.rb +1 -1
- data/lib/stepmod/utils/converters/stepmod_ext_description.rb +30 -7
- data/lib/stepmod/utils/converters/strong.rb +5 -4
- data/lib/stepmod/utils/converters/sub.rb +2 -2
- data/lib/stepmod/utils/converters/sup.rb +2 -2
- data/lib/stepmod/utils/converters/synonym.rb +2 -2
- data/lib/stepmod/utils/converters/table.rb +7 -9
- data/lib/stepmod/utils/converters/term.rb +18 -9
- data/lib/stepmod/utils/converters/text.rb +12 -14
- data/lib/stepmod/utils/converters/uof.rb +11 -7
- data/lib/stepmod/utils/html_to_asciimath.rb +91 -90
- data/lib/stepmod/utils/smrl_description_converter.rb +34 -33
- data/lib/stepmod/utils/smrl_resource_converter.rb +51 -50
- data/lib/stepmod/utils/stepmod_definition_converter.rb +39 -37
- data/lib/stepmod/utils/stepmod_file_annotator.rb +26 -19
- data/lib/stepmod/utils/terms_extractor.rb +378 -0
- data/lib/stepmod/utils/version.rb +1 -1
- data/stepmod-utils.gemspec +12 -6
- metadata +80 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6201c720f31faffdd6646d74a3c150733f3219bd756d9ba9743e5a27c1db4495
|
4
|
+
data.tar.gz: b1bafce759e91f5923d030fe0b5b0f74f2b719a832d53ac300db6b38e3e221d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 206becea0d17c930418426618aa5234e420a4aba77e63a9448890245dd637ca044ad5540073e509ca8d672a701bc31b1b9576ad671f21a0da7f620f917c83b68
|
7
|
+
data.tar.gz: 4f564a4b188082f6a20e41bb424c50950a2efce588fd1c48adaceb3a1068c7b4d5fa2388c758491f1d8814cceaefaee8f842337ae57d49873cb4e2bcb43933b1
|
data/.github/workflows/rake.yml
CHANGED
@@ -16,19 +16,9 @@ jobs:
|
|
16
16
|
strategy:
|
17
17
|
fail-fast: false
|
18
18
|
matrix:
|
19
|
-
ruby: [ '
|
19
|
+
ruby: [ '3.0', '2.7', '2.6', '2.5' ]
|
20
20
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
21
|
experimental: [ false ]
|
22
|
-
include:
|
23
|
-
- ruby: '3.0'
|
24
|
-
os: 'ubuntu-latest'
|
25
|
-
experimental: true
|
26
|
-
- ruby: '3.0'
|
27
|
-
os: 'windows-latest'
|
28
|
-
experimental: true
|
29
|
-
- ruby: '3.0'
|
30
|
-
os: 'macos-latest'
|
31
|
-
experimental: true
|
32
22
|
steps:
|
33
23
|
- uses: actions/checkout@v2
|
34
24
|
with:
|
@@ -9,7 +9,7 @@ on:
|
|
9
9
|
description: |
|
10
10
|
Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
|
11
11
|
required: true
|
12
|
-
default: '
|
12
|
+
default: 'skip'
|
13
13
|
push:
|
14
14
|
tags: [ v* ]
|
15
15
|
|
@@ -22,21 +22,23 @@ jobs:
|
|
22
22
|
- uses: ruby/setup-ruby@v1
|
23
23
|
with:
|
24
24
|
ruby-version: '2.6'
|
25
|
+
bundler-cache: true
|
25
26
|
|
26
27
|
- run: gem install gem-release
|
27
28
|
|
28
|
-
-
|
29
|
-
run: |
|
29
|
+
- run: |
|
30
30
|
git config user.name github-actions
|
31
31
|
git config user.email github-actions@github.com
|
32
|
-
|
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
|
33
35
|
|
34
36
|
- name: publish to rubygems.org
|
35
37
|
env:
|
36
38
|
RUBYGEMS_API_KEY: ${{secrets.METANORMA_CI_RUBYGEMS_API_KEY}}
|
37
39
|
run: |
|
38
40
|
gem install gem-release
|
39
|
-
|
41
|
+
envsubst << 'EOF' > ~/.gem/credentials
|
40
42
|
---
|
41
43
|
:rubygems_api_key: ${RUBYGEMS_API_KEY}
|
42
44
|
EOF
|
data/.hound.yml
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
inherit_from:
|
4
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
5
|
+
|
6
|
+
# local repo-specific modifications
|
7
|
+
# ...
|
8
|
+
|
9
|
+
AllCops:
|
10
|
+
TargetRubyVersion: 2.5
|
data/Gemfile
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
5
|
gemspec
|
6
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
7
7
|
|
8
|
+
gem "concurrent-ruby", "~> 1.1"
|
9
|
+
gem "pry"
|
8
10
|
gem "rake", "~> 12.0"
|
9
11
|
gem "rspec", "~> 3.0"
|
10
|
-
gem "pry"
|
11
|
-
gem "concurrent-ruby", "~> 1.1"
|
data/Rakefile
CHANGED
data/exe/stepmod-annotate-all
CHANGED
@@ -1,32 +1,38 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "concurrent"
|
4
|
+
require "stepmod/utils/stepmod_file_annotator"
|
5
5
|
|
6
6
|
stepmod_dir = ARGV.first || Dir.pwd
|
7
7
|
|
8
8
|
# build resource_docs cache
|
9
9
|
resource_docs_cache_file = `mktemp`
|
10
|
-
`"#{File.join(__dir__,
|
10
|
+
`"#{File.join(__dir__,
|
11
|
+
"stepmod-build-resource-docs-cache")}" "#{stepmod_dir}" > "#{resource_docs_cache_file}"`
|
11
12
|
|
12
13
|
# annotate each file
|
13
|
-
files = `"#{File.join(__dir__,
|
14
|
+
files = `"#{File.join(__dir__,
|
15
|
+
"stepmod-find-express-files")}" "#{stepmod_dir}"`.strip.split("\n")
|
14
16
|
MAX_THREADS = [2, Concurrent.processor_count].max * 2
|
15
17
|
MAX_QUEUE_SIZE = MAX_THREADS * 4
|
16
18
|
# https://github.com/ruby-concurrency/concurrent-ruby/blob/master/docs-source/thread_pools.md
|
17
19
|
pool = Concurrent::ThreadPoolExecutor.new(
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
20
|
+
min_threads: MAX_THREADS,
|
21
|
+
max_threads: MAX_THREADS,
|
22
|
+
max_queue: MAX_QUEUE_SIZE,
|
23
|
+
fallback_policy: :caller_runs,
|
22
24
|
)
|
23
25
|
files.each_slice(MAX_QUEUE_SIZE) do |batch|
|
24
26
|
puts("Queueing next batch")
|
25
27
|
batch.each do |file|
|
26
28
|
pool.post do
|
27
29
|
puts("#{Thread.current.object_id}: Queued processing #{file}")
|
28
|
-
annotated = Stepmod::Utils::StepmodFileAnnotator.new(express_file: file,
|
29
|
-
|
30
|
+
annotated = Stepmod::Utils::StepmodFileAnnotator.new(express_file: file,
|
31
|
+
resource_docs_cache_file: resource_docs_cache_file, stepmod_dir: stepmod_dir).call
|
32
|
+
File.open(
|
33
|
+
File.join(File.dirname(file),
|
34
|
+
"#{File.basename(file, '.exp')}_annotated.exp"), "w"
|
35
|
+
) do |file|
|
30
36
|
file.puts(annotated)
|
31
37
|
end
|
32
38
|
puts("#{Thread.current.object_id}: Done processing #{file}")
|
@@ -36,4 +42,4 @@ files.each_slice(MAX_QUEUE_SIZE) do |batch|
|
|
36
42
|
end
|
37
43
|
|
38
44
|
# cleanup
|
39
|
-
`rm "#{resource_docs_cache_file}"`
|
45
|
+
`rm "#{resource_docs_cache_file}"`
|
@@ -1,19 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "nokogiri"
|
4
|
+
require "json"
|
5
5
|
|
6
6
|
stepmod_dir = ARGV.first || Dir.pwd
|
7
7
|
|
8
8
|
schemas = {}
|
9
|
-
Dir.glob(File.join(stepmod_dir,
|
10
|
-
|
9
|
+
Dir.glob(File.join(stepmod_dir,
|
10
|
+
"data/resource_docs/*/resource.xml")).each do |resource_docs_file|
|
11
|
+
match = resource_docs_file.match("data/resource_docs/([^/]+)/resource.xml")
|
11
12
|
resource_docs_dir = match.captures[0]
|
12
13
|
|
13
14
|
resource_docs = Nokogiri::XML(File.read(resource_docs_file)).root
|
14
|
-
resource_docs.xpath(
|
15
|
-
schemas[schema[
|
15
|
+
resource_docs.xpath("schema").each do |schema|
|
16
|
+
schemas[schema["name"]] = resource_docs_dir
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
|
-
puts JSON.pretty_generate(schemas)
|
20
|
+
puts JSON.pretty_generate(schemas)
|
@@ -11,12 +11,14 @@ $:.unshift File.expand_path("../../lib", bin_file)
|
|
11
11
|
# Fixes https://github.com/rubygems/rubygems/issues/1420
|
12
12
|
require "rubygems/specification"
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
module Gem
|
15
|
+
class Specification
|
16
|
+
def this; self; end
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
|
-
require
|
19
|
-
require
|
20
|
+
require "bundler/setup"
|
21
|
+
require "stepmod/utils/smrl_description_converter"
|
20
22
|
|
21
23
|
ReverseAdoc.config.unknown_tags = :bypass
|
22
24
|
|
@@ -11,12 +11,14 @@ $:.unshift File.expand_path("../../lib", bin_file)
|
|
11
11
|
# Fixes https://github.com/rubygems/rubygems/issues/1420
|
12
12
|
require "rubygems/specification"
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
module Gem
|
15
|
+
class Specification
|
16
|
+
def this; self; end
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
|
-
require
|
19
|
-
require
|
20
|
+
require "bundler/setup"
|
21
|
+
require "stepmod/utils/smrl_resource_converter"
|
20
22
|
|
21
23
|
ReverseAdoc.config.unknown_tags = :bypass
|
22
24
|
|
data/exe/stepmod-extract-terms
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: UTF-8
|
3
3
|
|
4
|
-
require
|
4
|
+
require "pry"
|
5
5
|
# resolve bin path, ignoring symlinks
|
6
6
|
require "pathname"
|
7
7
|
bin_file = Pathname.new(__FILE__).realpath
|
@@ -12,48 +12,28 @@ $:.unshift File.expand_path("../../lib", bin_file)
|
|
12
12
|
# Fixes https://github.com/rubygems/rubygems/issues/1420
|
13
13
|
require "rubygems/specification"
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
module Gem
|
16
|
+
class Specification
|
17
|
+
def this; self; end
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require 'stepmod/utils/bibdata'
|
22
|
-
require 'stepmod/utils/concept'
|
23
|
-
require 'ptools'
|
24
|
-
|
25
|
-
ReverseAdoc.config.unknown_tags = :bypass
|
26
|
-
|
27
|
-
# TODO: we may want a command line option to override this in the future
|
28
|
-
ACCEPTED_STAGES = %w(IS DIS FDIS TS)
|
29
|
-
|
30
|
-
general_concepts = []
|
31
|
-
resource_concepts = []
|
32
|
-
module_concepts = []
|
33
|
-
parsed_bibliography = []
|
34
|
-
encountered_terms = {}
|
21
|
+
require "bundler/setup"
|
22
|
+
require "stepmod/utils/terms_extractor"
|
35
23
|
|
36
24
|
stepmod_dir = ARGV.first || Dir.pwd
|
37
25
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
when 41,42,43,44,45,46,47,51
|
45
|
-
true
|
46
|
-
when [56..112]
|
47
|
-
true
|
48
|
-
else
|
49
|
-
false
|
50
|
-
end
|
51
|
-
end
|
26
|
+
general_concepts,
|
27
|
+
resource_concepts,
|
28
|
+
parsed_bibliography,
|
29
|
+
part_concepts,
|
30
|
+
part_resources,
|
31
|
+
part_modules = Stepmod::Utils::TermsExtractor.call(stepmod_dir)
|
52
32
|
|
53
33
|
def part_to_title(bibdata)
|
54
34
|
case bibdata.part.to_i
|
55
35
|
when 41
|
56
|
-
"
|
36
|
+
"Fundamentals of product description and support"
|
57
37
|
when 42
|
58
38
|
"Geometric and topological representation"
|
59
39
|
when 43
|
@@ -61,7 +41,7 @@ def part_to_title(bibdata)
|
|
61
41
|
when 44
|
62
42
|
"Product structure, concept and configuration"
|
63
43
|
when 45
|
64
|
-
"
|
44
|
+
"Material and other engineering properties"
|
65
45
|
when 46
|
66
46
|
"Visual presentation"
|
67
47
|
when 47
|
@@ -73,227 +53,80 @@ def part_to_title(bibdata)
|
|
73
53
|
end
|
74
54
|
end
|
75
55
|
|
76
|
-
|
77
|
-
|
78
|
-
# If we are using the stepmod CVS repository, provide the revision number per file
|
79
|
-
has_cvs = File.which("cvs")
|
80
|
-
cvs_mode = has_cvs && Dir.exists?(stepmod_path.join('CVS'))
|
81
|
-
|
82
|
-
log "INFO: STEPmod directory set to #{stepmod_dir}."
|
83
|
-
|
84
|
-
if cvs_mode
|
85
|
-
log "INFO: STEPmod directory is a CVS repository and will detect revisions."
|
86
|
-
log "INFO: [CVS] Detecting file revisions can be slow, please be patient!"
|
87
|
-
else
|
88
|
-
log "INFO: STEPmod directory is not a CVS repository, skipping revision detection."
|
56
|
+
def log(message)
|
57
|
+
puts "[stepmod-utils] #{message}"
|
89
58
|
end
|
90
59
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
resource.xml
|
95
|
-
application_protocol.xml
|
96
|
-
business_object_model.xml
|
97
|
-
module.xml
|
98
|
-
).inject([]) do |acc, t|
|
99
|
-
|
100
|
-
candidate_paths = Dir["#{stepmod_dir}/**/#{t}"]
|
101
|
-
acc << candidate_paths
|
102
|
-
|
103
|
-
end.flatten.sort.uniq
|
104
|
-
|
105
|
-
max_encountered_refs_indexes = {}
|
106
|
-
|
107
|
-
files.each do |file_path|
|
108
|
-
file_path = Pathname.new(file_path).realpath
|
109
|
-
fpath = file_path.relative_path_from(stepmod_path)
|
110
|
-
|
111
|
-
log "INFO: Processing XML file #{fpath}"
|
112
|
-
current_document = Nokogiri::XML(File.read(file_path)).root
|
113
|
-
|
114
|
-
bibdata = nil
|
115
|
-
begin
|
116
|
-
bibdata = Stepmod::Utils::Bibdata.new(document: current_document)
|
117
|
-
rescue
|
118
|
-
log "WARNING: Unknown file #{fpath}, skipped"
|
119
|
-
next
|
60
|
+
part_concepts.each do |(bibdata, current_part_concepts)|
|
61
|
+
current_part_concepts = current_part_concepts.to_a.map do |n|
|
62
|
+
n.localizations["en"]
|
120
63
|
end
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
64
|
+
fn = "03x-stepmod-#{bibdata.part}.adoc"
|
65
|
+
File.open(fn, "w") do |file|
|
66
|
+
file.puts("== #{part_to_title(bibdata)}\n\n")
|
67
|
+
file.puts(current_part_concepts.map(&:to_mn_adoc).join("\n"))
|
125
68
|
end
|
69
|
+
log "INFO: written to: #{fn}"
|
70
|
+
end
|
126
71
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
next
|
72
|
+
part_resources.each do |(bibdata, current_part_resources)|
|
73
|
+
current_part_resources = current_part_resources.to_a.map do |n|
|
74
|
+
n.localizations["en"]
|
131
75
|
end
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
log "INFO: Detecting CVS revision..."
|
138
|
-
Dir.chdir(stepmod_path) do
|
139
|
-
status = `cvs status #{fpath}`
|
140
|
-
|
141
|
-
unless status.empty?
|
142
|
-
working_rev = status.split(/\n/).grep(/Working revision:/).first.match(/revision:\s+(.+)$/)[1]
|
143
|
-
repo_rev = status.split(/\n/).grep(/Repository revision:/).first.match(/revision:\t(.+)\t/)[1]
|
144
|
-
log "INFO: CVS working rev (#{working_rev}), repo rev (#{repo_rev})"
|
145
|
-
revision_string = "\n// CVS working rev: (#{working_rev}), repo rev (#{repo_rev})\n" +
|
146
|
-
"// CVS: revision #{working_rev == repo_rev ? 'up to date' : 'differs'}"
|
147
|
-
end
|
148
|
-
end
|
76
|
+
fn = "04x-stepmod-entities-resources-#{bibdata.part}.adoc"
|
77
|
+
File.open(fn, "w") do |file|
|
78
|
+
file.puts("== #{part_to_title(bibdata)}\n\n")
|
79
|
+
file.puts(current_part_resources.map(&:to_mn_adoc).join("\n"))
|
149
80
|
end
|
81
|
+
log "INFO: written to: #{fn}"
|
82
|
+
end
|
150
83
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
84
|
+
part_modules.each do |(bibdata, part_modules_arm, part_modules_mim)|
|
85
|
+
fn = "05x-stepmod-entities-modules-#{bibdata.part}.adoc"
|
86
|
+
File.open(fn, "w") do |file|
|
87
|
+
file.puts("")
|
88
|
+
unless part_modules_arm.empty?
|
89
|
+
schema_name = part_modules_arm.first.first
|
90
|
+
concepts = part_modules_arm.first.last.to_a.map do |n|
|
91
|
+
n.localizations["en"]
|
159
92
|
end
|
160
|
-
encountered_terms[term_id] = true
|
161
|
-
end
|
162
93
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
concept = Stepmod::Utils::Concept.parse(
|
168
|
-
definition,
|
169
|
-
reference_anchor: bibdata.anchor,
|
170
|
-
reference_clause: ref_clause,
|
171
|
-
file_path: fpath + revision_string
|
172
|
-
)
|
173
|
-
next unless concept
|
174
|
-
|
175
|
-
unless term_special_category(bibdata)
|
176
|
-
# log "INFO: this part is generic"
|
177
|
-
general_concepts << concept
|
178
|
-
else
|
179
|
-
# log "INFO: this part is special"
|
180
|
-
part_concepts << concept
|
181
|
-
end
|
182
|
-
|
183
|
-
max_encountered_refs_indexes[bibdata.anchor] = index + 1
|
184
|
-
parsed_bibliography << bibdata
|
185
|
-
end
|
186
|
-
|
187
|
-
part_modules = []
|
188
|
-
current_document.xpath('//arm/uof').each do |uof_node|
|
189
|
-
concept = Stepmod::Utils::Concept.parse(
|
190
|
-
uof_node,
|
191
|
-
reference_anchor: bibdata.anchor,
|
192
|
-
reference_clause: nil,
|
193
|
-
file_path: fpath + revision_string
|
194
|
-
)
|
195
|
-
# puts concept.inspect
|
196
|
-
|
197
|
-
next unless concept
|
198
|
-
|
199
|
-
unless term_special_category(bibdata)
|
200
|
-
# log "INFO: this part is generic"
|
201
|
-
module_concepts << concept
|
202
|
-
else
|
203
|
-
# log "INFO: this part is special"
|
204
|
-
part_modules << concept
|
94
|
+
# puts "SCHEMA NAME ARM: #{schema_name}"
|
95
|
+
file.puts("== #{schema_name}\n\n")
|
96
|
+
file.puts(concepts.map(&:to_mn_adoc).join("\n"))
|
205
97
|
end
|
206
98
|
|
207
|
-
|
208
|
-
end
|
209
|
-
|
210
|
-
part_resources = []
|
211
|
-
# Assumption: every schema is only linked by a single resource_docs document.
|
212
|
-
current_document.xpath('//schema').each do |schema_node|
|
213
|
-
schema_name = schema_node['name']
|
214
|
-
|
215
|
-
Dir["#{stepmod_path}/*/#{schema_name}/descriptions.xml"].each do |description_xml_path|
|
216
|
-
log "INFO: Processing resources schema #{description_xml_path}"
|
217
|
-
description_document = Nokogiri::XML(File.read(description_xml_path)).root
|
218
|
-
description_document.xpath('//ext_description').each do |ext_description|
|
219
|
-
|
220
|
-
concept = Stepmod::Utils::Concept.parse(
|
221
|
-
ext_description,
|
222
|
-
reference_anchor: bibdata.anchor,
|
223
|
-
reference_clause: nil,
|
224
|
-
file_path: fpath + revision_string
|
225
|
-
)
|
226
|
-
next unless concept
|
99
|
+
file.puts("")
|
227
100
|
|
228
|
-
|
229
|
-
|
230
|
-
resource_concepts << concept
|
231
|
-
else
|
232
|
-
# log "INFO: this part is special"
|
233
|
-
part_resources << concept
|
234
|
-
end
|
101
|
+
unless part_modules_mim.empty?
|
102
|
+
schema_name = part_modules_mim.first.first
|
235
103
|
|
236
|
-
|
104
|
+
# puts "SCHEMA NAME MIM: #{schema_name}"
|
105
|
+
concepts = part_modules_mim.first.last.to_a.map do |n|
|
106
|
+
n.localizations["en"]
|
237
107
|
end
|
108
|
+
file.puts("== #{schema_name}\n\n")
|
109
|
+
file.puts(concepts.map(&:to_mn_adoc).join("\n"))
|
238
110
|
end
|
239
111
|
end
|
240
|
-
|
241
|
-
log "INFO: Completed processing XML file #{fpath}"
|
242
|
-
|
243
|
-
if part_concepts.empty?
|
244
|
-
log "INFO: Skipping #{fpath} (#{bibdata.docid}) because it contains no concepts."
|
245
|
-
next
|
246
|
-
elsif part_concepts.length < 3
|
247
|
-
log "INFO: Skipping #{fpath} (#{bibdata.docid}) because it only has #{part_concepts.length} terms."
|
248
|
-
|
249
|
-
part_concepts.each do |x|
|
250
|
-
general_concepts << x
|
251
|
-
end
|
252
|
-
else
|
253
|
-
fn = "03x-stepmod-#{bibdata.part}.adoc"
|
254
|
-
File.open(fn, 'w') { |file|
|
255
|
-
file.puts("== #{part_to_title(bibdata)}\n\n")
|
256
|
-
file.puts(part_concepts.map(&:to_mn_adoc).join("\n"))
|
257
|
-
}
|
258
|
-
log "INFO: written to: #{fn}"
|
259
|
-
end
|
260
|
-
|
261
|
-
unless part_resources.empty?
|
262
|
-
fn = "04x-stepmod-entities-resources-#{bibdata.part}.adoc"
|
263
|
-
File.open(fn, 'w') { |file|
|
264
|
-
file.puts("== #{part_to_title(bibdata)}\n\n")
|
265
|
-
file.puts(part_resources.map(&:to_mn_adoc).join("\n"))
|
266
|
-
}
|
267
|
-
log "INFO: written to: #{fn}"
|
268
|
-
end
|
269
|
-
|
270
|
-
unless part_modules.empty?
|
271
|
-
fn = "04x-stepmod-entities-modules-#{bibdata.part}.adoc"
|
272
|
-
File.open(fn, 'w') { |file|
|
273
|
-
file.puts("== #{part_to_title(bibdata)}\n\n")
|
274
|
-
file.puts(part_modules.map(&:to_mn_adoc).join("\n"))
|
275
|
-
}
|
276
|
-
log "INFO: written to: #{fn}"
|
277
|
-
end
|
278
|
-
|
112
|
+
log "INFO: written to: #{fn}"
|
279
113
|
end
|
280
114
|
|
281
|
-
File.open(
|
282
|
-
file.puts(general_concepts.map
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
file.puts(resource_concepts.map(&:to_mn_adoc).join("\n"))
|
287
|
-
}
|
288
|
-
|
289
|
-
File.open('051-stepmod-entities-modules.adoc', 'w') { |file|
|
290
|
-
file.puts(module_concepts.map(&:to_mn_adoc).join("\n"))
|
291
|
-
}
|
292
|
-
|
115
|
+
File.open("031-stepmod-general.adoc", "w") do |file|
|
116
|
+
file.puts(general_concepts.to_a.map do |n|
|
117
|
+
n.localizations["en"]
|
118
|
+
end.map(&:to_mn_adoc).join("\n"))
|
119
|
+
end
|
293
120
|
log "INFO: written to: 031-stepmod-general.adoc"
|
294
121
|
|
295
|
-
File.open(
|
296
|
-
file.puts(
|
297
|
-
|
122
|
+
File.open("041-stepmod-entities-resources.adoc", "w") do |file|
|
123
|
+
file.puts(resource_concepts.to_a.map do |n|
|
124
|
+
n.localizations["en"]
|
125
|
+
end.map(&:to_mn_adoc).join("\n"))
|
126
|
+
end
|
127
|
+
log "INFO: written to: 041-stepmod-entities-resources.adoc"
|
298
128
|
|
129
|
+
File.open("991-generated-bibliography.adoc", "w") do |file|
|
130
|
+
file.puts(parsed_bibliography.map(&:to_mn_adoc).sort.uniq.join("\n"))
|
131
|
+
end
|
299
132
|
log "INFO: written to: 991-generated-bibliography.adoc"
|
@@ -1,23 +1,24 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require "nokogiri"
|
4
4
|
|
5
5
|
stepmod_dir = ARGV.first || Dir.pwd
|
6
6
|
|
7
|
-
index = Nokogiri::XML(File.read(File.join(stepmod_dir,
|
7
|
+
index = Nokogiri::XML(File.read(File.join(stepmod_dir,
|
8
|
+
"repository_index.xml"))).root
|
8
9
|
|
9
10
|
files = []
|
10
|
-
index.xpath(
|
11
|
+
index.xpath("modules/module").each do |item|
|
11
12
|
files << "#{stepmod_dir}/data/modules/#{item['name']}/arm.exp"
|
12
13
|
files << "#{stepmod_dir}/data/modules/#{item['name']}/mim.exp"
|
13
14
|
end
|
14
|
-
index.xpath(
|
15
|
+
index.xpath("resources/resource").each do |item|
|
15
16
|
files << "#{stepmod_dir}/data/resources/#{item['name']}/#{item['name']}.exp"
|
16
17
|
end
|
17
|
-
index.xpath(
|
18
|
+
index.xpath("business_object_models/business_object_model").each do |item|
|
18
19
|
files << "#{stepmod_dir}/data/business_object_models/#{item['name']}/bom.exp"
|
19
20
|
files << "#{stepmod_dir}/data/business_object_models/#{item['name']}/DomainModel.exp"
|
20
21
|
end
|
21
22
|
|
22
|
-
existing_files = files.filter{|file| File.exists?(file)}
|
23
|
-
puts existing_files
|
23
|
+
existing_files = files.filter { |file| File.exists?(file) }
|
24
|
+
puts existing_files
|