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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 031a1821b8f3b4510e1411068cbbe18ca5e1dc5d69d0072fc87e9dc009aeb796
4
- data.tar.gz: 75aabd60d69f737c2ecdfdda8abb1e438d01adf55f259be346793932db80c419
3
+ metadata.gz: d0904d633c3104d966a17882b682f011810d46dae9b832b47e3fdf05e64f140e
4
+ data.tar.gz: fcc98b428a33d7c89007486fc49fb23ee9fede9c114ac8c635a04cea894bcc85
5
5
  SHA512:
6
- metadata.gz: a5e63ce13f2bf2e792336c7ccd16c595b831af86f0750f16d0fdf877ebc7e5889c708bfd22295b99f7b321c0933cf8a51ec67da5e62b3c8ca95c5d01142e81a3
7
- data.tar.gz: f44544a34db3b2bc9709c6366e272c8cc0e3b888fe51f741a64f285ff24cd92fe40815ed2341fac5a9e0bcd330b4a641b7797228723fe44ce98fe9eee353a36e
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
- # Thoughtbot's style guide from: https://github.com/thoughtbot/guides
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
- DisplayCopNames: false
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) && /^#{GBCODE}[^A-Za-z]/.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/project-number") or return
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
- mandate = xmldoc.at("//gbmandate")&.text || "mandatory"
203
- idtext = @agencyclass.docidentifier(scope, prefix, mandate,
204
- nil, id.text) || return
205
- id.content = idtext.gsub(/\&#x2002;/, " ")
203
+ mand = xmldoc.at("//gbmandate")&.text || "mandatory"
204
+ idtext = @agencyclass.docidentifier(scope, prefix, mand, nil, id.text)
205
+ id.content = idtext&.gsub(/\&#x2002;/, " ")
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(/\&#x2002;/, " ")
206
210
  end
207
211
 
208
212
  def committee_cleanup(xmldoc)
@@ -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? node.attr("prefix")
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?(p) ? "recommended" :
128
- %r{/Z}.match?(p) ? "guidelines" : nil
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>
@@ -1034,6 +1034,9 @@
1034
1034
  <zeroOrMore>
1035
1035
  <ref name="docidentifier"/>
1036
1036
  </zeroOrMore>
1037
+ <optional>
1038
+ <ref name="docnumber"/>
1039
+ </optional>
1037
1040
  <zeroOrMore>
1038
1041
  <ref name="bdate"/>
1039
1042
  </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? prefix or
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? prefix or
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? b.at("./docidentifier").text
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?(p) ? l10n(", #{@modified_lbl} &mdash; ") : p
124
+ /\s*\[MODIFICATION\]/.match(p) ? l10n(", #{@modified_lbl} &mdash; ") : 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?(p) ? l10n(", #{@modified_lbl} &mdash; ") : p
124
+ /\s*\[MODIFICATION\]/.match(p) ? l10n(", #{@modified_lbl} &mdash; ") : p
125
125
  end.join.sub(/\A\s*/m, l10n("[")).sub(/\s*\z/m, l10n("]"))
126
126
  end
127
127
 
@@ -974,7 +974,7 @@ ul, ol {margin-left: 2em;}
974
974
  }
975
975
 
976
976
  ul > li > p:first-child:before {
977
- content: "";
977
+ content: "\2014";
978
978
  display: inline-block;
979
979
  width: 1em;
980
980
  margin-left: -1.5em;
@@ -620,7 +620,7 @@ ul li {
620
620
  }
621
621
 
622
622
  ul > li > p:first-child:before {
623
- content: "?~@~T";
623
+ content: "\2014";
624
624
  display: inline-block;
625
625
  width: 1em;
626
626
  margin-left: -1.5em;
@@ -126,14 +126,8 @@ module IsoDoc
126
126
  end
127
127
 
128
128
  def docid1(isoxml, _out)
129
- dn = docnumber(isoxml)
130
- docstatus = get[:stage]
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, @agencies.docidentifier(nil, nil, nil, docyear, get[:docnumber]))
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))
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Gb
3
- VERSION = "1.0.7"
3
+ VERSION = "1.0.8"
4
4
  end
5
5
  end
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.1"
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.7
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-10-27 00:00:00.000000000 Z
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.1
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.1
68
+ version: 0.0.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement