metanorma-gb 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -7
- data/README.adoc +0 -21
- data/lib/asciidoctor/gb/biblio.rng +10 -0
- data/lib/asciidoctor/gb/converter.rb +10 -6
- data/lib/asciidoctor/gb/front.rb +33 -20
- data/lib/asciidoctor/gb/gbstandard.rng +6 -0
- data/lib/asciidoctor/gb/isodoc.rng +3 -0
- data/lib/asciidoctor/gb/isostandard.rng +6 -0
- data/lib/asciidoctor/gb/validate.rb +3 -3
- data/lib/isodoc/gb/gbhtmlrender.rb +1 -1
- data/lib/isodoc/gb/gbwordconvert.rb +0 -26
- data/lib/isodoc/gb/gbwordrender.rb +1 -1
- data/lib/isodoc/gb/html/htmlcompliantstyle.scss +1 -1
- data/lib/isodoc/gb/html/htmlstyle.scss +1 -1
- data/lib/isodoc/gb/metadata.rb +3 -9
- data/lib/metanorma/gb/version.rb +1 -1
- data/metanorma-gb.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: d0904d633c3104d966a17882b682f011810d46dae9b832b47e3fdf05e64f140e
|
4
|
+
data.tar.gz: fcc98b428a33d7c89007486fc49fb23ee9fede9c114ac8c635a04cea894bcc85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eedc83eeaa4b7e7a0fdf9150812a8332fc5ce4760dd0f124c998d9baaf63ca432d9191129dbf3800683c55fce28bb00ddb0ed8eadcd9576ac30b54e6dac9383d
|
7
|
+
data.tar.gz: 72365bff0d1d9098fbc1ade88faf2ee42c59fed446414ecff347c170c7c78b24891716cb3f9c8d4fb08820e7e3eb380f7d3ab2ff9bd06264328fd2ea4fe32a31
|
data/.rubocop.yml
CHANGED
@@ -3,13 +3,8 @@
|
|
3
3
|
# All project-specific additions and overrides should be specified in this file.
|
4
4
|
|
5
5
|
inherit_from:
|
6
|
-
|
7
|
-
- ".rubocop.tb.yml"
|
8
|
-
# Overrides from Ribose
|
9
|
-
- ".rubocop.ribose.yml"
|
6
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
10
7
|
AllCops:
|
11
|
-
|
12
|
-
StyleGuideCopsOnly: false
|
13
|
-
TargetRubyVersion: 2.4
|
8
|
+
TargetRubyVersion: 2.3
|
14
9
|
Rails:
|
15
10
|
Enabled: true
|
data/README.adoc
CHANGED
@@ -152,27 +152,6 @@ Any `/Z` or `/T` suffix (indicating "recommended" and "guidelines" mandate) is
|
|
152
152
|
ignored unless the `:mandate:` attribute is not given. Any `Q/` or `T/` prefix for social and enterprise
|
153
153
|
standards is ignored unless the `:scope:` attribute is not given.
|
154
154
|
|
155
|
-
`:issued-date:`::
|
156
|
-
The date on which the GB standard was issued (authorised for publication by the issuing authority).
|
157
|
-
|
158
|
-
`:published-date:`::
|
159
|
-
The date on which the GB standard was published (distributed by the publisher).
|
160
|
-
|
161
|
-
`:implemented-date:`::
|
162
|
-
The date on which the GB standard became active.
|
163
|
-
|
164
|
-
`:created-date:`::
|
165
|
-
The date on which the first version of the GB standard was created.
|
166
|
-
|
167
|
-
`:updated-date:`::
|
168
|
-
The date on which the current version of the GB standard was updated.
|
169
|
-
|
170
|
-
`:obsoleted-date:`::
|
171
|
-
The date on which the GB standard was obsoleted/revoked.
|
172
|
-
|
173
|
-
`:confirmed-date:`::
|
174
|
-
The date on which the GB standard was reviewed and approved by the issuing authority.
|
175
|
-
|
176
155
|
`:library-ics:`::
|
177
156
|
The ICS (International Categorization for Standards) number for the GB standard. There may be more than one ICS for a document; if so, they should be comma-delimited. (Unlike the case for ISO, the ICS identifier is output to the front page of the GB standard.)
|
178
157
|
|
@@ -476,6 +476,9 @@
|
|
476
476
|
<zeroOrMore>
|
477
477
|
<ref name="docidentifier"/>
|
478
478
|
</zeroOrMore>
|
479
|
+
<optional>
|
480
|
+
<ref name="docnumber"/>
|
481
|
+
</optional>
|
479
482
|
<zeroOrMore>
|
480
483
|
<ref name="bdate"/>
|
481
484
|
</zeroOrMore>
|
@@ -637,6 +640,8 @@
|
|
637
640
|
<value>transmitted</value>
|
638
641
|
<value>copied</value>
|
639
642
|
<value>unchanged</value>
|
643
|
+
<value>circulated</value>
|
644
|
+
<text/>
|
640
645
|
</choice>
|
641
646
|
</attribute>
|
642
647
|
<choice>
|
@@ -673,6 +678,11 @@
|
|
673
678
|
<text/>
|
674
679
|
</element>
|
675
680
|
</define>
|
681
|
+
<define name="docnumber">
|
682
|
+
<element name="docnumber">
|
683
|
+
<text/>
|
684
|
+
</element>
|
685
|
+
</define>
|
676
686
|
<define name="bclassification">
|
677
687
|
<element name="classification">
|
678
688
|
<optional>
|
@@ -178,7 +178,8 @@ module Asciidoctor
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def fetch_ref(xml, code, year, **opts)
|
181
|
-
code = "CN(#{code})" if !/^CN\(/.match(code) &&
|
181
|
+
code = "CN(#{code})" if !/^CN\(/.match(code) &&
|
182
|
+
/^#{GBCODE}[^A-Za-z]/.match(code)
|
182
183
|
hit = @bibdb&.fetch(code, year, opts)
|
183
184
|
return nil if hit.nil?
|
184
185
|
xml.parent.add_child(Asciidoctor::Standoc::Utils::smart_render_xml(hit))
|
@@ -196,13 +197,16 @@ module Asciidoctor
|
|
196
197
|
end
|
197
198
|
|
198
199
|
def docidentifier_cleanup(xmldoc)
|
199
|
-
id = xmldoc.at("//bibdata/docidentifier
|
200
|
+
id = xmldoc.at("//bibdata/docidentifier[@type = 'gb']") or return
|
200
201
|
scope = xmldoc.at("//gbscope")&.text
|
201
202
|
prefix = xmldoc.at("//gbprefix")&.text
|
202
|
-
|
203
|
-
idtext = @agencyclass.docidentifier(scope, prefix,
|
204
|
-
|
205
|
-
id
|
203
|
+
mand = xmldoc.at("//gbmandate")&.text || "mandatory"
|
204
|
+
idtext = @agencyclass.docidentifier(scope, prefix, mand, nil, id.text)
|
205
|
+
id.content = idtext&.gsub(/\ /, " ")
|
206
|
+
id = xmldoc.at("//bibdata/docidentifier[@type = 'gb-structured']/"\
|
207
|
+
"project-number") or return
|
208
|
+
idtext = @agencyclass.docidentifier(scope, prefix, mand, nil, id.text)
|
209
|
+
id.content = idtext&.gsub(/\ /, " ")
|
206
210
|
end
|
207
211
|
|
208
212
|
def committee_cleanup(xmldoc)
|
data/lib/asciidoctor/gb/front.rb
CHANGED
@@ -97,7 +97,7 @@ module Asciidoctor
|
|
97
97
|
|
98
98
|
def get_scope(node)
|
99
99
|
node.attr("scope") and return node.attr("scope")
|
100
|
-
scope = if %r{^[TQ]/}.match
|
100
|
+
scope = if %r{^[TQ]/}.match node.attr("prefix")
|
101
101
|
m = node.attr("prefix").split(%{/})
|
102
102
|
mandate = m[0] == "T" ? "social-group" :
|
103
103
|
m[0] == "Q" ? "enterprise" : nil
|
@@ -124,8 +124,8 @@ module Asciidoctor
|
|
124
124
|
def get_mandate(node)
|
125
125
|
node.attr("mandate") and return node.attr("mandate")
|
126
126
|
p = node.attr("prefix")
|
127
|
-
mandate = %r{/T}.match
|
128
|
-
%r{/Z}.match
|
127
|
+
mandate = %r{/T}.match(p) ? "recommended" :
|
128
|
+
%r{/Z}.match(p) ? "guidelines" : nil
|
129
129
|
if mandate.nil?
|
130
130
|
mandate = "mandatory"
|
131
131
|
warn "GB: no mandate supplied, defaulting to mandatory"
|
@@ -149,23 +149,6 @@ module Asciidoctor
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
def metadata_date1(node, xml, type)
|
153
|
-
date = node.attr("#{type}-date")
|
154
|
-
date and xml.date **{ type: type } do |d|
|
155
|
-
d.on date
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
DATETYPES = %w{ published accessed created implemented obsoleted
|
160
|
-
confirmed updated issued
|
161
|
-
}.freeze
|
162
|
-
|
163
|
-
def metadata_date(node, xml)
|
164
|
-
DATETYPES.each do |t|
|
165
|
-
metadata_date1(node, xml, t)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
152
|
def metadata_gblibraryids(node, xml)
|
170
153
|
ccs = node.attr("library-ccs")
|
171
154
|
ccs and ccs.split(/, ?/).each do |l|
|
@@ -189,6 +172,36 @@ module Asciidoctor
|
|
189
172
|
metadata_contributor1(node, xml, "issuer", "issuer")
|
190
173
|
end
|
191
174
|
|
175
|
+
def iso_id(node, xml)
|
176
|
+
return unless node.attr("docnumber")
|
177
|
+
part = node.attr("partnumber")
|
178
|
+
dn = add_id_parts(node.attr("docnumber"), part, nil)
|
179
|
+
dn = id_stage_prefix(dn, node)
|
180
|
+
xml.docidentifier dn, **attr_code(type: "gb")
|
181
|
+
xml.docidentifier **attr_code(type: "gb-structured") do |i|
|
182
|
+
i.project_number node.attr("docnumber"),
|
183
|
+
**attr_code(part: part)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def add_id_parts(dn, part, subpart)
|
188
|
+
dn += ".#{part}" if part
|
189
|
+
dn += ".#{subpart}" if subpart
|
190
|
+
dn
|
191
|
+
end
|
192
|
+
|
193
|
+
def id_stage_prefix(dn, node)
|
194
|
+
if node.attr("docstage") && node.attr("docstage").to_i < 60
|
195
|
+
abbr = IsoDoc::Gb::Metadata.new("en", "Latn", {}).
|
196
|
+
stage_abbrev(node.attr("docstage"), node.attr("iteration"),
|
197
|
+
node.attr("draft"))
|
198
|
+
dn = "/#{abbr} #{dn}" # prefixes added in cleanup
|
199
|
+
else
|
200
|
+
dn += "-#{node.attr("copyright-year")}" if node.attr("copyright-year")
|
201
|
+
end
|
202
|
+
dn
|
203
|
+
end
|
204
|
+
|
192
205
|
def metadata(node, xml)
|
193
206
|
title node, xml
|
194
207
|
metadata_source(node, xml)
|
@@ -93,6 +93,9 @@
|
|
93
93
|
<zeroOrMore>
|
94
94
|
<ref name="docidentifier"/>
|
95
95
|
</zeroOrMore>
|
96
|
+
<optional>
|
97
|
+
<ref name="docnumber"/>
|
98
|
+
</optional>
|
96
99
|
<zeroOrMore>
|
97
100
|
<ref name="bdate"/>
|
98
101
|
</zeroOrMore>
|
@@ -160,6 +163,9 @@
|
|
160
163
|
<zeroOrMore>
|
161
164
|
<ref name="docidentifier"/>
|
162
165
|
</zeroOrMore>
|
166
|
+
<optional>
|
167
|
+
<ref name="docnumber"/>
|
168
|
+
</optional>
|
163
169
|
<zeroOrMore>
|
164
170
|
<ref name="bdate"/>
|
165
171
|
</zeroOrMore>
|
@@ -84,6 +84,9 @@
|
|
84
84
|
<zeroOrMore>
|
85
85
|
<ref name="docidentifier"/>
|
86
86
|
</zeroOrMore>
|
87
|
+
<optional>
|
88
|
+
<ref name="docnumber"/>
|
89
|
+
</optional>
|
87
90
|
<zeroOrMore>
|
88
91
|
<ref name="bdate"/>
|
89
92
|
</zeroOrMore>
|
@@ -163,6 +166,9 @@
|
|
163
166
|
<zeroOrMore>
|
164
167
|
<ref name="docidentifier"/>
|
165
168
|
</zeroOrMore>
|
169
|
+
<optional>
|
170
|
+
<ref name="docnumber"/>
|
171
|
+
</optional>
|
166
172
|
<zeroOrMore>
|
167
173
|
<ref name="bdate"/>
|
168
174
|
</zeroOrMore>
|
@@ -21,10 +21,10 @@ module Asciidoctor
|
|
21
21
|
scope = root&.at("//gbscope")&.text
|
22
22
|
case scope
|
23
23
|
when "social-group"
|
24
|
-
/^[A-Za-z]{3,6}$/.match
|
24
|
+
/^[A-Za-z]{3,6}$/.match(prefix) or
|
25
25
|
warn("#{prefix} is improperly formatted for social standards")
|
26
26
|
when "enterprise"
|
27
|
-
/^[A-Z0-9]{3,}$/.match
|
27
|
+
/^[A-Z0-9]{3,}$/.match(prefix) or
|
28
28
|
warn("#{prefix} is improperly formatted for enterprise standards")
|
29
29
|
when "sector"
|
30
30
|
%w(AQ BB CB CH CJ CY DA DB DL DZ EJ FZ GA GH GM GY HB HG HJ HS HY
|
@@ -104,7 +104,7 @@ module Asciidoctor
|
|
104
104
|
def norm_bibitem_style(root)
|
105
105
|
root.xpath(NORM_BIBITEMS).each do |b|
|
106
106
|
if b.at(Asciidoctor::Standoc::Converter::ISO_PUBLISHER_XPATH).nil?
|
107
|
-
unless /^#{GBCODE}(?![A-Z])/.match
|
107
|
+
unless /^#{GBCODE}(?![A-Z])/.match(b.at("./docidentifier").text)
|
108
108
|
Asciidoctor::Standoc::Utils::warning(b, NORM_ISO_WARN, b.text)
|
109
109
|
end
|
110
110
|
end
|
@@ -121,7 +121,7 @@ module IsoDoc
|
|
121
121
|
parts = x.split(%r{(\s*\[MODIFICATION\]|,)}m)
|
122
122
|
parts[1] = l10n(", #{@source_lbl}") if parts.size > 1 && parts[1] == ","
|
123
123
|
parts.map do |p|
|
124
|
-
/\s*\[MODIFICATION\]/.match
|
124
|
+
/\s*\[MODIFICATION\]/.match(p) ? l10n(", #{@modified_lbl} — ") : p
|
125
125
|
end.join.sub(/\A\s*/m, l10n("[")).sub(/\s*\z/m, l10n("]"))
|
126
126
|
end
|
127
127
|
|
@@ -100,32 +100,6 @@ module IsoDoc
|
|
100
100
|
out.parent.add_child(ENDLINE)
|
101
101
|
end
|
102
102
|
|
103
|
-
def generate_header(filename, dir)
|
104
|
-
return unless @header
|
105
|
-
template = Liquid::Template.parse(File.read(@header, encoding: "UTF-8"))
|
106
|
-
meta = @meta.get
|
107
|
-
meta[:filename] = filename
|
108
|
-
params = meta.map { |k, v| [k.to_s, v] }.to_h
|
109
|
-
File.open("header.html", "w:utf-8") { |f| f.write(template.render(params)) }
|
110
|
-
FileUtils.cp @common.fileloc(File.join('html', 'blank.png')), "blank.png"
|
111
|
-
@files_to_delete << "blank.png"
|
112
|
-
@files_to_delete << "header.html"
|
113
|
-
"header.html"
|
114
|
-
end
|
115
|
-
|
116
|
-
def header_strip(h)
|
117
|
-
h = h.to_s.gsub(%r{<br/>}, " ").sub(/<\/?h[12][^>]*>/, "")
|
118
|
-
h1 = to_xhtml_fragment(h.dup)
|
119
|
-
h1.traverse do |x|
|
120
|
-
x.replace(" ") if x.name == "span" &&
|
121
|
-
/mso-tab-count/.match?(x["style"])
|
122
|
-
x.remove if x.name == "span" && x["class"] == "MsoCommentReference"
|
123
|
-
x.remove if x.name == "a" && x["epub:type"] == "footnote"
|
124
|
-
x.replace(x.children) if x.name == "a"
|
125
|
-
end
|
126
|
-
from_xhtml(h1)
|
127
|
-
end
|
128
|
-
|
129
103
|
def word_cleanup(docxml)
|
130
104
|
word_preface(docxml)
|
131
105
|
word_annex_cleanup(docxml)
|
@@ -121,7 +121,7 @@ module IsoDoc
|
|
121
121
|
parts = x.split(%r{(\s*\[MODIFICATION\]|,)}m)
|
122
122
|
parts[1] = l10n(", #{@source_lbl}") if parts.size > 1 && parts[1] == ","
|
123
123
|
parts.map do |p|
|
124
|
-
/\s*\[MODIFICATION\]/.match
|
124
|
+
/\s*\[MODIFICATION\]/.match(p) ? l10n(", #{@modified_lbl} — ") : p
|
125
125
|
end.join.sub(/\A\s*/m, l10n("[")).sub(/\s*\z/m, l10n("]"))
|
126
126
|
end
|
127
127
|
|
data/lib/isodoc/gb/metadata.rb
CHANGED
@@ -126,14 +126,8 @@ module IsoDoc
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def docid1(isoxml, _out)
|
129
|
-
dn =
|
130
|
-
|
131
|
-
if docstatus
|
132
|
-
abbr = stage_abbrev(docstatus.to_s, isoxml.at(ns("//bibdata/status/iteration")),
|
133
|
-
isoxml.at(ns("//version/draft")))
|
134
|
-
(docstatus.to_i < 60) && dn = abbr + " " + dn
|
135
|
-
end
|
136
|
-
set(:docnumber, dn)
|
129
|
+
dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'gb']"))
|
130
|
+
set(:docnumber, dn&.text)
|
137
131
|
end
|
138
132
|
|
139
133
|
def docid(isoxml, _out)
|
@@ -174,7 +168,7 @@ module IsoDoc
|
|
174
168
|
issuer = isoxml&.at(ns("//bibdata/contributor[role/@type = 'issuer']/"\
|
175
169
|
"organization/name"))&.text || "GB"
|
176
170
|
@agencies = GbAgencies::Agencies.new(@lang, @labels, issuer)
|
177
|
-
set(:docidentifier,
|
171
|
+
set(:docidentifier, get[:docnumber])
|
178
172
|
set(:issuer, issuer)
|
179
173
|
set(:standard_class, standard_class(scope, prefix, mandate))
|
180
174
|
set(:standard_agency, @agencies.standard_agency(scope, prefix, mandate))
|
data/lib/metanorma/gb/version.rb
CHANGED
data/metanorma-gb.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency "metanorma-iso", "~> 1.0.1"
|
32
32
|
spec.add_dependency "isodoc", "~> 0.9.1"
|
33
33
|
spec.add_dependency "twitter_cldr"
|
34
|
-
spec.add_dependency "gb-agencies", "~> 0.0.
|
34
|
+
spec.add_dependency "gb-agencies", "~> 0.0.4"
|
35
35
|
|
36
36
|
spec.add_development_dependency "bundler", "~> 1.15"
|
37
37
|
spec.add_development_dependency "byebug", "~> 9.1"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-gb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: metanorma-iso
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.0.
|
61
|
+
version: 0.0.4
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.0.
|
68
|
+
version: 0.0.4
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|