relaton-iec 1.7.8 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +1 -11
  3. data/.rubocop.yml +3 -1
  4. data/README.adoc +23 -0
  5. data/grammars/basicdoc.rng +191 -27
  6. data/grammars/biblio.rng +12 -11
  7. data/grammars/iec.rng +144 -1
  8. data/grammars/isodoc.rng +1156 -112
  9. data/grammars/isostandard.rng +69 -115
  10. data/grammars/reqt.rng +65 -7
  11. data/lib/relaton_iec/basic_block/alignment.rb +30 -0
  12. data/lib/relaton_iec/basic_block/basic_block.rb +15 -0
  13. data/lib/relaton_iec/basic_block/citation_type.rb +32 -0
  14. data/lib/relaton_iec/basic_block/dl.rb +60 -0
  15. data/lib/relaton_iec/basic_block/eref.rb +10 -0
  16. data/lib/relaton_iec/basic_block/eref_type.rb +39 -0
  17. data/lib/relaton_iec/basic_block/formula.rb +34 -0
  18. data/lib/relaton_iec/basic_block/image.rb +41 -0
  19. data/lib/relaton_iec/basic_block/index.rb +27 -0
  20. data/lib/relaton_iec/basic_block/index_xref.rb +31 -0
  21. data/lib/relaton_iec/basic_block/note.rb +21 -0
  22. data/lib/relaton_iec/basic_block/paragraph.rb +27 -0
  23. data/lib/relaton_iec/basic_block/paragraph_with_footnote.rb +29 -0
  24. data/lib/relaton_iec/basic_block/reference_format.rb +38 -0
  25. data/lib/relaton_iec/basic_block/stem.rb +30 -0
  26. data/lib/relaton_iec/basic_block/table.rb +115 -0
  27. data/lib/relaton_iec/basic_block/text_element.rb +27 -0
  28. data/lib/relaton_iec/hit_collection.rb +1 -1
  29. data/lib/relaton_iec/iec_bibliographic_item.rb +86 -1
  30. data/lib/relaton_iec/scrapper.rb +18 -17
  31. data/lib/relaton_iec/tc_sc_officers_note.rb +24 -0
  32. data/lib/relaton_iec/version.rb +1 -1
  33. data/lib/relaton_iec/xml_parser.rb +20 -0
  34. data/relaton_iec.gemspec +2 -4
  35. metadata +23 -5
@@ -0,0 +1,27 @@
1
+ module BasicBlock
2
+ class Index
3
+ #
4
+ # @param [Array<BasicBlock::TextElement] primary
5
+ # @param [Hash] args
6
+ # @option args [String, nil] :to
7
+ # @option args [Array<BasicBlock::TextElement>, nil] :secondary
8
+ # @option args [Array<BasicBlock::TextElement>, nil] :tertiary
9
+ #
10
+ def initialize(primary:, **args)
11
+ @to = args[:to]
12
+ @primary = primary
13
+ @secondary = args[:secondary]
14
+ @tertiary = args[:tertiary]
15
+ end
16
+
17
+ # @param [Nokogiri::XML::Builder] builder
18
+ def to_xml(builder) # rubocop:disable Metrics/CyclomaticComplexity
19
+ idx = builder.index do |b|
20
+ @primary.each { |p| p.to_xml b }
21
+ @secondary&.each { |s| s.to_xml b }
22
+ @tertiary&.each { |t| t.to_xml b }
23
+ end
24
+ idx[:to] = @to if @to
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,31 @@
1
+ module BasicBlock
2
+ class IndexXref
3
+ #
4
+ # @param [Boolean] also
5
+ # @param [Array<BasicBlock::TextElement>] primary
6
+ # @param [Array<BasicBlock::TextElement>] target
7
+ # @param [Hash] args
8
+ # @option args [Array<BasicBlock::TextElement>, nil] secondary
9
+ # @option args [Array<BasicBlock::TextElement>, nil] tertiary
10
+ #
11
+ def initialize(also:, primary:, target:, **args)
12
+ @also = also
13
+ @primary = primary
14
+ @target = target
15
+ @secondary = args[:secondary]
16
+ @tertiary = args[:tertiary]
17
+ end
18
+
19
+ #
20
+ # @param [Nokogiri::XML::Builder] builder
21
+ #
22
+ def to_xml(builder) # rubocop:disable Metrics/CyclomaticComplexity
23
+ builder.send "index-xref", also: @also do |b|
24
+ @primary.each { |p| p.to_xml b }
25
+ @secondary&.each { |s| s.to_xml b }
26
+ @tertiary&.each { |t| t.to_xml b }
27
+ @target.each { |t| t.to_xml b }
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,21 @@
1
+ module BasicBlock
2
+ class Note
3
+ #
4
+ # @param [String] id
5
+ # @param [Array<BasicBlock::Paragraph>] content
6
+ #
7
+ def initialize(id:, content:)
8
+ @id = id
9
+ @contain = content
10
+ end
11
+
12
+ #
13
+ # @param [Nokogiei::XMO::Builder] builder
14
+ #
15
+ def to_xml(builder)
16
+ builder.note id: @id do |b|
17
+ @content.each { |c| c.to_xm b }
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ module BasicBlock
2
+ class Paragraph
3
+ #
4
+ # @param [String] id
5
+ # @param [Array<BasicBlock::TextElement>] content
6
+ # @param [Array<BasicBlock::Note>] note
7
+ # @param [BasicBlock::Alignment, nil] align
8
+ #
9
+ def initialize(id:, content:, note:, align: nil)
10
+ @id = id
11
+ @content = content
12
+ @note = note
13
+ @align = align
14
+ end
15
+ end
16
+
17
+ #
18
+ # @param [Nokogiri::XML::Builder] builder
19
+ #
20
+ def to_xml(builder)
21
+ p = builder.p id: @id do |b|
22
+ @content.each { |c| c.to_xml b }
23
+ @note.each { |n| n.to_xml b }
24
+ end
25
+ p[:align] = @align if @align
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ module BasicBlock
2
+ class ParagraphWithFootnote
3
+ #
4
+ # @param [String] id
5
+ # @param [Hash] args
6
+ # @param [BasicBlock::Alignment, nil] align
7
+ # @param [Array<BasicBlock::TextElement, BasicBlock::Eref, BasicBlock::Stem,
8
+ # BasicBlock::Image, BasicBlock::Index, BasicBlock::IndexXref>] content
9
+ # @param [Array<RelatonIec::Note>] note
10
+ #
11
+ def initialize(id:, align: nil, content: [], note: [])
12
+ @id = id
13
+ @aligments = align
14
+ @content = content
15
+ @note = note
16
+ end
17
+
18
+ #
19
+ # @param [Nokogiri::XML::Builder] builder
20
+ #
21
+ def to_xml(builder)
22
+ elm = builder.p(@id) do |b|
23
+ @content.each { |te| te.to_xml b }
24
+ @note.each { |n| n.to_xml b }
25
+ end
26
+ elm[:align] = @align if @align
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,38 @@
1
+ module RelatonIec
2
+ def self.respond_to_missing?(method, _include_private)
3
+ method == "ReferenceFormat"
4
+ end
5
+
6
+ def self.method_missing(_method, *args)
7
+ ReferenceFormat.new *args
8
+ end
9
+
10
+ class ReferenceFormat
11
+ FORMATS = %w[external inline footnote callout].freeze
12
+
13
+ #
14
+ # @param [String] format
15
+ #
16
+ def initialize(format)
17
+ unless FORMATS.include? format
18
+ warn "[relaton-iec] WARNING: invalid reference format \"#{format}\""
19
+ warn "[relaton-iec] alloved reference formats are: #{FORMATS.join ', '}"
20
+ end
21
+ @format = format
22
+ end
23
+
24
+ #
25
+ # @return [String]
26
+ #
27
+ def to_s
28
+ @format
29
+ end
30
+
31
+ #
32
+ # @return [Sting] <description>
33
+ #
34
+ def inspect
35
+ to_s
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,30 @@
1
+ module BasicBlock
2
+ class Stem
3
+ TYPES = %w[MathML AsciiMath].freeze
4
+
5
+ # @return [String]
6
+ attr_reader :type
7
+
8
+ #
9
+ # @param [String] type
10
+ # @param [Array<#to_xml>] content any element
11
+ #
12
+ def initialize(type:, content: [])
13
+ unless TYPES.include? type
14
+ warn "[relaton-iec] WARNING: invalud type \"#{type}\""
15
+ warn "[relaton-iec] allowed types are: #{TYPES.join ', '}"
16
+ end
17
+ @type = type
18
+ @content = content
19
+ end
20
+
21
+ #
22
+ # @param [Nokogiri::XML::Builder] builder
23
+ #
24
+ def to_xml(builder)
25
+ builder.stem(type) do |b|
26
+ content.each { |c| c.to_xml b }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,115 @@
1
+ module BasicBlock
2
+ class Table
3
+ #
4
+ # @param [String] id
5
+ # @param [Array<BasicBlock::Tr>] tbody
6
+ # @param [Array<BasicBlock::Paragraph>] note
7
+ # @param [Hash] args
8
+ # @option args [Boolean, nil] :unnumbered
9
+ # @option args [String, nil] :subsequence
10
+ # @option args [String, nil] :alt
11
+ # @option args [String, nil] :summary
12
+ # @option args [String, nil] :uri
13
+ # @option args [BasicBlock::TextElement, nil] :tname
14
+ # @option args [BasicBlock::Table::Tr, nil] :thead
15
+ # @option args [BasicBlock::TextElement, nil] :tfoot
16
+ # @option args [BasicBlock::Dl, nil] :dl
17
+ #
18
+ def initialize(id:, tbody:, note:, **args) # rubocop:disable Metrics/MethodLength
19
+ @id = id
20
+ @unnumbered = args[:unnumbered]
21
+ @subsequence = args[:subsequence]
22
+ @alt = args[:alt]
23
+ @summary = args[:summary]
24
+ @uri = args[:uri]
25
+ @tname = args[:tname]
26
+ @thead = args[:thead]
27
+ @tbody = tbody
28
+ @tfoot = args[:tfoot]
29
+ @note = note
30
+ @dl = args[:dl]
31
+ end
32
+
33
+ # @param [Nokogiri::XML::Builder] builder
34
+ def to_xml(builder) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
35
+ tab = builder.table id: @id do |b|
36
+ b.name { @tname.to_xml b } if @tname
37
+ b.thead { @thead.to_xml b } if @thead
38
+ @tbody.each { |tb| tb.to_xml b }
39
+ b.name { @tfoot.to_xml b } if @tfoot
40
+ @note.each { |n| b.note { n.to_xml b } }
41
+ @dl.to_xml b
42
+ end
43
+ tab[:unnumbered] = @unnumbered if @unnumbered
44
+ tab[:subsequence] = @subsequence if @subsequence
45
+ tab[:alt] = @alt if @alt
46
+ tab[:summary] = @summary if @summary
47
+ tab[:uri] = @uri if @uri
48
+ end
49
+
50
+ class Tr
51
+ # @param [Array<BasicBlock::Table::Td, BasicBlock::Table::Th>] content
52
+ def initialize(content)
53
+ @content = content
54
+ end
55
+
56
+ # @param [Nokogiri::XML::Builder] builder
57
+ def to_xml(builder)
58
+ builder.tr do |b|
59
+ @content.each { |c| c.to_xm b }
60
+ end
61
+ end
62
+ end
63
+
64
+ class TabCell
65
+ ALIGNS = %w[left right ceter].freeze
66
+ VALIGNS = %w[top middle bottom baseline].freeze
67
+
68
+ # @param [Array<BasicBlock::TextElement,
69
+ # BasicBlock::ParagraphWithFootnote>] content
70
+ # @param [Hssh] args
71
+ # @option args [String, nil] :colspan
72
+ # @option args [String, nil] :rowspan
73
+ # @option args [String, nil] :align
74
+ # @option args [String, nil] :valign
75
+ def initialize(content, **args) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
76
+ if args[:align] && !ALIGNS.include?(args[:align])
77
+ warn "[basic-block] WARNING: invalid table/tr/td align \"#{args[:align]}\""
78
+ warn "[basic-block] alloved aligns are: #{ALIGNS.join ', '}"
79
+ end
80
+ if args[:valign] && !VALIGNS.include?(args[:valign])
81
+ warn "[basic-block] WARNING: invalid table/tr/td valign \"#{args[:valign]}\""
82
+ warn "[basic-block] alloved valigns are: #{VALIGNS.join ', '}"
83
+ end
84
+ @content = content
85
+ @colspan = args[:colspan]
86
+ @rowspan = args[:rowspan]
87
+ @align = args[:align]
88
+ @valign = args[:valign]
89
+ end
90
+
91
+ # @param [Nokogiri::XML::Builder] builder
92
+ def to_xml(builder)
93
+ td = @content.each { |c| c.to_xml builder }
94
+ td[:colspan] = @colspan if @colspan
95
+ td[:rowspan] = @rowspan if @rowspan
96
+ td[:align] = @align if @align
97
+ td[:valign] = @valign if @valign
98
+ end
99
+ end
100
+
101
+ class Td < BasicBlock::Table::TabCell
102
+ # @param [Nokogiri::XML::Builder] builder
103
+ def to_xml(builder)
104
+ builder.th { super }
105
+ end
106
+ end
107
+
108
+ class Th < BasicBlock::Table::TabCell
109
+ # @param [Nokogiri::XML::Builder] builder
110
+ def to_xml(builder)
111
+ builder.td { super }
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,27 @@
1
+ module BasicBlock
2
+ class TextElement
3
+ TAGS = %w[em strong sub sup tt underline strike smallcap br hr keyword rp
4
+ rt ruby pagebreak bookmark].freeze
5
+
6
+ #
7
+ # @param [String] tag
8
+ # @param [Array<String, BasicBlock::TextElement, BasicBlock::Stem>,
9
+ # String] content
10
+ #
11
+ def initialize(tag:, content:)
12
+ unless TAGS.include? tag
13
+ warn "[basic-block] WARNING: invalid tag \"#{tag}\""
14
+ warn "[basic-block] allowed tags are: #{TAGS.join ', '}"
15
+ end
16
+ @tag = tag
17
+ @content = content
18
+ end
19
+
20
+ # @param [Nokogiri::XML::Builder]
21
+ def to_xml(builder)
22
+ builder.send @tag do |b|
23
+ @content.each { |c| c.is_a?(String) ? c : c.to_xml(b) }
24
+ end
25
+ end
26
+ end
27
+ end
@@ -25,7 +25,7 @@ module RelatonIec
25
25
  def to_all_parts # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity
26
26
  parts = @array.reject { |h| h.part.nil? }
27
27
  hit = parts.min_by &:part
28
- return @array.first.fetch lang unless hit
28
+ return @array.first&.fetch unless hit
29
29
 
30
30
  bibitem = hit.fetch
31
31
  all_parts_item = bibitem.to_all_parts
@@ -3,14 +3,99 @@ module RelatonIec
3
3
  TYPES = %w[
4
4
  international-standard technical-specification technical-report
5
5
  publicly-available-specification international-workshop-agreement
6
- guide
6
+ guide industry-technical-agreement
7
7
  ].freeze
8
8
 
9
+ FUNCTION = %w[emc safety enviroment quality-assurance].freeze
10
+
11
+ # @return [String, nil]
12
+ attr_reader :function, :updates_document_type, :price_code, :secretary,
13
+ :interest_to_committees
14
+
15
+ # @return [Boolean, nil]
16
+ attr_reader :accessibility_color_inside, :cen_processing
17
+
18
+ # attr_reader :tc_sc_officers_note
19
+
20
+ def initialize(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
21
+ if args[:function] && !FUNCTION.include?(args[:function])
22
+ warn "[relaton-iec] WARNING: invalid function \"#{args[:function]}\""
23
+ warn "[relaton-iec] allowed function values are: #{FUNCTION.join(', ')}"
24
+ end
25
+ if args[:updates_document_type] &&
26
+ !TYPES.include?(args[:updates_document_type])
27
+ warn "[relaton-iec] WARNING: invalid updates_document_type "\
28
+ "\"#{args[:updates_document_type]}\""
29
+ warn "[relaton-iec] allowed updates_document_type values are: "\
30
+ "#{TYPES.join(', ')}"
31
+ end
32
+ @function = args.delete :function
33
+ @updates_document_type = args.delete :updates_document_type
34
+ @accessibility_color_inside = args.delete :accessibility_color_inside
35
+ @price_code = args.delete :price_code
36
+ @cen_processing = args.delete :cen_processing
37
+ @secretary = args.delete :secretary
38
+ @interest_to_committees = args.delete :interest_to_committees
39
+ super
40
+ end
41
+
9
42
  # @param hash [Hash]
10
43
  # @return [RelatonIsoBib::IecBibliographicItem]
11
44
  def self.from_hash(hash)
12
45
  item_hash = ::RelatonIec::HashConverter.hash_to_bib(hash)
13
46
  new **item_hash
14
47
  end
48
+
49
+ # @param opts [Hash]
50
+ # @option opts [Nokogiri::XML::Builder] :builder XML builder
51
+ # @option opts [Boolean] :bibdata
52
+ # @option opts [String] :lang language
53
+ # @return [String] XML
54
+ def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
55
+ super **opts do |b|
56
+ if opts[:bibdata]
57
+ b.ext do
58
+ b.doctype doctype if doctype
59
+ b.horizontal horizontal unless horizontal.nil?
60
+ b.function function if function
61
+ editorialgroup&.to_xml b
62
+ ics.each { |i| i.to_xml b }
63
+ structuredidentifier&.to_xml b
64
+ b.stagename stagename if stagename
65
+ if updates_document_type
66
+ b.send("updates-document-type", updates_document_type)
67
+ end
68
+ unless accessibility_color_inside.nil?
69
+ b.send("accessibility-color-inside", accessibility_color_inside)
70
+ end
71
+ b.send("price-code", price_code) if price_code
72
+ b.send("cen-processing", cen_processing) unless cen_processing.nil?
73
+ b.secretary secretary if secretary
74
+ if interest_to_committees
75
+ b.send("interest-to-committees", interest_to_committees)
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ # @return [Hash]
83
+ def to_hash # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
84
+ hash = super
85
+ hash["function"] = function if function
86
+ if updates_document_type
87
+ hash["updates_document_type"] = updates_document_type
88
+ end
89
+ unless accessibility_color_inside.nil?
90
+ hash["accessibility_color_inside"] = accessibility_color_inside
91
+ end
92
+ hash["price_code"] = price_code if price_code
93
+ hash["cen_processing"] = cen_processing unless cen_processing.nil?
94
+ hash["secretary"] = secretary if secretary
95
+ if interest_to_committees
96
+ hash["interest_to_committees"] = interest_to_committees
97
+ end
98
+ hash
99
+ end
15
100
  end
16
101
  end
@@ -9,6 +9,11 @@ module RelatonIec
9
9
  # Scrapper.
10
10
  module Scrapper
11
11
  DOMAIN = "https://webstore.iec.ch"
12
+ ABBREVS = {
13
+ "ISO" => ["International Organization for Standardization", "www.iso.org"],
14
+ "IEC" => ["International Electrotechnical Commission", "www.iec.ch"],
15
+ "CISPR" => ["International special committee on radio interference", "www.iec.ch"],
16
+ }.freeze
12
17
 
13
18
  TYPES = {
14
19
  "ISO" => "international-standard",
@@ -36,7 +41,7 @@ module RelatonIec
36
41
 
37
42
  # Fetch edition.
38
43
  edition = doc.at(
39
- "//th[contains(., 'Edition')]/following-sibling::td/span"
44
+ "//th[contains(., 'Edition')]/following-sibling::td/span",
40
45
  ).text
41
46
 
42
47
  status, relations = fetch_status_relations hit_data[:url]
@@ -59,7 +64,7 @@ module RelatonIec
59
64
  copyright: fetch_copyright(hit_data[:code], doc),
60
65
  link: fetch_link(doc, hit_data[:url]),
61
66
  relation: relations,
62
- place: ["Geneva"]
67
+ place: ["Geneva"],
63
68
  )
64
69
  end
65
70
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
@@ -71,7 +76,7 @@ module RelatonIec
71
76
  def fetch_docid(hit)
72
77
  urn = RelatonIec.code_to_urn hit[:code], "en"
73
78
  [
74
- RelatonBib::DocumentIdentifier.new(id: hit[:code], type: "IEC"),
79
+ RelatonBib::DocumentIdentifier.new(id: hit[:code], type: "IEC", primary: true),
75
80
  RelatonBib::DocumentIdentifier.new(id: urn, type: "URN"),
76
81
  ]
77
82
  end
@@ -121,12 +126,12 @@ module RelatonIec
121
126
  item_ref = doc.at("//span[@itemprop='productID']")
122
127
  unless item_ref
123
128
  return RelatonIsoBib::StructuredIdentifier.new(
124
- project_number: "?", part_number: "", prefix: nil, id: "?"
129
+ project_number: "?", part_number: "", prefix: nil, id: "?",
125
130
  )
126
131
  end
127
132
 
128
133
  m = item_ref.text.match(
129
- /(?<=\s)(?<project>\d+)-?(?<part>(?<=-)\d+|)-?(?<subpart>(?<=-)\d+|)/
134
+ /(?<=\s)(?<project>\d+)-?(?<part>(?<=-)\d+|)-?(?<subpart>(?<=-)\d+|)/,
130
135
  )
131
136
  RelatonIsoBib::StructuredIdentifier.new(
132
137
  project_number: m[:project],
@@ -134,7 +139,7 @@ module RelatonIec
134
139
  subpart_number: m[:subpart],
135
140
  prefix: nil,
136
141
  type: "IEC",
137
- id: item_ref.text
142
+ id: item_ref.text,
138
143
  )
139
144
  end
140
145
 
@@ -190,7 +195,7 @@ module RelatonIec
190
195
  else r_type
191
196
  end
192
197
  fref = RelatonBib::FormattedRef.new(
193
- content: r.at("FULL_NAME").text, format: "text/plain"
198
+ content: r.at("FULL_NAME").text, format: "text/plain",
194
199
  )
195
200
  bibitem = IecBibliographicItem.new(formattedref: fref)
196
201
  { type: type, bibitem: bibitem }
@@ -199,8 +204,8 @@ module RelatonIec
199
204
 
200
205
  def fetch_status_relations(url)
201
206
  pubid = url.match(/\d+$/).to_s
202
- uri = URI DOMAIN + "/webstore/webstore.nsf/AjaxRequestXML?"\
203
- "Openagent&url=" + pubid
207
+ uri = URI "#{DOMAIN}/webstore/webstore.nsf/AjaxRequestXML?"\
208
+ "Openagent&url=#{pubid}"
204
209
  resp = Net::HTTP.get_response uri
205
210
  doc = Nokogiri::XML resp.body
206
211
  status = fetch_status doc
@@ -214,7 +219,7 @@ module RelatonIec
214
219
  # @return [String]
215
220
  def fetch_type(doc)
216
221
  doc.at(
217
- '//th[contains(., "Publication type")]/following-sibling::td/span'
222
+ '//th[contains(., "Publication type")]/following-sibling::td/span',
218
223
  ).text.downcase.tr " ", "-"
219
224
  end
220
225
 
@@ -253,9 +258,9 @@ module RelatonIec
253
258
  # @return [Array<Hash>]
254
259
  def fetch_ics(doc)
255
260
  doc.xpath(
256
- '//th[contains(text(), "ICS")]/following-sibling::td/a'
261
+ '//th[contains(text(), "ICS")]/following-sibling::td/a',
257
262
  ).map do |i|
258
- code = i.text.match(/[\d\.]+/).to_s.split "."
263
+ code = i.text.match(/[\d.]+/).to_s.split "."
259
264
  { field: code[0], group: code[1], subgroup: code[2] }
260
265
  end
261
266
  end
@@ -292,11 +297,7 @@ module RelatonIec
292
297
  # rubocop:enable Metrics/MethodLength
293
298
 
294
299
  def name_url(abbrev)
295
- case abbrev
296
- when "ISO" then ["International Organization for Standardization", "www.iso.org"]
297
- when "IEC" then ["International Electrotechnical Commission", "www.iec.ch"]
298
- when "CISPR" then ["International special committee on radio interference", "www.iec.ch"]
299
- end
300
+ ABBREVS[abbrev]
300
301
  end
301
302
  end
302
303
  end
@@ -0,0 +1,24 @@
1
+ module RelatonIec
2
+ class TcScOfficersNote
3
+ # @return [Array<RelatonIec::BasicBlock>]
4
+ attr_reader :basic_blocks
5
+
6
+ #
7
+ # @param [Array<BasicBlock::ParagraphWithFootnote>] basic_blocks
8
+ #
9
+ def initialize(basic_blocks)
10
+ @basic_blocks = basic_blocks
11
+ end
12
+
13
+ #
14
+ # XML serialization
15
+ #
16
+ # @param [Nokogiri::XML::Builder] builder
17
+ #
18
+ def to_xml(builder)
19
+ builder.send "tc-sc-officers-note" do |b|
20
+ basic_blocks.each { |bb| bb.to_xml b }
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module RelatonIec
2
- VERSION = "1.7.8".freeze
2
+ VERSION = "1.10.1".freeze
3
3
  end
@@ -1,6 +1,26 @@
1
1
  module RelatonIec
2
2
  class XMLParser < RelatonIsoBib::XMLParser
3
3
  class << self
4
+ # Override RelatonIsoBib::XMLParser.item_data method.
5
+ # @param isoitem [Nokogiri::XML::Element]
6
+ # @returtn [Hash]
7
+ def item_data(isoitem) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
8
+ data = super
9
+ ext = isoitem.at "./ext"
10
+ return data unless ext
11
+
12
+ data[:function] = ext.at("./function")&.text
13
+ data[:updates_document_type] = ext.at("./updates-document-type")&.text
14
+ aci = ext.at("./accessibility-color-inside")
15
+ data[:accessibility_color_inside] = aci.text == "true" if aci
16
+ data[:price_code] = ext.at("./price-code")&.text
17
+ cp = ext.at("./cen-processing")
18
+ data[:cen_processing] = cp.text == "true" if cp
19
+ data[:secretary] = ext.at("./secretary")&.text
20
+ data[:interest_to_committees] = ext.at("./interest-to-committees")&.text
21
+ data
22
+ end
23
+
4
24
  private
5
25
 
6
26
  # override RelatonIsoBib::IsoBibliographicItem.bib_item method
data/relaton_iec.gemspec CHANGED
@@ -21,19 +21,17 @@ Gem::Specification.new do |spec|
21
21
  spec.bindir = "exe"
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
- spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
24
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
25
25
 
26
- # spec.add_development_dependency "debase"
27
26
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
28
27
  spec.add_development_dependency "pry-byebug"
29
28
  spec.add_development_dependency "rake", "~> 10.0"
30
29
  spec.add_development_dependency "rspec", "~> 3.0"
31
- # spec.add_development_dependency "ruby-debug-ide"
32
30
  spec.add_development_dependency "ruby-jing"
33
31
  spec.add_development_dependency "simplecov"
34
32
  spec.add_development_dependency "vcr"
35
33
  spec.add_development_dependency "webmock"
36
34
 
37
35
  spec.add_dependency "addressable"
38
- spec.add_dependency "relaton-iso-bib", "~> 1.7.0"
36
+ spec.add_dependency "relaton-iso-bib", "~> 1.10.1"
39
37
  end