metanorma-jis 0.1.3 → 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 +4 -4
- data/Gemfile +5 -2
- data/lib/isodoc/jis/i18n.rb +7 -7
- data/lib/isodoc/jis/presentation_xml_convert.rb +15 -12
- data/lib/isodoc/jis/xref.rb +4 -4
- data/lib/metanorma/jis/biblio.rng +13 -0
- data/lib/metanorma/jis/front.rb +65 -90
- data/lib/metanorma/jis/isodoc.rng +11 -1
- data/lib/metanorma/jis/version.rb +1 -1
- data/metanorma-jis.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bbc9bfd3ed93ebd4eb27838a31bae9b074c79c280f0eee5c476475de1239a9c
|
4
|
+
data.tar.gz: 3404f0677c547960ef888d5503ed89b942a21c33812bb3ae042c9ed7d09f5fdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0839e480d352f8971eda023631979408b4ac4f352b06673b17e5ee02f3280842c2e51a40b9cd1bb091494f54cc9cc4235453d8d8ee18458bad55f43fe9228ec3'
|
7
|
+
data.tar.gz: bcaf0551aa3d35711b213137019a580eb84ae83c4b13a409c76644fc2af6eb577e06d46acb65260a48699598537064a6354fb35072392137161405097bc22798
|
data/Gemfile
CHANGED
@@ -2,11 +2,14 @@ Encoding.default_external = Encoding::UTF_8
|
|
2
2
|
Encoding.default_internal = Encoding::UTF_8
|
3
3
|
|
4
4
|
source "https://rubygems.org"
|
5
|
+
git_source(:github) { |repo| "https://github.com/#{repo}" }
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
group :development, :test do
|
8
|
+
gem "rspec"
|
9
|
+
end
|
8
10
|
|
9
11
|
if File.exist? "Gemfile.devel"
|
10
12
|
eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
|
11
13
|
end
|
12
14
|
|
15
|
+
gemspec
|
data/lib/isodoc/jis/i18n.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module JIS
|
3
3
|
class I18n < IsoDoc::Iso::I18n
|
4
|
+
def load_file(fname)
|
5
|
+
f = File.join(File.dirname(__FILE__), fname)
|
6
|
+
File.exist?(f) ? YAML.load_file(f) : {}
|
7
|
+
end
|
8
|
+
|
4
9
|
def load_yaml1(lang, script)
|
5
|
-
y =
|
6
|
-
|
7
|
-
else
|
8
|
-
YAML.load_file(File.join(File.dirname(__FILE__), "i18n-ja.yaml"))
|
9
|
-
end
|
10
|
-
super.deep_merge(y)
|
10
|
+
y = load_file("i18n-#{yaml_lang(lang, script)}.yaml")
|
11
|
+
y.empty? ? load_file("i18n-en.yaml").merge(super) : super.deep_merge(y)
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
15
|
-
|
@@ -205,7 +205,7 @@ module IsoDoc
|
|
205
205
|
elem = s.children.first
|
206
206
|
middle_title_hdr(elem)
|
207
207
|
middle_title_main(elem, "zzSTDTitle1")
|
208
|
-
middle_subtitle_main(elem)
|
208
|
+
middle_subtitle_main(elem, "zzSTDTitle2")
|
209
209
|
# middle_title_amd(s.children.first)
|
210
210
|
end
|
211
211
|
|
@@ -225,11 +225,8 @@ module IsoDoc
|
|
225
225
|
def middle_title_main(out, style)
|
226
226
|
t = @meta.get[:doctitlemain]
|
227
227
|
(t && !t.empty?) or return
|
228
|
-
ret =
|
229
|
-
|
230
|
-
ret += t
|
231
|
-
ret += " — " if t && @meta.get[:doctitlepart]
|
232
|
-
ret += "</p>"
|
228
|
+
ret =
|
229
|
+
middle_title_para(style, :doctitleintro, :doctitlemain, :doctitlepart)
|
233
230
|
if a = @meta.get[:doctitlepart]
|
234
231
|
ret += "<p class='zzSTDTitle1'>"
|
235
232
|
b = @meta.get[:doctitlepartlabel] and ret += "#{b}: "
|
@@ -238,14 +235,11 @@ module IsoDoc
|
|
238
235
|
out.previous = ret
|
239
236
|
end
|
240
237
|
|
241
|
-
def middle_subtitle_main(out)
|
238
|
+
def middle_subtitle_main(out, style)
|
242
239
|
t = @meta.get[:docsubtitlemain]
|
243
240
|
(t && !t.empty?) or return
|
244
|
-
ret =
|
245
|
-
|
246
|
-
ret += @meta.get[:docsubtitlemain]
|
247
|
-
ret += " — " if t && @meta.get[:docsubtitlepart]
|
248
|
-
ret += "</p>"
|
241
|
+
ret = middle_title_para(style, :docsubtitleintro, :docsubtitlemain,
|
242
|
+
:docsubtitlepart)
|
249
243
|
if a = @meta.get[:docsubtitlepart]
|
250
244
|
ret += "<p class='zzSTDTitle2'>"
|
251
245
|
b = @meta.get[:docsubtitlepartlabel] and ret += "#{b}: "
|
@@ -254,6 +248,15 @@ module IsoDoc
|
|
254
248
|
out.previous = ret
|
255
249
|
end
|
256
250
|
|
251
|
+
def middle_title_para(style, intro, main, part)
|
252
|
+
ret = "<p class='#{style}'>#{@meta.get[intro]}"
|
253
|
+
ret += " — " if @meta.get[intro] && @meta.get[main]
|
254
|
+
ret += @meta.get[main]
|
255
|
+
ret += " — " if @meta.get[main] && @meta.get[part]
|
256
|
+
ret += "</p>"
|
257
|
+
ret
|
258
|
+
end
|
259
|
+
|
257
260
|
include Init
|
258
261
|
end
|
259
262
|
end
|
data/lib/isodoc/jis/xref.rb
CHANGED
@@ -59,11 +59,11 @@ module IsoDoc
|
|
59
59
|
def back_clauses_anchor_names(xml)
|
60
60
|
clause_order_back(xml).each do |a|
|
61
61
|
xml.xpath(ns(a[:path])).each do |c|
|
62
|
-
if c["commentary"] == "true"
|
63
|
-
|
64
|
-
else
|
65
|
-
preface_names(c)
|
62
|
+
if c["commentary"] == "true" then commentary_names(c)
|
63
|
+
else preface_names(c)
|
66
64
|
end
|
65
|
+
x = Nokogiri::XML::NodeSet.new(c.document, [c])
|
66
|
+
sequential_asset_names(x, container: true)
|
67
67
|
a[:multi] or break
|
68
68
|
end
|
69
69
|
end
|
@@ -374,6 +374,16 @@
|
|
374
374
|
<ref name="image"/>
|
375
375
|
</element>
|
376
376
|
</define>
|
377
|
+
<define name="depiction">
|
378
|
+
<element name="depiction">
|
379
|
+
<optional>
|
380
|
+
<attribute name="scope"/>
|
381
|
+
</optional>
|
382
|
+
<zeroOrMore>
|
383
|
+
<ref name="image"/>
|
384
|
+
</zeroOrMore>
|
385
|
+
</element>
|
386
|
+
</define>
|
377
387
|
<define name="NameWithVariants">
|
378
388
|
<element name="primary">
|
379
389
|
<ref name="LocalizedString"/>
|
@@ -760,6 +770,9 @@
|
|
760
770
|
<optional>
|
761
771
|
<ref name="validity"/>
|
762
772
|
</optional>
|
773
|
+
<optional>
|
774
|
+
<ref name="depiction"/>
|
775
|
+
</optional>
|
763
776
|
</define>
|
764
777
|
<define name="ReducedBibliographicItem">
|
765
778
|
<optional>
|
data/lib/metanorma/jis/front.rb
CHANGED
@@ -7,29 +7,28 @@ module Metanorma
|
|
7
7
|
super.merge("Japanese Industrial Standards" => "JIS")
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def default_publisher
|
11
11
|
"JIS"
|
12
12
|
end
|
13
13
|
|
14
|
-
# Like the ISO code, but multilingual
|
15
14
|
def metadata_author(node, xml)
|
16
|
-
|
17
|
-
|
15
|
+
org_contributor(node, xml,
|
16
|
+
{ source: ["publisher", "pub"], role: "author",
|
17
|
+
default: JIS_HASH })
|
18
18
|
node.attr("doctype") == "expert-commentary" and
|
19
19
|
personal_author(node, xml)
|
20
20
|
end
|
21
21
|
|
22
22
|
def metadata_publisher(node, xml)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
desc: "Investigative committee" })
|
23
|
+
[{ source: ["publisher", "pub"], role: "publisher", default: JIS_HASH },
|
24
|
+
{ role: "authorizer",
|
25
|
+
source: ["investigative-organization"],
|
26
|
+
desc: "Investigative organization" },
|
27
|
+
{ role: "authorizer",
|
28
|
+
source: ["investigative-committee"],
|
29
|
+
desc: "Investigative committee" }].each do |o|
|
30
|
+
org_contributor(node, xml, o)
|
31
|
+
end
|
33
32
|
end
|
34
33
|
|
35
34
|
LANGS = %w(ja en).freeze
|
@@ -37,56 +36,58 @@ module Metanorma
|
|
37
36
|
JIS_HASH =
|
38
37
|
{ "ja" => "日本工業規格", "en" => "Japanese Industrial Standards" }.freeze
|
39
38
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
39
|
+
def org_organization(node, xml, org)
|
40
|
+
organization(xml, { name: org[:name], abbr: org[:abbr] }.compact,
|
41
|
+
node, !multiling_docattr(node, "publisher", "", LANGS))
|
42
|
+
org_address(org, xml)
|
43
|
+
org_logo(xml, org[:logo])
|
43
44
|
end
|
44
45
|
|
45
|
-
def
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
opt[:desc] and r.description opt[:desc]
|
50
|
-
end
|
51
|
-
c.organization do |a|
|
52
|
-
organization(a, p, opt[:role] == "publisher", node, default)
|
53
|
-
end
|
54
|
-
end
|
46
|
+
def org_attrs_parse(node, opts)
|
47
|
+
source = opts[:source]&.detect { |s| node.attr(s) }
|
48
|
+
source ||= opts[:source]&.detect do |s|
|
49
|
+
LANGS.detect { |l| node.attr("#{s}-#{l}") }
|
55
50
|
end
|
51
|
+
org_attrs_simple_parse(node, opts, source) ||
|
52
|
+
org_attrs_complex_parse(node, opts, source)
|
53
|
+
end
|
54
|
+
|
55
|
+
def org_attrs_complex_parse(node, opts, source)
|
56
|
+
i = 1
|
57
|
+
suffix = ""
|
58
|
+
ret = []
|
59
|
+
while multiling_docattr(node, source, suffix, LANGS)
|
60
|
+
ret << extract_org_attrs_complex(node, opts, source, suffix)
|
61
|
+
i += 1
|
62
|
+
suffix = "_#{i}"
|
63
|
+
end
|
64
|
+
ret
|
56
65
|
end
|
57
66
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
[pub&.map { |p| { name: p, abbr: abbr } }, default]
|
62
|
-
end
|
63
|
-
|
64
|
-
def multiling_docattr(node, attr, langs)
|
65
|
-
ret = node.attr(attr) and return ret
|
67
|
+
def multiling_docattr(node, attr, suffix, langs)
|
68
|
+
node.nil? and return nil
|
69
|
+
ret = node.attr(attr + suffix) and return ret
|
66
70
|
ret = langs.each_with_object({}).each do |l, m|
|
67
|
-
x = node.attr("#{attr}-#{l}") and m[l] = x
|
71
|
+
x = node.attr("#{attr}-#{l}#{suffix}") and m[l] = x
|
68
72
|
end.compact
|
69
73
|
ret.empty? and return nil
|
70
74
|
ret
|
71
75
|
end
|
72
76
|
|
73
|
-
def
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
[ret, not_found]
|
77
|
+
def extract_org_attrs_complex(node, opts, source, suffix)
|
78
|
+
{ name: multiling_docattr(node, source, suffix, LANGS),
|
79
|
+
role: opts[:role], desc: opts[:desc],
|
80
|
+
abbr: multiling_docattr(node, "#{source}-abbr", suffix, LANGS),
|
81
|
+
logo: multiling_docattr(node, "#{source}_logo", suffix, LANGS) }
|
82
|
+
.compact
|
83
|
+
.merge(extract_org_attrs_address(node, opts, suffix))
|
81
84
|
end
|
82
85
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
m[i] ||= {}
|
89
|
-
m[i][k] = v1
|
86
|
+
def extract_org_attrs_address(node, opts, suffix)
|
87
|
+
%w(address phone fax email uri).each_with_object({}) do |a, m|
|
88
|
+
opts[:source]&.each do |s|
|
89
|
+
p = multiling_docattr(node, "#{s}-#{a}", suffix, LANGS) and
|
90
|
+
m[a.to_sym] = p
|
90
91
|
end
|
91
92
|
end
|
92
93
|
end
|
@@ -104,37 +105,26 @@ module Metanorma
|
|
104
105
|
end
|
105
106
|
end
|
106
107
|
|
107
|
-
def organization(xml, org,
|
108
|
-
org.is_a?(Hash) or org = { name: org }
|
108
|
+
def organization(xml, org, node = nil, default_org = nil)
|
109
|
+
org.is_a?(Hash) && org[:name] or org = { name: org }
|
109
110
|
abbrevs = org_abbrev
|
110
111
|
name_str = org[:name].is_a?(Hash) ? org[:name]["en"] : org[:name]
|
111
112
|
n = abbrevs.invert[org[:name]] and org = { name: n, abbr: org[:name] }
|
112
113
|
multiling_noko_value(org[:name], "name", xml)
|
113
|
-
default_org && a = multiling_docattr(node, "subdivision", LANGS) and
|
114
|
+
default_org && a = multiling_docattr(node, "subdivision", "", LANGS) and
|
114
115
|
multiling_noko_value(a, "subdivision", xml)
|
115
116
|
abbr = org[:abbr]
|
116
117
|
abbr ||= org_abbrev[name_str]
|
117
|
-
default_org && b = node
|
118
|
+
default_org && b = node&.attr("subdivision-abbr") and abbr = b
|
118
119
|
abbr and xml.abbreviation abbr
|
119
|
-
# is_pub && node and org_address(node, org) # should refactor into struct, like abbr
|
120
120
|
end
|
121
121
|
|
122
|
-
def
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
pub&.each do |p|
|
129
|
-
xml.copyright do |c|
|
130
|
-
c.from (node.attr("copyright-year") || Date.today.year)
|
131
|
-
c.owner do |owner|
|
132
|
-
owner.organization do |o|
|
133
|
-
organization(o, p, true, node, default)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
122
|
+
def copyright_parse(node)
|
123
|
+
opt = { source: ["copyright-holder", "publisher", "pub"],
|
124
|
+
role: "publisher", default: JIS_HASH }
|
125
|
+
ret = org_attrs_parse(node, opt)
|
126
|
+
ret.empty? and ret = [{ name: "-" }]
|
127
|
+
ret
|
138
128
|
end
|
139
129
|
|
140
130
|
def title(node, xml)
|
@@ -149,8 +139,6 @@ module Metanorma
|
|
149
139
|
end
|
150
140
|
|
151
141
|
def metadata_id(node, xml)
|
152
|
-
node.attr("docidentifier") || node.attr("docnumber") or
|
153
|
-
@fatalerror << "No docnumber attribute supplied"
|
154
142
|
if id = node.attr("docidentifier")
|
155
143
|
xml.docidentifier id.sub(/^JIS /, ""), **attr_code(type: "JIS")
|
156
144
|
else iso_id(node, xml)
|
@@ -167,21 +155,8 @@ module Metanorma
|
|
167
155
|
end
|
168
156
|
end
|
169
157
|
|
170
|
-
def
|
171
|
-
|
172
|
-
return
|
173
|
-
params = iso_id_params(node)
|
174
|
-
iso_id_out(xml, params, true)
|
175
|
-
end
|
176
|
-
|
177
|
-
def iso_id_params(node)
|
178
|
-
params = iso_id_params_core(node)
|
179
|
-
params2 = iso_id_params_add(node)
|
180
|
-
if node.attr("updates")
|
181
|
-
orig_id = Pubid::Jis::Identifier::Base.parse(node.attr("updates"))
|
182
|
-
orig_id.edition ||= 1
|
183
|
-
end
|
184
|
-
iso_id_params_resolve(params, params2, node, orig_id)
|
158
|
+
def base_pubid
|
159
|
+
Pubid::Jis::Identifier
|
185
160
|
end
|
186
161
|
|
187
162
|
def iso_id_params_core(node)
|
@@ -208,7 +183,7 @@ module Metanorma
|
|
208
183
|
end
|
209
184
|
|
210
185
|
def iso_id_default(params)
|
211
|
-
|
186
|
+
base_pubid.create(**params)
|
212
187
|
rescue StandardError => e
|
213
188
|
clean_abort("Document identifier: #{e}", xml)
|
214
189
|
end
|
@@ -17,7 +17,7 @@
|
|
17
17
|
these elements; we just want one namespace for any child grammars
|
18
18
|
of this.
|
19
19
|
-->
|
20
|
-
<!-- VERSION v1.2.
|
20
|
+
<!-- VERSION v1.2.9 -->
|
21
21
|
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
22
22
|
<include href="reqt.rng"/>
|
23
23
|
<include href="basicdoc.rng">
|
@@ -1958,6 +1958,16 @@
|
|
1958
1958
|
<data type="boolean"/>
|
1959
1959
|
</attribute>
|
1960
1960
|
</optional>
|
1961
|
+
<optional>
|
1962
|
+
<attribute name="type">
|
1963
|
+
<choice>
|
1964
|
+
<value>letter</value>
|
1965
|
+
<value>symbol</value>
|
1966
|
+
<value>formula</value>
|
1967
|
+
<value>equation</value>
|
1968
|
+
</choice>
|
1969
|
+
</attribute>
|
1970
|
+
</optional>
|
1961
1971
|
<element name="name">
|
1962
1972
|
<oneOrMore>
|
1963
1973
|
<choice>
|
data/metanorma-jis.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
31
31
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
32
32
|
|
33
|
-
spec.add_dependency "metanorma-iso", "~> 2.
|
33
|
+
spec.add_dependency "metanorma-iso", "~> 2.6.0"
|
34
34
|
spec.add_dependency "pubid-jis"
|
35
35
|
|
36
36
|
spec.add_development_dependency "debug"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-jis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-iso
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.6.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.6.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pubid-jis
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|