stepmod-utils 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d9d95bf89fc69ea44d7924a14274ab5c82361da39fb40e795c14fea8cc87eaf
4
- data.tar.gz: 6e2240c2d977787e40183bb988b4ba8db188be9e5c71da1815cc6748e503517b
3
+ metadata.gz: 46b71314210eb0f813efd1fe7862b3e5bc061133e2cfe7f32df95a77e5f4e290
4
+ data.tar.gz: c6fffa6edd1e0565127f2da4872c624bd2c501be27afabd456b50379a5904a05
5
5
  SHA512:
6
- metadata.gz: ca1a8cdacd5c6798944103d428bf98b2ca7caa8e964bcfd339d1f54c5342e87d20bffe72c7e3995ffb69a1e5b10b1144f29e7ee2b8f63822e982b5058c649a03
7
- data.tar.gz: de99be754e8690fa61623767a83da8704cae6e94bd089bd2acf22c89fab61b10b54d41d3d5acc790f62b7424c7398740d06c92a2e6cfc5b2ba787156e09461fc
6
+ metadata.gz: 7fb0a8b89aed9d4db7c1aaa2e0d7f8881b0b5c0869019f287d6d50f472795356830d7b4f3751c163adc59db3ac5ec567516f92ebfa029fa29f85eb05b42671c4
7
+ data.tar.gz: f2b1717966c60aa636bd79e90df18c28b1a1829c7277ece5adb19180a63c01842756497b6004ff38b48350bc5b7c704117c7ecd7e12b4ad07e9755add899fdb5
@@ -25,7 +25,11 @@ Or include it in your gemspec.
25
25
 
26
26
  [source,sh]
27
27
  ----
28
- stepmod-extract-terms {stepmod-data-directory}
28
+ # Extracts from current directory
29
+ $ stepmod-extract-terms
30
+
31
+ # Extracts from specified stepmod/ or stepmod/data/ directory
32
+ $ stepmod-extract-terms {stepmod-data-directory}
29
33
  ----
30
34
 
31
35
  Then these files will be created:
@@ -28,31 +28,37 @@ parsed_terms = []
28
28
  parsed_bibliography = []
29
29
  encountered_terms = {}
30
30
 
31
- paths = ARGV.map do |path|
32
- path = "../iso-10303-stepmod/data"
33
- puts "Searching for #{path}/{resource,module,application_protocol,business_object_model}.xml..."
34
- Dir[
35
- "#{path}/**/resource.xml",
36
- "#{path}/**/application_protocol.xml",
37
- "#{path}/**/business_object_model.xml",
38
- "#{path}/**/module.xml"
39
- ]
31
+ stepmod_dir = ARGV.first || Dir.pwd
32
+
33
+ def log message
34
+ puts "[stepmod-utils] #{message}"
35
+ end
36
+
37
+ log "STEPmod directory set to #{stepmod_dir}. Detecting paths..."
38
+
39
+ files = %w(
40
+ resource.xml
41
+ application_protocol.xml
42
+ business_object_model.xml
43
+ module.xml
44
+ ).inject([]) do |acc, t|
45
+ acc << Dir["#{stepmod_dir}/**/#{t}"]
40
46
  end.flatten.sort.uniq
41
47
 
42
- paths.each do |file_path|
43
- puts("Processing XML file #{file_path}")
48
+ files.each do |file_path|
49
+ log "Processing XML file #{file_path}"
44
50
  current_document = Nokogiri::XML(File.read(file_path)).root
45
51
 
46
52
  bibdata = nil
47
53
  begin
48
54
  bibdata = Stepmod::Utils::Bibdata.new(document: current_document)
49
55
  rescue
50
- puts "WARNING: Unknown file #{file_path}, skipped"
56
+ log "WARNING: Unknown file #{file_path}, skipped"
51
57
  next
52
58
  end
53
59
 
54
60
  if bibdata.part.to_s.empty?
55
- puts "FATAL: missing `part` attribute: #{file_path}"
61
+ log "FATAL: missing `part` attribute: #{file_path}"
56
62
  end
57
63
 
58
64
  # read definitions
@@ -61,7 +67,7 @@ paths.each do |file_path|
61
67
  term_id = definition['id']
62
68
  unless term_id.nil?
63
69
  if encountered_terms[term_id]
64
- puts "FATAL: Duplicated term with id: #{term_id}, #{file_path}"
70
+ log "FATAL: Duplicated term with id: #{term_id}, #{file_path}"
65
71
  end
66
72
  encountered_terms[term_id] = true
67
73
  end
@@ -86,6 +92,10 @@ File.open('031-generated-terms.adoc', 'w') { |file|
86
92
  file.puts(parsed_terms.map(&:to_mn_adoc).join("\n"))
87
93
  }
88
94
 
95
+ log "written to: 031-generated-terms.adoc"
96
+
89
97
  File.open('991-generated-bibliography.adoc', 'w') { |file|
90
98
  file.puts(parsed_bibliography.map(&:to_mn_adoc).join("\n"))
91
99
  }
100
+
101
+ log "written to: 991-generated-bibliography.adoc"
@@ -29,7 +29,7 @@ module Stepmod
29
29
  @pub_year = document['publication.year'].split('-').first
30
30
  @pub_date = document['publication.date']
31
31
 
32
- puts to_mn_adoc
32
+ # puts to_mn_adoc
33
33
 
34
34
  return self
35
35
  # <module
@@ -1,5 +1,5 @@
1
1
  module Stepmod
2
2
  module Utils
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
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.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-03 00:00:00.000000000 Z
11
+ date: 2020-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor