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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +1 -11
  3. data/.github/workflows/release.yml +7 -5
  4. data/.hound.yml +5 -0
  5. data/.rubocop.yml +10 -0
  6. data/Gemfile +3 -3
  7. data/Rakefile +1 -1
  8. data/exe/stepmod-annotate-all +17 -11
  9. data/exe/stepmod-build-resource-docs-cache +8 -7
  10. data/exe/stepmod-convert-express-description +6 -4
  11. data/exe/stepmod-convert-express-resource +6 -4
  12. data/exe/stepmod-extract-terms +69 -236
  13. data/exe/stepmod-find-express-files +8 -7
  14. data/lib/stepmod/utils/bibdata.rb +31 -35
  15. data/lib/stepmod/utils/cleaner.rb +3 -3
  16. data/lib/stepmod/utils/concept.rb +86 -30
  17. data/lib/stepmod/utils/converters/a.rb +7 -10
  18. data/lib/stepmod/utils/converters/blockquote.rb +4 -4
  19. data/lib/stepmod/utils/converters/br.rb +1 -1
  20. data/lib/stepmod/utils/converters/bypass.rb +33 -33
  21. data/lib/stepmod/utils/converters/clause_ref.rb +3 -3
  22. data/lib/stepmod/utils/converters/code.rb +1 -1
  23. data/lib/stepmod/utils/converters/comment.rb +5 -3
  24. data/lib/stepmod/utils/converters/dd.rb +2 -2
  25. data/lib/stepmod/utils/converters/def.rb +30 -22
  26. data/lib/stepmod/utils/converters/drop.rb +2 -2
  27. data/lib/stepmod/utils/converters/dt.rb +2 -2
  28. data/lib/stepmod/utils/converters/em.rb +1 -1
  29. data/lib/stepmod/utils/converters/em_express_description.rb +1 -1
  30. data/lib/stepmod/utils/converters/eqn.rb +28 -26
  31. data/lib/stepmod/utils/converters/example.rb +12 -2
  32. data/lib/stepmod/utils/converters/express_g.rb +10 -9
  33. data/lib/stepmod/utils/converters/express_ref.rb +2 -2
  34. data/lib/stepmod/utils/converters/express_ref_express_description.rb +3 -2
  35. data/lib/stepmod/utils/converters/ext_description.rb +4 -2
  36. data/lib/stepmod/utils/converters/figure.rb +20 -0
  37. data/lib/stepmod/utils/converters/fund_cons.rb +1 -1
  38. data/lib/stepmod/utils/converters/head.rb +3 -2
  39. data/lib/stepmod/utils/converters/hr.rb +2 -2
  40. data/lib/stepmod/utils/converters/ignore.rb +3 -3
  41. data/lib/stepmod/utils/converters/introduction.rb +1 -1
  42. data/lib/stepmod/utils/converters/module_ref.rb +11 -7
  43. data/lib/stepmod/utils/converters/note.rb +12 -2
  44. data/lib/stepmod/utils/converters/ol.rb +5 -5
  45. data/lib/stepmod/utils/converters/p.rb +2 -2
  46. data/lib/stepmod/utils/converters/pass_through.rb +2 -2
  47. data/lib/stepmod/utils/converters/q.rb +1 -1
  48. data/lib/stepmod/utils/converters/schema.rb +1 -1
  49. data/lib/stepmod/utils/converters/stem.rb +1 -1
  50. data/lib/stepmod/utils/converters/stepmod_ext_description.rb +30 -7
  51. data/lib/stepmod/utils/converters/strong.rb +5 -4
  52. data/lib/stepmod/utils/converters/sub.rb +2 -2
  53. data/lib/stepmod/utils/converters/sup.rb +2 -2
  54. data/lib/stepmod/utils/converters/synonym.rb +2 -2
  55. data/lib/stepmod/utils/converters/table.rb +7 -9
  56. data/lib/stepmod/utils/converters/term.rb +18 -9
  57. data/lib/stepmod/utils/converters/text.rb +12 -14
  58. data/lib/stepmod/utils/converters/uof.rb +11 -7
  59. data/lib/stepmod/utils/html_to_asciimath.rb +91 -90
  60. data/lib/stepmod/utils/smrl_description_converter.rb +34 -33
  61. data/lib/stepmod/utils/smrl_resource_converter.rb +51 -50
  62. data/lib/stepmod/utils/stepmod_definition_converter.rb +39 -37
  63. data/lib/stepmod/utils/stepmod_file_annotator.rb +26 -19
  64. data/lib/stepmod/utils/terms_extractor.rb +378 -0
  65. data/lib/stepmod/utils/version.rb +1 -1
  66. data/stepmod-utils.gemspec +12 -6
  67. metadata +80 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcb84433f081424b5227cdb8c9c6b7d7342d31089e176f8f333817c4533c721d
4
- data.tar.gz: 82fee2a54cc8d818587c2c9b08e955d1328497f05362307f528b968f1a576f61
3
+ metadata.gz: 6201c720f31faffdd6646d74a3c150733f3219bd756d9ba9743e5a27c1db4495
4
+ data.tar.gz: b1bafce759e91f5923d030fe0b5b0f74f2b719a832d53ac300db6b38e3e221d0
5
5
  SHA512:
6
- metadata.gz: 4840fc050b58a4eda03c0c7106d7af524c7d3f863d5a40907facf6e6393ddf26d60a00852478df1ccadc2568b20616139251bb5fd4f4fcdb37296a8bfc5a94cb
7
- data.tar.gz: f3a7b2d85581e1f5db195bef23b28422a82dd8588b66c66df2147700ccebc6b15c96b3b2b696cfb0435e2a6cdedf02579b542bd1af77efd6c1afd608a61593ca
6
+ metadata.gz: 206becea0d17c930418426618aa5234e420a4aba77e63a9448890245dd637ca044ad5540073e509ca8d672a701bc31b1b9576ad671f21a0da7f620f917c83b68
7
+ data.tar.gz: 4f564a4b188082f6a20e41bb424c50950a2efce588fd1c48adaceb3a1068c7b4d5fa2388c758491f1d8814cceaefaee8f842337ae57d49873cb4e2bcb43933b1
@@ -16,19 +16,9 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '2.7', '2.6', '2.5', '2.4' ]
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: 'patch'
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
- - if: ${{ github.event_name == 'workflow_dispatch' }}
29
- run: |
29
+ - run: |
30
30
  git config user.name github-actions
31
31
  git config user.email github-actions@github.com
32
- gem bump --version ${{ github.event.inputs.next_version }} --tag --push
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
- cat > ~/.gem/credentials << EOF
41
+ envsubst << 'EOF' > ~/.gem/credentials
40
42
  ---
41
43
  :rubygems_api_key: ${RUBYGEMS_API_KEY}
42
44
  EOF
data/.hound.yml ADDED
@@ -0,0 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ ruby:
4
+ enabled: true
5
+ config_file: .rubocop.yml
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
@@ -3,4 +3,4 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,32 +1,38 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'concurrent'
4
- require 'stepmod/utils/stepmod_file_annotator'
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__, 'stepmod-build-resource-docs-cache')}" "#{stepmod_dir}" > "#{resource_docs_cache_file}"`
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__, 'stepmod-find-express-files')}" "#{stepmod_dir}"`.strip.split("\n")
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
- :min_threads => MAX_THREADS,
19
- :max_threads => MAX_THREADS,
20
- :max_queue => MAX_QUEUE_SIZE,
21
- :fallback_policy => :caller_runs
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, resource_docs_cache_file: resource_docs_cache_file, stepmod_dir: stepmod_dir).call
29
- File.open(File.join(File.dirname(file), "#{File.basename(file, '.exp')}_annotated.exp"), 'w') do |file|
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 'nokogiri'
4
- require 'json'
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, 'data/resource_docs/*/resource.xml')).each do |resource_docs_file|
10
- match = resource_docs_file.match('data/resource_docs/([^/]+)/resource.xml')
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('schema').each do |schema|
15
- schemas[schema['name']] = resource_docs_dir
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
- class Gem::Specification
15
- def this; self; end
14
+ module Gem
15
+ class Specification
16
+ def this; self; end
17
+ end
16
18
  end
17
19
 
18
- require 'bundler/setup'
19
- require 'stepmod/utils/smrl_description_converter'
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
- class Gem::Specification
15
- def this; self; end
14
+ module Gem
15
+ class Specification
16
+ def this; self; end
17
+ end
16
18
  end
17
19
 
18
- require 'bundler/setup'
19
- require 'stepmod/utils/smrl_resource_converter'
20
+ require "bundler/setup"
21
+ require "stepmod/utils/smrl_resource_converter"
20
22
 
21
23
  ReverseAdoc.config.unknown_tags = :bypass
22
24
 
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: UTF-8
3
3
 
4
- require 'pry'
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
- class Gem::Specification
16
- def this; self; end
15
+ module Gem
16
+ class Specification
17
+ def this; self; end
18
+ end
17
19
  end
18
20
 
19
- require 'bundler/setup'
20
- require 'stepmod/utils/stepmod_definition_converter'
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
- def log message
39
- puts "[stepmod-utils] #{message}"
40
- end
41
-
42
- def term_special_category(bibdata)
43
- case bibdata.part.to_i
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
- "Part 41"
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
- "Part 45"
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
- stepmod_path = Pathname.new(stepmod_dir).realpath
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
- log "INFO: Detecting paths..."
92
-
93
- files = %w(
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
- unless ACCEPTED_STAGES.include? bibdata.doctype
123
- log "INFO: skipped #{bibdata.docid} as it is not one of (#{ACCEPTED_STAGES.join(", ")})."
124
- next
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
- if bibdata.part.to_s.empty?
128
- log "FATAL: missing `part` attribute: #{fpath}"
129
- log "INFO: skipped #{bibdata.docid} as it is missing `part` attribute."
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
- revision_string = "\n// CVS: revision not detected"
134
- if cvs_mode
135
- # Run `cvs status` to find out version
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
- # read definitions
152
- part_concepts = []
153
- current_document.xpath('//definition').each do |definition|
154
- index = max_encountered_refs_indexes[bibdata.anchor] || 1
155
- term_id = definition['id']
156
- unless term_id.nil?
157
- if encountered_terms[term_id]
158
- log "FATAL: Duplicated term with id: #{term_id}, #{fpath}"
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
- # Assume that definition is located in clause 3 of the ISO document
164
- # in order. We really don't have a good reference here.
165
- ref_clause = "3.#{index}"
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
- parsed_bibliography << bibdata
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
- unless term_special_category(bibdata)
229
- # log "INFO: this part is generic"
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
- parsed_bibliography << bibdata
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('031-stepmod-general.adoc', 'w') { |file|
282
- file.puts(general_concepts.map(&:to_mn_adoc).join("\n"))
283
- }
284
-
285
- File.open('041-stepmod-entities-resources.adoc', 'w') { |file|
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('991-generated-bibliography.adoc', 'w') { |file|
296
- file.puts(parsed_bibliography.map(&:to_mn_adoc).sort.uniq.join("\n"))
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 'nokogiri'
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, 'repository_index.xml'))).root
7
+ index = Nokogiri::XML(File.read(File.join(stepmod_dir,
8
+ "repository_index.xml"))).root
8
9
 
9
10
  files = []
10
- index.xpath('modules/module').each do |item|
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('resources/resource').each do |item|
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('business_object_models/business_object_model').each do |item|
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