isodoc 1.2.5 → 1.2.6

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: 1f76ecc765fd3176ab1e46bd2b91b2a1d5746554772047b7137581ecc54a1ab9
4
- data.tar.gz: b98fe5eee6522b4d5992c4213f3180e1c95f92f358b0c56ff3a2b5f66973a900
3
+ metadata.gz: dcbc3f4f71f739273b06483080ad077fcda05b20f8eca96858300543b0fb2784
4
+ data.tar.gz: f0c4a29519de6c22dbc47af2193d8f4ee0a2c925c5d0c9f58414813be28070ef
5
5
  SHA512:
6
- metadata.gz: 1a2649fdf7365e2554c0e0bdec19aa0cf6e50fad624d4252dd99aa88d436b95b1ff24e823c6a0a9be4afa7e875921b11310e67595b308a9c81c8758b6e8cf302
7
- data.tar.gz: d21cdae8851e757e999a54809868e15a8004fcc387afa78e79e60a4605df07108c454fc3c04e0a3e79f3a5c14af9ca8cdbbb855eca9fa47e254e3ff4a40d3ac4
6
+ metadata.gz: 5eb17f999c954a1185f60807f5c9b4dcdde33391fd95546d51dca4a00aee8d742736155313153a5007205d06d189c5ee69b39152db57478669e54e7622fde568
7
+ data.tar.gz: e0122186b16428b61c7009d7c8560ab12de531a8ec3bac56e58e89528f4a2a0acd2e1ab4ce4453919f7ed2707e7724037175852a3dc148a53bb0eef63aa5f695
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
37
37
  spec.add_dependency "liquid"
38
38
  spec.add_dependency "roman-numerals"
39
39
  spec.add_dependency "metanorma", "~> 1.1.0"
40
+ spec.add_dependency "relaton-cli"
40
41
 
41
42
  spec.add_development_dependency "rake", "~> 13.0"
42
43
  spec.add_development_dependency "byebug", "~> 9.1"
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
9
9
  table, caption, tbody, tfoot, thead, tr, th, td,
10
10
  article, aside, canvas, details, embed,
11
11
  figure, figcaption, footer, header, hgroup,
12
- menu, nav, output, ruby, section, summary,
12
+ menu, output, ruby, section, summary,
13
13
  time, mark, audio, video {
14
14
  margin: 0;
15
15
  padding: 0; }
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
9
9
  table, caption, tbody, tfoot, thead, tr, th, td,
10
10
  article, aside, canvas, details, embed,
11
11
  figure, figcaption, footer, header, hgroup,
12
- menu, nav, output, ruby, section, summary,
12
+ menu, output, ruby, section, summary,
13
13
  time, mark, audio, video {
14
14
  margin: 0;
15
15
  padding: 0; }
@@ -9,7 +9,7 @@ fieldset, form, label, legend,
9
9
  table, caption, tbody, tfoot, thead, tr, th, td,
10
10
  article, aside, canvas, details, embed,
11
11
  figure, figcaption, footer, header, hgroup,
12
- menu, nav, output, ruby, section, summary,
12
+ menu, output, ruby, section, summary,
13
13
  time, mark, audio, video {
14
14
  margin: 0;
15
15
  padding: 0;
@@ -104,6 +104,7 @@ module IsoDoc::Function
104
104
  @meta.version isoxml, out
105
105
  @meta.url isoxml, out
106
106
  @meta.keywords isoxml, out
107
+ @meta.note isoxml, out
107
108
  @meta.get
108
109
  end
109
110
 
@@ -42,55 +42,6 @@ module IsoDoc
42
42
  @labels.each do |k, v|
43
43
  self.class.send(:define_method, k.downcase) { v }
44
44
  end
45
- =begin
46
- @term_def_boilerplate = y["term_def_boilerplate"]
47
- @scope_lbl = y["scope"]
48
- @symbols_lbl = y["symbols"]
49
- @table_of_contents_lbl = y["table_of_contents"]
50
- @introduction_lbl = y["introduction"]
51
- @foreword_lbl = y["foreword"]
52
- @abstract_lbl = y["abstract"]
53
- @termsdef_lbl = y["termsdef"]
54
- @termsdefsymbols_lbl = y["termsdefsymbols"]
55
- @normref_lbl = y["normref"]
56
- @bibliography_lbl = y["bibliography"]
57
- @clause_lbl = y["clause"]
58
- @annex_lbl = y["annex"]
59
- @appendix_lbl = y["appendix"]
60
- @no_terms_boilerplate = y["no_terms_boilerplate"]
61
- @internal_terms_boilerplate = y["internal_terms_boilerplate"]
62
- @norm_with_refs_pref = y["norm_with_refs_pref"]
63
- @norm_empty_pref = y["norm_empty_pref"]
64
- @external_terms_boilerplate = y["external_terms_boilerplate"]
65
- @internal_external_terms_boilerplate =
66
- y["internal_external_terms_boilerplate"]
67
- @note_lbl = y["note"]
68
- @note_xref_lbl = y["note_xref"]
69
- @termnote_lbl = y["termnote"]
70
- @figure_lbl = y["figure"]
71
- @list_lbl = y["list"]
72
- @formula_lbl = y["formula"]
73
- @inequality_lbl = y["inequality"]
74
- @table_lbl = y["table"]
75
- @key_lbl = y["key"]
76
- @example_lbl = y["example"]
77
- @example_xref_lbl = y["example_xref"]
78
- @where_lbl = y["where"]
79
- @wholeoftext_lbl = y["wholeoftext"]
80
- @draft_lbl = y["draft_label"]
81
- @inform_annex_lbl = y["inform_annex"]
82
- @norm_annex_lbl = y["norm_annex"]
83
- @modified_lbl = y["modified"]
84
- @deprecated_lbl = y["deprecated"]
85
- @source_lbl = y["source"]
86
- @and_lbl = y["and"]
87
- @all_parts_lbl = y["all_parts"]
88
- @permission_lbl = y["permission"]
89
- @recommendation_lbl = y["recommendation"]
90
- @requirement_lbl = y["requirement"]
91
- @locality = y["locality"]
92
- @admonition = y["admonition"]
93
- =end
94
45
  end
95
46
 
96
47
  def self.l10n(x, lang = @lang, script = @script)
@@ -115,6 +66,14 @@ module IsoDoc
115
66
  end
116
67
  end
117
68
 
69
+ def multiple_and(names, andword)
70
+ return '' if names.empty?
71
+ return names[0] if names.length == 1
72
+ (names.length == 2) &&
73
+ (return l10n("#{names[0]} #{andword} #{names[1]}", @lang, @script))
74
+ l10n(names[0..-2].join(', ') + " #{andword} #{names[-1]}", @lang, @script)
75
+ end
76
+
118
77
  #module_function :l10n
119
78
 
120
79
  end
@@ -4,11 +4,6 @@ require_relative './metadata_date'
4
4
 
5
5
  module IsoDoc
6
6
  class Metadata
7
- DATETYPES = %w{published accessed created implemented obsoleted confirmed
8
- updated issued received transmitted copied unchanged
9
- circulated vote-started
10
- vote-ended}.freeze
11
-
12
7
  attr_accessor :fonts_options
13
8
 
14
9
  def ns(xpath)
@@ -110,7 +105,7 @@ module IsoDoc
110
105
  name == 'International Organization for Standardization')
111
106
  end
112
107
 
113
- def agency(xml)
108
+ def agency1(xml)
114
109
  agency = ''
115
110
  publisher = []
116
111
  xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/"\
@@ -120,41 +115,48 @@ module IsoDoc
120
115
  publisher << name if name
121
116
  agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/"
122
117
  end
118
+ [agency, publisher]
119
+ end
120
+
121
+ def agency(xml)
122
+ agency, publisher = agency1(xml)
123
123
  set(:agency, agency.sub(%r{/$}, ''))
124
- set(:publisher, multiple_and(publisher, @labels['and']))
124
+ set(:publisher, @i18n.multiple_and(publisher, @labels['and']))
125
+ agency_addr(xml)
125
126
  end
126
127
 
127
- def multiple_and(names, andword)
128
- return '' if names.empty?
129
- return names[0] if names.length == 1
130
- (names.length == 2) &&
131
- (return l10n("#{names[0]} #{andword} #{names[1]}", @lang, @script))
132
- l10n(names[0..-2].join(', ') + " #{andword} #{names[-1]}", @lang, @script)
128
+ def agency_addr(xml)
129
+ a = xml.at(ns("//bibdata/contributor[xmlns:role/@type = 'publisher'][1]/"\
130
+ "organization")) or return
131
+ n = a.at(ns("./subdivision")) and set(:subdivision, n.text)
132
+ n = a.at(ns("./address/formattedAddress")) and
133
+ set(:pub_address, n.children.to_xml)
134
+ n = a.at(ns("./phone[not(@type = 'fax')]")) and set(:pub_phone, n.text)
135
+ n = a.at(ns("./phone[@type = 'fax']")) and set(:pub_fax, n.text)
136
+ n = a.at(ns("./email")) and set(:pub_email, n.text)
137
+ n = a.at(ns("./uri")) and set(:pub_uri, n.text)
133
138
  end
134
139
 
135
140
  def docstatus(isoxml, _out)
136
- docstatus = isoxml.at(ns('//bibdata/status/stage'))
137
141
  set(:unpublished, true)
138
- if docstatus
139
- docstatus_local = isoxml.at(ns('//local_bibdata/status/stage'))
140
- set(:stage, status_print(docstatus.text))
141
- docstatus_local and
142
- set(:stage_display, status_print(docstatus_local.text))
143
- (i = isoxml&.at(ns('//bibdata/status/substage'))&.text) &&
144
- set(:substage, i)
145
- (i = isoxml&.at(ns('//local_bibdata/status/substage'))&.text) &&
146
- set(:substage_display, i)
147
- (i = isoxml&.at(ns('//bibdata/status/iteration'))&.text) &&
148
- set(:iteration, i)
149
- set(:unpublished, unpublished(docstatus.text))
150
- unpublished(docstatus.text) &&
151
- set(:stageabbr, stage_abbr(docstatus.text))
152
- end
142
+ return unless docstatus = isoxml.at(ns('//bibdata/status/stage'))
143
+ docstatus_local = isoxml.at(ns('//local_bibdata/status/stage'))
144
+ set(:stage, status_print(docstatus.text))
145
+ docstatus_local and
146
+ set(:stage_display, status_print(docstatus_local.text))
147
+ (i = isoxml&.at(ns('//bibdata/status/substage'))&.text) &&
148
+ set(:substage, i)
149
+ (i = isoxml&.at(ns('//local_bibdata/status/substage'))&.text) &&
150
+ set(:substage_display, i)
151
+ (i = isoxml&.at(ns('//bibdata/status/iteration'))&.text) &&
152
+ set(:iteration, i)
153
+ set(:unpublished, unpublished(docstatus.text))
154
+ unpublished(docstatus.text) &&
155
+ set(:stageabbr, stage_abbr(docstatus.text))
153
156
  end
154
157
 
155
158
  def stage_abbr(docstatus)
156
- status_print(docstatus).split(/ /)
157
- .map { |s| s[0].upcase }.join('')
159
+ status_print(docstatus).split(/ /).map { |s| s[0].upcase }.join('')
158
160
  end
159
161
 
160
162
  def unpublished(status)
@@ -176,12 +178,10 @@ module IsoDoc
176
178
  end
177
179
 
178
180
  def draftinfo(draft, revdate)
179
- draftinfo = ''
180
- if draft
181
- draftinfo = " (#{@labels['draft_label']} #{draft}"
182
- draftinfo += ", #{revdate}" if revdate
183
- draftinfo += ')'
184
- end
181
+ return "" unless draft
182
+ draftinfo = " (#{@labels['draft_label']} #{draft}"
183
+ draftinfo += ", #{revdate}" if revdate
184
+ draftinfo += ')'
185
185
  l10n(draftinfo, @lang, @script)
186
186
  end
187
187
 
@@ -237,5 +237,13 @@ module IsoDoc
237
237
  isoxml.xpath(ns('//bibdata/keyword')).each { |kw| ret << kw.text }
238
238
  set(:keywords, ret)
239
239
  end
240
+
241
+ def note(isoxml, _out)
242
+ ret = []
243
+ isoxml.xpath(ns("//bibdata/note[@type = 'title-footnote']")).each do |n|
244
+ ret << n.text
245
+ end
246
+ set(:title_footnote, ret)
247
+ end
240
248
  end
241
249
  end
@@ -1,5 +1,10 @@
1
1
  module IsoDoc
2
2
  class Metadata
3
+ DATETYPES = %w{published accessed created implemented obsoleted confirmed
4
+ updated issued received transmitted copied unchanged
5
+ circulated vote-started
6
+ vote-ended}.freeze
7
+
3
8
  def months
4
9
  {
5
10
  "01": @labels["month_january"],
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.2.5".freeze
2
+ VERSION = "1.2.6".freeze
3
3
  end
@@ -23,6 +23,10 @@ module IsoDoc
23
23
  nil
24
24
  end
25
25
 
26
+ def pdf_options(docxml)
27
+ ""
28
+ end
29
+
26
30
  def convert(input_filename, file = nil, debug = false, output_filename = nil)
27
31
  file = File.read(input_filename, encoding: "utf-8") if file.nil?
28
32
  docxml, filename, dir = convert_init(file, input_filename, debug)
@@ -34,7 +38,8 @@ module IsoDoc
34
38
  FileUtils.rm_rf dir
35
39
  ::Metanorma::Output::XslfoPdf.new.convert(input_filename,
36
40
  output_filename || "#{filename}.#{@suffix}",
37
- File.join(@libdir, pdf_stylesheet(docxml)))
41
+ File.join(@libdir, pdf_stylesheet(docxml)),
42
+ pdf_options(docxml))
38
43
  end
39
44
 
40
45
  def xref_parse(node, out)
@@ -7,7 +7,7 @@ RSpec.describe IsoDoc do
7
7
  arr = c.convert_init(<<~"INPUT", "test", false)
8
8
  <iso-standard xmlns="http://riboseinc.com/isoxml">
9
9
  INPUT
10
- expect(Hash[c.info(Nokogiri::XML(<<~"INPUT"), nil).sort]).to be_equivalent_to <<~"OUTPUT"
10
+ expect(metadata(c.info(Nokogiri::XML(<<~"INPUT"), nil))).to be_equivalent_to <<~"OUTPUT"
11
11
  <iso-standard xmlns="http://riboseinc.com/isoxml">
12
12
  <bibdata type="standard">
13
13
  <title>The Incredible Mr Ripley</title>
@@ -73,6 +73,9 @@ RSpec.describe IsoDoc do
73
73
  </name>
74
74
  </person>
75
75
  </contributor>
76
+ <note type="title-footnote"><p>A footnote</p></note>
77
+ <note type="iso"><p>A note</p></note>
78
+ <note type="title-footnote"><p>Another footnote</p></note>
76
79
  <language>en</language>
77
80
  <script>Latn</script>
78
81
  <status>
@@ -125,13 +128,13 @@ INPUT
125
128
  :obsoleteddate=>"2014",
126
129
  :pdf=>"URL D",
127
130
  :publisheddate=>"2011",
128
- :publisher=>"",
129
131
  :receiveddate=>"XXX",
130
132
  :revdate=>"2016-05-01",
131
133
  :revdate_monthyear=>"May 2016",
132
134
  :stage=>"Committee Draft",
133
135
  :stageabbr=>"CD",
134
136
  :substage=>"Withdrawn",
137
+ :title_footnote=>["A footnote", "Another footnote"],
135
138
  :transmitteddate=>"2020",
136
139
  :unchangeddate=>"2019",
137
140
  :unpublished=>true,
@@ -148,7 +151,7 @@ OUTPUT
148
151
  arr = c.convert_init(<<~"INPUT", "test", false)
149
152
  <iso-standard xmlns="http://riboseinc.com/isoxml">
150
153
  INPUT
151
- expect(Hash[c.info(Nokogiri::XML(<<~"INPUT"), nil).sort]).to be_equivalent_to <<~"OUTPUT"
154
+ expect(metadata(c.info(Nokogiri::XML(<<~"INPUT"), nil))).to be_equivalent_to <<~"OUTPUT"
152
155
  <iso-standard xmlns="http://riboseinc.com/isoxml">
153
156
  <bibdata type="standard">
154
157
  <title language="fr" format="text/plain">Céréales et légumineuses</ti>
@@ -169,7 +172,15 @@ OUTPUT
169
172
  <role type="publisher"/>
170
173
  <organization>
171
174
  <name>International Organization for Standardization</name>
175
+ <subdivision>Subdivision</subdivision>
172
176
  <abbreviation>ISO</abbreviation>
177
+ <address>
178
+ <formattedAddress>1 Infinity Loop + California</formattedAddress>
179
+ </address>
180
+ <phone>3333333</phone>
181
+ <phone type='fax'>4444444</phone>
182
+ <email>x@example.com</email>
183
+ <uri>http://www.example.com</uri>
173
184
  </organization>
174
185
  </contributor>
175
186
  <contributor>
@@ -215,8 +226,6 @@ OUTPUT
215
226
  INPUT
216
227
  {:accesseddate=>"XXX",
217
228
  :agency=>"ISO/IEC/IEEE",
218
- :authors=>[],
219
- :authors_affiliations=>{},
220
229
  :circulateddate=>"XXX",
221
230
  :confirmeddate=>"XXX",
222
231
  :copieddate=>"XXX",
@@ -228,20 +237,24 @@ INPUT
228
237
  :docyear=>"2016",
229
238
  :draft=>"12",
230
239
  :draftinfo=>" (draft 12, 2016-05)",
231
- :edition=>nil,
232
240
  :implementeddate=>"XXX",
233
241
  :issueddate=>"XXX",
234
- :keywords=>[],
235
242
  :obsoleteddate=>"XXX",
236
243
  :obsoletes=>"IEC 8121",
237
244
  :obsoletes_part=>"3.1",
238
245
  :partof=>"IEC 8122",
246
+ :pub_address=>"1 Infinity Loop + California",
247
+ :pub_email=>"x@example.com",
248
+ :pub_fax=>"4444444",
249
+ :pub_phone=>"3333333",
250
+ :pub_uri=>"http://www.example.com",
239
251
  :publisheddate=>"2011-01",
240
252
  :publisher=>"International Organization for Standardization, International Electrotechnical Commission and Institute of Electrical and Electronics Engineers",
241
253
  :receiveddate=>"XXX",
242
254
  :revdate=>"2016-05",
243
255
  :revdate_monthyear=>"May 2016",
244
256
  :stage=>"Published",
257
+ :subdivision=>"Subdivision",
245
258
  :transmitteddate=>"XXX",
246
259
  :unchangeddate=>"XXX",
247
260
  :unpublished=>false,
@@ -261,7 +274,7 @@ OUTPUT
261
274
  </bibdata>
262
275
  </iso-standard>
263
276
  INPUT
264
- expect(Hash[c.info(Nokogiri::XML(<<~"INPUT"), nil).sort]).to be_equivalent_to <<~"OUTPUT"
277
+ expect(metadata(c.info(Nokogiri::XML(<<~"INPUT"), nil))).to be_equivalent_to <<~"OUTPUT"
265
278
  <iso-standard xmlns="http://riboseinc.com/isoxml">
266
279
  <bibdata type="standard">
267
280
  <title language="fr" format="text/plain">Céréales et légumineuses</ti>
@@ -308,8 +321,6 @@ OUTPUT
308
321
  INPUT
309
322
  {:accesseddate=>"XXX",
310
323
  :agency=>"ISO/IEC",
311
- :authors=>[],
312
- :authors_affiliations=>{},
313
324
  :circulateddate=>"XXX",
314
325
  :confirmeddate=>"XXX",
315
326
  :copieddate=>"XXX",
@@ -318,12 +329,8 @@ INPUT
318
329
  :docnumeric=>"17301",
319
330
  :doctitle=>"Cereals and pulses",
320
331
  :docyear=>"2016",
321
- :draft=>nil,
322
- :draftinfo=>"",
323
- :edition=>nil,
324
332
  :implementeddate=>"XXX",
325
333
  :issueddate=>"XXX",
326
- :keywords=>[],
327
334
  :obsoleteddate=>"XXX",
328
335
  :publisheddate=>"2011-01",
329
336
  :publisher=>"International Organization for Standardization et International Electrotechnical Commission",
@@ -29,6 +29,10 @@ def xmlpp(x)
29
29
  s
30
30
  end
31
31
 
32
+ def metadata(x)
33
+ Hash[x.sort].delete_if{ |k, v| v.nil? || v.respond_to?(:empty?) && v.empty? }
34
+ end
35
+
32
36
  def strip_guid(x)
33
37
  x.gsub(%r{ id="_[^"]+"}, ' id="_"').gsub(%r{ target="_[^"]+"}, ' target="_"').
34
38
  gsub(%r( href="#[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{13}"), ' href="#_"').
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-26 00:00:00.000000000 Z
11
+ date: 2020-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.1.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: relaton-cli
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rake
141
155
  requirement: !ruby/object:Gem::Requirement