relaton-ieee 1.14.4 → 1.14.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ae3fb426f6edd0288108dfa8f04d185703edad1cc448e16194dbe11b3a168a5
4
- data.tar.gz: 1671092867f6bb46fd019b508548684be0d59b9623aef2a99f9d877404fce901
3
+ metadata.gz: 00e27e5a5b433c742b68257cf7e5255e6ca00340ce418ce6abd8a25c01e7c45f
4
+ data.tar.gz: 36f8f46ba0a3f255b559b60e66abe396d72ce2bd6ef86641714be2ac38c48e3d
5
5
  SHA512:
6
- metadata.gz: 55a135e2ce29c648f475b82b9eac47bf80ca36e03262ffc3caf5de49c39e3c8fb39f349e1f37826cbebaf7a3bcc52219ab842b8d54f66f4c179ebdd9d40b8f22
7
- data.tar.gz: d4698b5437a3d4a93b2a51908dd2e2f936b76caafd6209bdb8fab3dd241e3e4232aae35fa0551692006c22b19228306241775ae5b4854c6272717a00acf527a1
6
+ metadata.gz: fef0694b4d753c8472a95dce28e2be839bc9a163ae1ae8b9737148f10dbb0b7ca30256d69a98d68e496b6672c773251f14242665c05abf1adf8f4c965bcce916
7
+ data.tar.gz: f02c71b8da934372620aeff7efd6d2c3ad22b6881209fe593d67bc15e9839cdc3b258eeb1b58868dee1658aea8bb67c4001230f5a7ff23cac2ffd2d36afab63d
@@ -522,7 +522,6 @@
522
522
  <value>tip</value>
523
523
  <value>important</value>
524
524
  <value>caution</value>
525
- <value>statement</value>
526
525
  </choice>
527
526
  </define>
528
527
  <define name="figure">
data/grammars/biblio.rng CHANGED
@@ -216,6 +216,9 @@
216
216
  <optional>
217
217
  <ref name="fullname"/>
218
218
  </optional>
219
+ <zeroOrMore>
220
+ <ref name="credential"/>
221
+ </zeroOrMore>
219
222
  <zeroOrMore>
220
223
  <ref name="affiliation"/>
221
224
  </zeroOrMore>
@@ -232,6 +235,11 @@
232
235
  <ref name="FullNameType"/>
233
236
  </element>
234
237
  </define>
238
+ <define name="credential">
239
+ <element name="credential">
240
+ <text/>
241
+ </element>
242
+ </define>
235
243
  <define name="FullNameType">
236
244
  <choice>
237
245
  <group>
@@ -305,7 +313,9 @@
305
313
  <zeroOrMore>
306
314
  <ref name="affiliationdescription"/>
307
315
  </zeroOrMore>
308
- <ref name="organization"/>
316
+ <optional>
317
+ <ref name="organization"/>
318
+ </optional>
309
319
  </element>
310
320
  </define>
311
321
  <define name="affiliationname">
@@ -1316,7 +1326,7 @@
1316
1326
  <value>commentaryOf</value>
1317
1327
  <value>hasCommentary</value>
1318
1328
  <value>related</value>
1319
- <value>complements</value>
1329
+ <value>hasComplement</value>
1320
1330
  <value>complementOf</value>
1321
1331
  <value>obsoletes</value>
1322
1332
  <value>obsoletedBy</value>
@@ -97,13 +97,8 @@ module RelatonIeee
97
97
  return
98
98
  end
99
99
  stdid = doc.at("./publicationinfo/standard_id")&.text
100
- if stdid == "0"
101
- # nt = doc&.at("./normtitle")&.text
102
- # ntid = @normtitles.index nt
103
- # @normtitles << nt if nt && !ntid
104
- # warn "Zero standard_id in #{filename}"
105
- return
106
- end
100
+ return if stdid == "0"
101
+
107
102
  bib = DataParser.parse doc, self
108
103
  if bib.docnumber.nil?
109
104
  nt = doc&.at("./normtitle")&.text
@@ -2,6 +2,11 @@ module RelatonIeee
2
2
  class DataParser
3
3
  DATETYPES = { "OriginalPub" => "created", "ePub" => "published",
4
4
  "LastInspecUpd" => "updated" }.freeze
5
+ ATTRS = %i[
6
+ docnumber title date docid contributor abstract copyright docstatus
7
+ relation link keyword ics editorialgroup standard_status standard_modifier
8
+ pubstatus holdstatus doctype
9
+ ].freeze
5
10
 
6
11
  attr_reader :doc, :fetcher
7
12
 
@@ -33,25 +38,9 @@ module RelatonIeee
33
38
  #
34
39
  # @return [RelatonIeee::IeeeBibliographicItem]
35
40
  #
36
- def parse # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
37
- args = {
38
- type: "standard",
39
- docnumber: docnumber,
40
- title: parse_title,
41
- date: parse_date,
42
- docid: parse_docid,
43
- contributor: parse_contributor,
44
- abstract: parse_abstract,
45
- copyright: parse_copyright,
46
- language: ["en"],
47
- script: ["Latn"],
48
- docstatus: parse_status,
49
- relation: parse_relation,
50
- link: parse_link,
51
- keyword: parse_keyword,
52
- ics: parse_ics,
53
- editorialgroup: parse_editorialgroup,
54
- }
41
+ def parse
42
+ args = { type: "standard", language: ["en"], script: ["Latn"] }
43
+ ATTRS.each { |attr| args[attr] = send("parse_#{attr}") }
55
44
  IeeeBibliographicItem.new(**args)
56
45
  end
57
46
 
@@ -142,6 +131,10 @@ module RelatonIeee
142
131
  end
143
132
  end
144
133
 
134
+ def parse_docnumber
135
+ docnumber
136
+ end
137
+
145
138
  #
146
139
  # Parse docnumber
147
140
  #
@@ -227,16 +220,13 @@ module RelatonIeee
227
220
  #
228
221
  # Parse status
229
222
  #
230
- # @return [RelatonBib::DocumentStatus]
223
+ # @return [RelatonIee::DocumentStatus, nil]
231
224
  #
232
- def parse_status
233
- st = doc.at("./publicationinfo/standard_status").text.downcase
234
- stage = case st
235
- when "active" then "approved"
236
- when "inactive" then "withdrawn"
237
- else st
238
- end
239
- DocumentStatus.new stage: stage
225
+ def parse_docstatus
226
+ st = parse_standard_modifier
227
+ return unless %w[Draft Approved Superseded Withdrawn].include?(st)
228
+
229
+ DocumentStatus.new stage: st.downcase
240
230
  end
241
231
 
242
232
  #
@@ -250,7 +240,7 @@ module RelatonIeee
250
240
  if (ref = fetcher.backrefs[r.text])
251
241
  rel = fetcher.create_relation(r[:type], ref)
252
242
  rels << rel if rel
253
- elsif !/Inactive Date/.match?(r) && docnumber
243
+ elsif !"Inactive Date".include?(r) && docnumber
254
244
  fetcher.add_crossref(docnumber, r)
255
245
  end
256
246
  end
@@ -302,5 +292,50 @@ module RelatonIeee
302
292
  ).map &:text
303
293
  EditorialGroup.new committee: committee if committee.any?
304
294
  end
295
+
296
+ #
297
+ # Parse standard status
298
+ #
299
+ # @return [String, nil] standard status or nil
300
+ #
301
+ def parse_standard_status
302
+ doc.at("./publicationinfo/standard_status")&.text
303
+ end
304
+
305
+ #
306
+ # Parse standard modifier
307
+ #
308
+ # @return [String, nil] standard modifier or nil
309
+ #
310
+ def parse_standard_modifier
311
+ doc.at("./publicationinfo/standardmodifierset/standard_modifier")&.text
312
+ end
313
+
314
+ #
315
+ # Parse pubstatus
316
+ #
317
+ # @return [String, nil] pubstatus or nil
318
+ #
319
+ def parse_pubstatus
320
+ doc.at("./publicationinfo/pubstatus")&.text
321
+ end
322
+
323
+ #
324
+ # Pasrse holdstatus
325
+ #
326
+ # @return [String, nil] holdstatus or nil
327
+ #
328
+ def parse_holdstatus
329
+ doc.at("./publicationinfo/holdstatus")&.text
330
+ end
331
+
332
+ #
333
+ # Parse doctype
334
+ #
335
+ # @return [String] doctype
336
+ #
337
+ def parse_doctype
338
+ parse_standard_modifier == "Redline" ? "redline" : "standard"
339
+ end
305
340
  end
306
341
  end
@@ -4,13 +4,14 @@ module RelatonIeee
4
4
  # @param args [Hash]
5
5
  # @param neated [TrueClas, FalseClass] default true
6
6
  # @return [Hash]
7
- # def hash_to_bib(args)
8
- # hash = super
9
- # return nil unless hash.is_a?(Hash)
7
+ def hash_to_bib(args)
8
+ hash = super
9
+ return unless hash.is_a?(Hash)
10
10
 
11
- # editorialgroup_hash_to_bib hash
12
- # hash
13
- # end
11
+ # editorialgroup_hash_to_bib hash
12
+ ext_hash_to_bib hash
13
+ hash
14
+ end
14
15
 
15
16
  # @param item_hash [Hash]
16
17
  # @return [RelatonIeee::IeeeBibliographicItem]
@@ -24,6 +25,16 @@ module RelatonIeee
24
25
 
25
26
  hash[:editorialgroup] = EditorialGroup.new(**hash[:editorialgroup])
26
27
  end
28
+
29
+ def ext_hash_to_bib(hash)
30
+ ext = hash.delete(:ext)
31
+ return unless ext
32
+
33
+ attrs = %i[standard_status standard_modifier pubstatus holdstatus]
34
+ ext.select { |k, _| attrs.include? k }.each do |k, v|
35
+ hash[k] = v
36
+ end
37
+ end
27
38
  end
28
39
  end
29
40
  end
@@ -1,6 +1,6 @@
1
1
  module RelatonIeee
2
2
  class IeeeBibliographicItem < RelatonBib::BibliographicItem
3
- TYPES = %w[guide recommended-practice standard].freeze
3
+ DOCTYPES = %w[guide recommended-practice standard witepaper redline other].freeze
4
4
  SUBTYPES = %w[amendment corrigendum erratum].freeze
5
5
 
6
6
  # @return [RelatonIeee::EditorialGroup, nil]
@@ -9,16 +9,24 @@ module RelatonIeee
9
9
  # @return [Boolean, nil] Trial use
10
10
  attr_reader :trialuse
11
11
 
12
+ # @return [String, nil]
13
+ attr_reader :standard_status, :standard_modifier, :pubstatus, :holdstatus
14
+
12
15
  #
13
16
  # @param [Hash] args
14
17
  # @option args [Boolean, nil] :trialuse Trial use
15
18
  # @option args [Array<RelatonIeee::EditorialGroup>] :editorialgroup
16
19
  # Editorial group
20
+ # @option args [String, nil] :standard_status Active, Inactive, Superseded
21
+ # @option args [String, nil] :standard_modifier Draft, Withdrawn, Suspended,
22
+ # Approved, Reserved, Redline
23
+ # @option args [String, nil] :pubstatus Active, Inactive
24
+ # @option args [String, nil] :holdstatus Held, Publish
17
25
  #
18
26
  def initialize(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
19
- if args[:doctype] && !TYPES.include?(args[:doctype])
27
+ if args[:doctype] && !DOCTYPES.include?(args[:doctype])
20
28
  warn "[relaton-ieee] invalid doctype \"#{args[:doctype]}\". " \
21
- "It should be one of: #{TYPES.join(', ')}."
29
+ "It should be one of: #{DOCTYPES.join(', ')}."
22
30
  end
23
31
  if args[:docsubtype] && !SUBTYPES.include?(args[:docsubtype])
24
32
  warn "[relaton-ieee] invalid docsubtype \"#{args[:docsubtype]}\". " \
@@ -26,6 +34,10 @@ module RelatonIeee
26
34
  end
27
35
  eg = args.delete(:editorialgroup)
28
36
  @trialuse = args.delete(:trialuse)
37
+ @standard_status = args.delete(:standard_status)
38
+ @standard_modifier = args.delete(:standard_modifier)
39
+ @pubstatus = args.delete(:pubstatus)
40
+ @holdstatus = args.delete(:holdstatus)
29
41
  super
30
42
  @editorialgroup = eg
31
43
  end
@@ -53,13 +65,18 @@ module RelatonIeee
53
65
  # @return [String] XML
54
66
  def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
55
67
  super(**opts) do |bldr|
56
- if opts[:bibdata] && (doctype || subdoctype || !trialuse.nil? || editorialgroup || ics.any?)
68
+ if opts[:bibdata] && (doctype || subdoctype || !trialuse.nil? || editorialgroup ||
69
+ ics.any? || standard_status || standard_modifier || pubstatus || holdstatus)
57
70
  ext = bldr.ext do |b|
58
71
  b.doctype doctype if doctype
59
72
  b.subdoctype subdoctype if subdoctype
60
73
  b.send :"trial-use", trialuse unless trialuse.nil?
61
74
  editorialgroup&.to_xml(b)
62
75
  ics.each { |ic| ic.to_xml(b) }
76
+ b.standard_status standard_status if standard_status
77
+ b.standard_modifier standard_modifier if standard_modifier
78
+ b.pubstatus pubstatus if pubstatus
79
+ b.holdstatus holdstatus if holdstatus
63
80
  end
64
81
  ext["schema-version"] = ext_schema unless opts[:embedded]
65
82
  end
@@ -73,9 +90,13 @@ module RelatonIeee
73
90
  #
74
91
  # @return [Hash]
75
92
  #
76
- def to_hash(embedded: false)
93
+ def to_hash(embedded: false) # rubocop:disable Metrics/AbcSize
77
94
  hash = super
78
95
  hash["trialuse"] = trialuse unless trialuse.nil?
96
+ hash["ext"]["standard_status"] = standard_status unless standard_status.nil?
97
+ hash["ext"]["standard_modifier"] = standard_modifier unless standard_modifier.nil?
98
+ hash["ext"]["pubstatus"] = pubstatus unless pubstatus.nil?
99
+ hash["ext"]["holdstatus"] = holdstatus unless holdstatus.nil?
79
100
  hash
80
101
  end
81
102
 
@@ -1,3 +1,3 @@
1
1
  module RelatonIeee
2
- VERSION = "1.14.4".freeze
2
+ VERSION = "1.14.5".freeze
3
3
  end
@@ -6,12 +6,16 @@ module RelatonIeee
6
6
  # Override RelatonBib::XMLParser.item_data method.
7
7
  # @param item [Nokogiri::XML::Element]
8
8
  # @returtn [Hash]
9
- def item_data(item)
9
+ def item_data(item) # rubocop:disable Metrics/AbcSize
10
10
  data = super
11
11
  ext = item.at "./ext"
12
12
  return data unless ext
13
13
 
14
14
  data[:editorialgroup] = parse_editorialgroup(item)
15
+ data[:standard_status] = ext.at("./standard_status")&.text
16
+ data[:standard_modifier] = ext.at("./standard_modifier")&.text
17
+ data[:pubstatus] = ext.at("./pubstatus")&.text
18
+ data[:holdstatus] = ext.at("./holdstatus")&.text
15
19
  data
16
20
  end
17
21
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-ieee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.4
4
+ version: 1.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-17 00:00:00.000000000 Z
11
+ date: 2023-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml