stepmod-utils 0.3.25 → 0.3.27

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: 46ea2364546e11b067f0d3d21e78d0a1df701ec5189aeb94d08461d551b22786
4
- data.tar.gz: ab5adf48414ca093c86ff2fbe12155ff7eab79102412f1c1f9949ee5e7eac591
3
+ metadata.gz: b4bb366577c4b43d545ccbdf77ea88e46ece9f0bbefe5ca493769131e18ccaed
4
+ data.tar.gz: 9811424a834ad40699bfd1c2ed900762469407d764adbe714a5ccf47bc792ed7
5
5
  SHA512:
6
- metadata.gz: 16eb837cff97033e742a20f2513ca426f69d41bb49cce9956c450f41c90290bd3404083c378a40b0ac6c35a68c974c57db1b11e5919cc6a1d5da9b65845b310b
7
- data.tar.gz: c3df83672ebda912b592c487698b61e1e19e91cc31da78959dae7d3f4d3836b6a1940d78e33eec34dca92815fe7385e0289f3170303f989187132e1ef21ebc82
6
+ metadata.gz: 38fe3f3a2292c0f4e891bcb29997165ff5550aa2c4e95d5997afda0a77b01bd037642b8f412cd84fa4b01ffd90c70a12dea7a29acb532376984259ed7522a39d
7
+ data.tar.gz: 2644087f0c877378d0d1e2fc417e74157906a0c00121f0504a0df3475d0d40de5b94a9ed542385ab3977b573e134747cb6f5bd2478d7ae41bb5a43fd9ce8622a
@@ -16,6 +16,8 @@ def all_express_files(stepmod_dir)
16
16
  end
17
17
 
18
18
  index.xpath("resources/resource").each do |item|
19
+ next if item["name"] == "iso13584_expressions_schema"
20
+
19
21
  files << "#{stepmod_dir}/data/resources/#{item['name']}/#{item['name']}.exp"
20
22
  end
21
23
 
@@ -142,7 +142,7 @@ end
142
142
  part_resources.each do |(_bibdata, current_part_resources)|
143
143
  current_part_resources.save_to_files(output_dir)
144
144
  end
145
- log "INFO: part_resources written to yaml files"
145
+ log "INFO: part_resources written to YAML files in #{output_dir}"
146
146
 
147
147
  part_modules.sort_by do |(bibdata, _part_modules_arm, _part_modules_mim)|
148
148
  bibdata.part.to_i
@@ -159,7 +159,7 @@ end.each do |(_bibdata, part_modules_arm, part_modules_mim)|
159
159
  end
160
160
  end
161
161
  end
162
- log "INFO: part_modules written to yaml files"
162
+ log "INFO: part_modules written to YAML files in #{output_dir}"
163
163
 
164
164
  resource_concepts.save_to_files(output_dir)
165
- log "INFO: resource_concepts written to yaml files"
165
+ log "INFO: resource_concepts written to YAML files in #{output_dir}"
@@ -17,7 +17,7 @@ module Stepmod
17
17
  # TODO: converted_definition is not supposed to be an attribute, it is
18
18
  # supposed to be a method!
19
19
  class << self
20
- def parse(definition_xml, reference_anchor:, reference_clause:, file_path:, language_code: "en")
20
+ def parse(definition_xml, reference_anchor:, reference_clause:, file_path:, language_code: "eng")
21
21
  converted_definition = Stepmod::Utils::StepmodDefinitionConverter.convert(
22
22
  definition_xml,
23
23
  {
@@ -21,13 +21,13 @@ module Stepmod
21
21
  if !published_info.nil?
22
22
  @pubid = Pubid::Iso::Identifier.parse(published_info)
23
23
 
24
- @part = pubid.part
25
- @version = pubid.edition
26
- @pub_year = pubid.year
24
+ @part = pubid.part&.to_s
25
+ @version = pubid.edition&.to_s
26
+ @pub_year = pubid.year&.to_s
27
27
  elsif !schema.version.nil?
28
- @part = schema.version.items.find { |i| i.name == "part" }.value
29
- @version = schema.version.items.find { |i| i.name == "part" }.value
30
- @pub_year = schema.version.items.find { |i| i.name == "part" }.value
28
+ @part = schema.version.items.find { |i| i.name == "part" }.value&.to_s
29
+ @version = schema.version.items.find { |i| i.name == "part" }.value&.to_s
30
+ @pub_year = schema.version.items.find { |i| i.name == "part" }.value&.to_s
31
31
  else
32
32
  raise "PublishedInfoNotFound"
33
33
  end
@@ -268,7 +268,7 @@ module Stepmod
268
268
  year = "" if year == "tbd"
269
269
  edition = bib.attributes["version"].value
270
270
 
271
- pubid = Pubid::Iso::Identifier.new(
271
+ pubid = Pubid::Iso::Identifier.create(
272
272
  publisher: "ISO",
273
273
  number: 10303,
274
274
  )
@@ -66,29 +66,53 @@ module Stepmod
66
66
  end
67
67
  end
68
68
 
69
+ def published_part_numbers
70
+ docs_xml = Nokogiri::XML(File.read(@stepmod_path.join('library/docs.xml')))
71
+ docs_xml.xpath("//doc").map do |x|
72
+ x['part']
73
+ end.uniq.sort
74
+ end
75
+
69
76
  def call
70
77
  log "INFO: STEPmod directory set to #{stepmod_dir}."
71
78
  log "INFO: Detecting paths..."
72
79
 
73
- # Run `cvs status` to find out version
74
80
  log "INFO: Detecting Git SHA..."
75
81
  Dir.chdir(stepmod_path) do
76
82
  @git_rev = `git rev-parse HEAD` || nil
77
83
  end
78
84
 
85
+ published_part_nos = published_part_numbers
79
86
  repo_index = Nokogiri::XML(File.read(@index_path)).root
80
87
 
81
88
  files = []
82
89
 
83
90
  # add module paths
84
91
  repo_index.xpath("//module").each do |x|
85
- next if x['status'] == WITHDRAWN_STATUS
92
+ unless published_part_nos.include? x['part']
93
+ log "INFO: skipping module #{x['name']} as part #{x['part']} is not published in `docs.xml`."
94
+ next
95
+ end
86
96
 
87
- arm_path = Pathname.new("#{stepmod_dir}/modules/#{x['name']}/arm_annotated.exp")
88
- mim_path = Pathname.new("#{stepmod_dir}/modules/#{x['name']}/mim_annotated.exp")
97
+ if x['status'] == WITHDRAWN_STATUS
98
+ log "INFO: skipping module #{x['name']} as it is withdrawn."
99
+ next
100
+ end
89
101
 
90
- files << arm_path if File.exist? arm_path
91
- files << mim_path if File.exist? mim_path
102
+ arm_path = @stepmod_path.join("modules/#{x['name']}/arm_annotated.exp")
103
+ mim_path = @stepmod_path.join("modules/#{x['name']}/mim_annotated.exp")
104
+
105
+ if File.exist? arm_path
106
+ files << arm_path
107
+ else
108
+ log "INFO: skipping module ARM for #{x['name']} as it does not exist at #{arm_path}."
109
+ end
110
+
111
+ if File.exist? mim_path
112
+ files << mim_path
113
+ else
114
+ log "INFO: skipping module MIM for #{x['name']} as it does not exist at #{mim_path}."
115
+ end
92
116
  end
93
117
 
94
118
  # Should ignore these because the `<resource_docs>` elements do not provide any EXPRESS schemas
@@ -102,10 +126,27 @@ module Stepmod
102
126
 
103
127
  # add resource paths
104
128
  repo_index.xpath("//resource").each do |x|
105
- next if x['status'] == WITHDRAWN_STATUS
129
+ unless published_part_nos.include? x['part']
130
+ log "INFO: skipping resource #{x['name']} as part #{x['part']} is not published in `docs.xml`."
131
+ next
132
+ end
133
+
134
+ if x['status'] == WITHDRAWN_STATUS
135
+ log "INFO: skipping resource #{x['name']} as it is withdrawn."
136
+ next
137
+ end
106
138
 
107
- path = Pathname.new("#{stepmod_dir}/resources/#{x['name']}/#{x['name']}_annotated.exp")
108
- files << path if File.exist? path
139
+ if x["name"] == "iso13584_expressions_schema"
140
+ log "INFO: skipping resource #{x['name']} as the ISO 13584 series is out of scope."
141
+ next
142
+ end
143
+
144
+ path = @stepmod_path.join("resources/#{x['name']}/#{x['name']}_annotated.exp")
145
+ if File.exist? path
146
+ files << path
147
+ else
148
+ log "INFO: skipping resource #{x['name']} as it does not exist at #{path}."
149
+ end
109
150
  end
110
151
 
111
152
  # Should ignore these because we are skiping Clause 3 terms
@@ -340,7 +381,7 @@ module Stepmod
340
381
  },
341
382
  ],
342
383
  notes: notes,
343
- language_code: "en",
384
+ language_code: "eng",
344
385
  part: bibdata.part,
345
386
  schema: schema,
346
387
  document: document,
@@ -1,5 +1,5 @@
1
1
  module Stepmod
2
2
  module Utils
3
- VERSION = "0.3.25".freeze
3
+ VERSION = "0.3.27".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.25
4
+ version: 0.3.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-14 00:00:00.000000000 Z
11
+ date: 2023-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby