stepmod-utils 0.1.8 → 0.2.0
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/Gemfile +1 -0
- data/README.adoc +54 -1
- data/exe/stepmod-extract-terms +56 -14
- data/lib/stepmod/utils/version.rb +1 -1
- data/stepmod-utils.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83672fac3acf9ef0d9a2ab17fffab1204b326c7d41018675c2cc819976ac8b40
|
4
|
+
data.tar.gz: 2a59c155d059ca7b73e48ebf5ddedac314e998dbb92eb301a55c460d8ac44e79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca130bac46780aeef8434443d68e02a83cfc2d17a5dd1634c13c6448fd33c1861e85cc3173303db64449e7da3465b1953ed344690894e09cd5698304c4b129eb
|
7
|
+
data.tar.gz: f4d94ac262f4c98ca810a1002c0bdc22d67cc3bd771521f4700e512386f226156d442de3c3f826c0aa7757bbc7d41a78dd42c22b166eca6a032b9b1177511424
|
data/Gemfile
CHANGED
data/README.adoc
CHANGED
@@ -10,7 +10,7 @@ image:https://img.shields.io/github/commits-since/metanorma/stepmod-utils/latest
|
|
10
10
|
|
11
11
|
== Purpose
|
12
12
|
|
13
|
-
The stepmod-utils Ruby gem provides a number of tools to work with the STEPmod repository
|
13
|
+
The `stepmod-utils` Ruby gem provides a number of tools to work with the STEPmod repository.
|
14
14
|
|
15
15
|
== Installation
|
16
16
|
|
@@ -38,3 +38,56 @@ Then these files will be created:
|
|
38
38
|
* `991-generated-bibliography.adoc` all bibliographic sources where the terms come from
|
39
39
|
|
40
40
|
|
41
|
+
== CVS revision detection
|
42
|
+
|
43
|
+
If the STEPmod repository is a CVS repository, it will display the
|
44
|
+
working and repository revisions as comments.
|
45
|
+
|
46
|
+
WARNING: CVS revision detection can be *slow*! Be patient.
|
47
|
+
|
48
|
+
Sample output:
|
49
|
+
|
50
|
+
[source,sh]
|
51
|
+
----
|
52
|
+
[stepmod-utils] INFO: STEPmod directory set to ../x/stepmod/.
|
53
|
+
[stepmod-utils] INFO: STEPmod directory is a CVS repository and will detect revisions.
|
54
|
+
[stepmod-utils] INFO: [CVS] Detecting file revisions can be slow, please be patient!
|
55
|
+
[stepmod-utils] INFO: Detecting paths...
|
56
|
+
[stepmod-utils] INFO: Processing XML file data/business_object_models/managed_model_based_3d_engineering/business_object_model.xml
|
57
|
+
[stepmod-utils] INFO: Detecting CVS revision...
|
58
|
+
[stepmod-utils] INFO: CVS working rev (1.148), repo rev (1.148)
|
59
|
+
[stepmod-utils] INFO: Completed processing XML file data/business_object_models/managed_model_based_3d_engineering/business_object_model.xml
|
60
|
+
[stepmod-utils] INFO: Processing XML file data/business_object_models/managed_model_based_3d_engineering_domain/business_object_model.xml
|
61
|
+
[stepmod-utils] INFO: Detecting CVS revision...
|
62
|
+
[stepmod-utils] INFO: CVS working rev (1.31), repo rev (1.31)
|
63
|
+
[stepmod-utils] INFO: Completed processing XML file data/business_object_models/managed_model_based_3d_engineering_domain/business_object_model.xml
|
64
|
+
...
|
65
|
+
stepmod/data/business_object_models/managed_model_based_3d_engineering_domain/business_object_model.xml
|
66
|
+
[stepmod-utils] INFO: written to: 031-generated-terms.adoc
|
67
|
+
[stepmod-utils] INFO: written to: 991-generated-bibliography.adoc
|
68
|
+
----
|
69
|
+
|
70
|
+
|
71
|
+
== Non-CVS repository
|
72
|
+
|
73
|
+
If the STEPmod repository is not a CVS repository, or if the `cvs` executable
|
74
|
+
cannot be found, term extract will still work.
|
75
|
+
|
76
|
+
Sample output:
|
77
|
+
|
78
|
+
[source,sh]
|
79
|
+
----
|
80
|
+
[stepmod-utils] INFO: STEPmod directory set to ../iso-10303-stepmod.
|
81
|
+
[stepmod-utils] INFO: STEPmod directory is not a CVS repository, skipping revision detection.
|
82
|
+
[stepmod-utils] INFO: Detecting paths...
|
83
|
+
[stepmod-utils] INFO: Processing XML file data/application_protocols/boundary_representation_for_iso_14306_open_jt/application_protocol.xml
|
84
|
+
[stepmod-utils] INFO: skipped ISO/CD 10303-243 as it is not IS, DIS or TS
|
85
|
+
[stepmod-utils] INFO: Processing XML file data/application_protocols/configuration_control_3d_design_ed2/application_protocol.xml
|
86
|
+
[stepmod-utils] INFO: Completed processing XML file data/application_protocols/configuration_control_3d_design_ed2/application_protocol.xml
|
87
|
+
[stepmod-utils] INFO: Processing XML file data/application_protocols/electronic_assembly_interconnect_and_packaging_design/application_protocol.xml
|
88
|
+
[stepmod-utils] INFO: skipped ISO/CD 10303-210:2019 as it is not IS, DIS or TS
|
89
|
+
[stepmod-utils] INFO: Processing XML file data/application_protocols/functional_data_and_their_schematic_representation_for_process_plant/application_protocol.xml
|
90
|
+
[stepmod-utils] INFO: Completed processing XML file data/application_protocols/functional_data_and_their_schematic_representation_for_process_plant/application_protocol.xml
|
91
|
+
...
|
92
|
+
----
|
93
|
+
|
data/exe/stepmod-extract-terms
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
1
|
#!/usr/bin/env ruby
|
4
2
|
# encoding: UTF-8
|
5
3
|
|
4
|
+
require 'pry'
|
6
5
|
# resolve bin path, ignoring symlinks
|
7
6
|
require "pathname"
|
8
7
|
bin_file = Pathname.new(__FILE__).realpath
|
@@ -21,6 +20,7 @@ require 'bundler/setup'
|
|
21
20
|
require 'stepmod/utils/stepmod_definition_converter'
|
22
21
|
require 'stepmod/utils/bibdata'
|
23
22
|
require 'stepmod/utils/concept'
|
23
|
+
require 'ptools'
|
24
24
|
|
25
25
|
ReverseAdoc.config.unknown_tags = :bypass
|
26
26
|
|
@@ -34,7 +34,22 @@ def log message
|
|
34
34
|
puts "[stepmod-utils] #{message}"
|
35
35
|
end
|
36
36
|
|
37
|
-
|
37
|
+
stepmod_path = Pathname.new(stepmod_dir).realpath
|
38
|
+
|
39
|
+
# If we are using the stepmod CVS repository, provide the revision number per file
|
40
|
+
has_cvs = File.which("cvs")
|
41
|
+
cvs_mode = has_cvs && Dir.exists?(stepmod_path.join('CVS'))
|
42
|
+
|
43
|
+
log "INFO: STEPmod directory set to #{stepmod_dir}."
|
44
|
+
|
45
|
+
if cvs_mode
|
46
|
+
log "INFO: STEPmod directory is a CVS repository and will detect revisions."
|
47
|
+
log "INFO: [CVS] Detecting file revisions can be slow, please be patient!"
|
48
|
+
else
|
49
|
+
log "INFO: STEPmod directory is not a CVS repository, skipping revision detection."
|
50
|
+
end
|
51
|
+
|
52
|
+
log "INFO: Detecting paths..."
|
38
53
|
|
39
54
|
files = %w(
|
40
55
|
resource.xml
|
@@ -46,25 +61,48 @@ files = %w(
|
|
46
61
|
end.flatten.sort.uniq
|
47
62
|
|
48
63
|
files.each do |file_path|
|
49
|
-
|
64
|
+
file_path = Pathname.new(file_path).realpath
|
65
|
+
fpath = file_path.relative_path_from(stepmod_path)
|
66
|
+
|
67
|
+
log "INFO: Processing XML file #{fpath}"
|
50
68
|
current_document = Nokogiri::XML(File.read(file_path)).root
|
51
69
|
|
52
70
|
bibdata = nil
|
53
71
|
begin
|
54
72
|
bibdata = Stepmod::Utils::Bibdata.new(document: current_document)
|
55
73
|
rescue
|
56
|
-
log "WARNING: Unknown file #{
|
74
|
+
log "WARNING: Unknown file #{fpath}, skipped"
|
57
75
|
next
|
58
76
|
end
|
59
77
|
|
60
78
|
# TODO: we may want a command line option to override this in the future
|
61
79
|
unless %w(IS DIS TS).include? bibdata.doctype
|
62
|
-
log "
|
80
|
+
log "INFO: skipped #{bibdata.docid} as it is not IS, DIS or TS"
|
63
81
|
next
|
64
82
|
end
|
65
83
|
|
66
84
|
if bibdata.part.to_s.empty?
|
67
|
-
log "FATAL: missing `part` attribute: #{
|
85
|
+
log "FATAL: missing `part` attribute: #{fpath}"
|
86
|
+
log "INFO: skipped #{bibdata.docid} as it is missing `part` attribute."
|
87
|
+
next
|
88
|
+
end
|
89
|
+
|
90
|
+
revision_string = "\n// CVS: revision not detected"
|
91
|
+
if cvs_mode
|
92
|
+
# Run `cvs status` to find out version
|
93
|
+
|
94
|
+
log "INFO: Detecting CVS revision..."
|
95
|
+
Dir.chdir(stepmod_path) do
|
96
|
+
status = `cvs status #{fpath}`
|
97
|
+
|
98
|
+
unless status.empty?
|
99
|
+
working_rev = status.split(/\n/).grep(/Working revision:/).first.match(/revision:\s+(.+)$/)[1]
|
100
|
+
repo_rev = status.split(/\n/).grep(/Repository revision:/).first.match(/revision:\t(.+)\t/)[1]
|
101
|
+
log "INFO: CVS working rev (#{working_rev}), repo rev (#{repo_rev})"
|
102
|
+
revision_string = "\n// CVS working rev: (#{working_rev}), repo rev (#{repo_rev})\n" +
|
103
|
+
"// CVS: revision #{working_rev == repo_rev ? 'up to date' : 'differs'}"
|
104
|
+
end
|
105
|
+
end
|
68
106
|
end
|
69
107
|
|
70
108
|
# read definitions
|
@@ -73,24 +111,28 @@ files.each do |file_path|
|
|
73
111
|
term_id = definition['id']
|
74
112
|
unless term_id.nil?
|
75
113
|
if encountered_terms[term_id]
|
76
|
-
log "FATAL: Duplicated term with id: #{term_id}, #{
|
114
|
+
log "FATAL: Duplicated term with id: #{term_id}, #{fpath}"
|
77
115
|
end
|
78
116
|
encountered_terms[term_id] = true
|
79
117
|
end
|
80
118
|
|
119
|
+
# Assume that definition is located in clause 3 of the ISO document
|
120
|
+
# in order. We really don't have a good reference here.
|
121
|
+
ref_clause = "3.#{index}"
|
122
|
+
|
81
123
|
concept = Stepmod::Utils::Concept.parse(
|
82
124
|
definition,
|
83
125
|
reference_anchor: bibdata.anchor,
|
84
|
-
|
85
|
-
|
86
|
-
reference_clause: "3.#{index}",
|
87
|
-
file_path: Pathname.new(file_path).relative_path_from(Pathname.new(stepmod_dir))
|
126
|
+
reference_clause: ref_clause,
|
127
|
+
file_path: fpath + revision_string
|
88
128
|
)
|
89
129
|
|
90
130
|
parsed_terms << concept
|
91
131
|
parsed_bibliography << bibdata
|
92
132
|
end
|
93
133
|
|
134
|
+
log "INFO: Completed processing XML file #{fpath}"
|
135
|
+
|
94
136
|
end
|
95
137
|
|
96
138
|
parsed_bibliography.uniq!
|
@@ -99,10 +141,10 @@ File.open('031-generated-terms.adoc', 'w') { |file|
|
|
99
141
|
file.puts(parsed_terms.map(&:to_mn_adoc).join("\n"))
|
100
142
|
}
|
101
143
|
|
102
|
-
log "written to: 031-generated-terms.adoc"
|
144
|
+
log "INFO: written to: 031-generated-terms.adoc"
|
103
145
|
|
104
146
|
File.open('991-generated-bibliography.adoc', 'w') { |file|
|
105
147
|
file.puts(parsed_bibliography.map(&:to_mn_adoc).join("\n"))
|
106
148
|
}
|
107
149
|
|
108
|
-
log "written to: 991-generated-bibliography.adoc"
|
150
|
+
log "INFO: written to: 991-generated-bibliography.adoc"
|
data/stepmod-utils.gemspec
CHANGED
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.
|
4
|
+
version: 0.2.0
|
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-
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.2.9
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ptools
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: byebug
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|