relaton-ieee 1.12.4 → 1.12.5

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: e06d850cd175596e9f8a50c8a88000ecd646fb4e9059082e26248269fb045380
4
- data.tar.gz: a34c8e7e8ab5f4bcb95903ef2cdbc4185e97ab391f55aefb403bffeb39071e3c
3
+ metadata.gz: b6ad7f017d693570ce6e8c4831ce40b7d5c6385014292abd35511b73b33e4dfa
4
+ data.tar.gz: 851deaf7128da40b1e419a9bb1003879a7ac86580ea9386abd62c7549d4c3292
5
5
  SHA512:
6
- metadata.gz: 8edfef0c1e20620b4a79afb43657f96d7cc4d783b34b3f0d66aa18aff07cf7fa1b358c4079e899ac1dc57ef082c146d4f1abac87de3cab3a2ba5ef7b6d4b5572
7
- data.tar.gz: 32c965caf76d0e5b99e2390cbd3cff57c5dddd14a78c49bae54ec37f4968d735e73b8a67dda45f91f1569d452282ad727f9fea9f8048ce4bf8499a4fb6c75019
6
+ metadata.gz: 796570f9e1769e5550e77c5f41a675c7f8a8ae8c3ad39e975fa7a7db6bd20379752ca0b1e8fddd3e58e4f650ff8fc6588fcd6cb3c9ecaf6c1559d3814e44fe79
7
+ data.tar.gz: 67a34e3ab8b37a25c128cb46f3957b453a111b7a4afea312cd925f4a33579ef63bc32e2400420900a71f4c5fb1fd206402ca90a9d6868d99af1c5f6d6d2fe65f
@@ -0,0 +1,56 @@
1
+ module RelatonIeee
2
+ class BallotingGroup
3
+ TYPES = %w[individual entity].freeze
4
+
5
+ # @return [String]
6
+ attr_reader :type, :content
7
+
8
+ #
9
+ # Initialize balloting group
10
+ #
11
+ # @param [String] type type
12
+ # @param [String] content content
13
+ #
14
+ def initialize(type:, content:)
15
+ unless TYPES.include?(type)
16
+ warn "[relaton-ieee] WARNING: type of Balloting group must be one of #{TYPES.join(', ')}"
17
+ end
18
+
19
+ @type = type
20
+ @content = content
21
+ end
22
+
23
+ #
24
+ # Render balloting group to XML
25
+ #
26
+ # @param [Nokogiri::XML::Builder] builder XML builder
27
+ #
28
+ def to_xml(builder)
29
+ builder.send :"balloting-group", content, type: type
30
+ end
31
+
32
+ #
33
+ # Render balloting group to Hash
34
+ #
35
+ # @return [Hash] balloting group as Hash
36
+ #
37
+ def to_hash
38
+ { "type" => type, "content" => content }
39
+ end
40
+
41
+ #
42
+ # Render balloting group to AsciiBib
43
+ #
44
+ # @param [String] prefix Prefix
45
+ #
46
+ # @return [String] AsciiBib
47
+ #
48
+ def to_asciibib(prefix = "")
49
+ pref = prefix.empty? ? prefix : "#{prefix}."
50
+ pref += "balloting-group"
51
+ out = "#{pref}.type:: #{type}\n"
52
+ out += "#{pref}.content:: #{content}\n"
53
+ out
54
+ end
55
+ end
56
+ end
@@ -35,6 +35,7 @@ module RelatonIeee
35
35
  #
36
36
  def parse # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
37
37
  args = {
38
+ fetched: Date.today.to_s,
38
39
  type: "standard",
39
40
  docnumber: docnumber,
40
41
  title: parse_title,
@@ -127,6 +128,11 @@ module RelatonIeee
127
128
  end
128
129
  end
129
130
 
131
+ #
132
+ # Create PubID
133
+ #
134
+ # @return [RelatonIeee::RawbibIdParser] PubID
135
+ #
130
136
  def pubid
131
137
  @pubid ||= begin
132
138
  nt = doc.at("./normtitle").text
@@ -223,7 +229,7 @@ module RelatonIeee
223
229
  #
224
230
  def parse_status
225
231
  stage = doc.at("./publicationinfo/standard_status").text
226
- RelatonBib::DocumentStatus.new stage: stage
232
+ DocumentStatus.new stage: stage
227
233
  end
228
234
 
229
235
  #
@@ -0,0 +1,14 @@
1
+ module RelatonIeee
2
+ class DocumentStatus < RelatonBib::DocumentStatus
3
+ class Stage < RelatonBib::DocumentStatus::Stage
4
+ STAGES = %w[developing active inactive].freeze
5
+
6
+ def initialize(value:, abbreviation: nil)
7
+ unless STAGES.include?(value.downcase)
8
+ warn "[relaton-ieee] Stage value must be one of #{STAGES.join(', ')}"
9
+ end
10
+ super
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,83 @@
1
+ module RelatonIeee
2
+ class EditorialGroup
3
+ # @return [String]
4
+ attr_reader :society, :working_group
5
+ # @return [RelatonIeee::BallotingGroup] Balloting group
6
+ attr_reader :balloting_group
7
+ # @return [Array<String>] Committee
8
+ attr_reader :committee
9
+
10
+ #
11
+ # Initialize editorial group
12
+ #
13
+ # @param [Hash] **args Hash of arguments
14
+ # @option args [String] :society Society
15
+ # @option args [RelatonIeee::BallotingGroup, Hash] :balloting_group Balloting group
16
+ # @option args [String] :working_group Working group
17
+ # @option args [Array<String>] :committee Committee
18
+ #
19
+ def initialize(**args)
20
+ unless args[:committee].is_a?(Array) && args[:committee].any?
21
+ raise ArgumentError, ":committee is required"
22
+ end
23
+
24
+ @society = args[:society]
25
+ @balloting_group = if args[:balloting_group].is_a?(Hash)
26
+ BallotingGroup.new(**args[:balloting_group])
27
+ else args[:balloting_group]
28
+ end
29
+ @working_group = args[:working_group]
30
+ @committee = args[:committee]
31
+ end
32
+
33
+ def presence?
34
+ true
35
+ end
36
+
37
+ #
38
+ # Render editorial group to XML
39
+ #
40
+ # @param [Nokogiri::XML::Builder] builder XML builder
41
+ #
42
+ def to_xml(builder)
43
+ builder.editorialgroup do |b|
44
+ b.society society if society
45
+ balloting_group&.to_xml(b)
46
+ b.send :"working-group", working_group if working_group
47
+ committee.each { |c| b.committee c }
48
+ end
49
+ end
50
+
51
+ #
52
+ # Render editorial group to Hash
53
+ #
54
+ # @return [Hash] editorial group as Hash
55
+ #
56
+ def to_hash
57
+ hash = {}
58
+ hash["society"] = society if society
59
+ hash["balloting_group"] = balloting_group.to_hash if balloting_group
60
+ hash["working_group"] = working_group if working_group
61
+ hash["committee"] = committee if committee
62
+ hash
63
+ end
64
+
65
+ #
66
+ # Render editorial group to AsciiBib
67
+ #
68
+ # @param [String] prefix Prefix
69
+ #
70
+ # @return [String] AsciiBib
71
+ #
72
+ def to_asciibib(prefix = "")
73
+ pref = prefix.empty? ? prefix : "#{prefix}."
74
+ pref += "editorialgroup"
75
+ out = ""
76
+ out += "#{pref}.society:: #{society}\n" if society
77
+ out += balloting_group.to_asciibib(pref) if balloting_group
78
+ out += "#{pref}.working-group:: #{working_group}\n" if working_group
79
+ committee.each { |c| out += "#{pref}.committee:: #{c}\n" }
80
+ out
81
+ end
82
+ end
83
+ end
@@ -4,13 +4,13 @@ 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 nil unless hash.is_a?(Hash)
10
10
 
11
- committee_hash_to_bib hash
12
- hash
13
- end
11
+ # editorialgroup_hash_to_bib hash
12
+ # hash
13
+ # end
14
14
 
15
15
  # @param item_hash [Hash]
16
16
  # @return [RelatonIeee::IeeeBibliographicItem]
@@ -19,10 +19,10 @@ module RelatonIeee
19
19
  end
20
20
 
21
21
  # @param hash [Hash]
22
- def committee_hash_to_bib(hash)
23
- return unless hash[:committee]
22
+ def editorialgroup_hash_to_bib(hash)
23
+ return unless hash[:editorialgroup]
24
24
 
25
- hash[:committee] = hash[:committee].map { |c| Committee.new(**c) }
25
+ hash[:editorialgroup] = EditorialGroup.new(**hash[:editorialgroup])
26
26
  end
27
27
  end
28
28
  end
@@ -4,37 +4,39 @@ require "fileutils"
4
4
 
5
5
  module RelatonIeee
6
6
  class HitCollection < RelatonBib::HitCollection
7
- DOMAIN = "https://standards.ieee.org".freeze
8
- # DATADIR = File.expand_path ".relaton/ogc/", Dir.home
9
- # DATAFILE = File.expand_path "bibliography.json", DATADIR
10
- # ETAGFILE = File.expand_path "etag.txt", DATADIR
7
+ # DOMAIN = "https://standards.ieee.org".freeze
8
+ GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ieee/main/data/".freeze
11
9
 
12
10
  # @param reference [Strig]
13
11
  # @param opts [Hash]
14
12
  def initialize(reference) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
15
13
  super
16
- code1 = reference.sub(/^IEEE\s(Std\s)?/, "")
17
- url = "#{DOMAIN}/wp-admin/admin-ajax.php"
18
- query = reference.gsub("/", " ")
19
- resp = Faraday.post url, { action: "ieee_cloudsearch", q: query }
20
- json = JSON.parse resp.body
21
- unless json["results"]
22
- @array = []
23
- return
24
- end
14
+ ref = reference.gsub(/[\s,:\/]/, "_").squeeze("_").upcase
15
+ url = "#{GH_URL}#{ref}.yaml"
16
+ resp = Faraday.get url
17
+ hit = YAML.load resp.body
18
+ # code1 = reference.sub(/^IEEE\s(Std\s)?/, "")
19
+ # url = "#{DOMAIN}/wp-admin/admin-ajax.php"
20
+ # query = reference.gsub("/", " ")
21
+ # resp = Faraday.post url, { action: "ieee_cloudsearch", q: query }
22
+ # json = JSON.parse resp.body
23
+ # unless json["results"]
24
+ # @array = []
25
+ # return
26
+ # end
25
27
 
26
- @array = json["results"]["hits"]["hit"].reduce([]) do |s, hit|
27
- flds = hit["fields"]
28
- /^(?:\w+\s)?(?<code2>[A-Z\d.]+)(?:-(?<year>\d{4}))?/ =~ flds["meta_designation_l"]
29
- next s unless code2 && code1 =~ %r{^#{code2}}
28
+ # @array = json["results"]["hits"]["hit"].reduce([]) do |s, hit|
29
+ # flds = hit["fields"]
30
+ # /^(?:\w+\s)?(?<code2>[A-Z\d.]+)(?:-(?<year>\d{4}))?/ =~ flds["meta_designation_l"]
31
+ # next s unless code2 && code1 =~ %r{^#{code2}}
30
32
 
31
- hit_data = {
32
- ref: flds["meta_designation_l"],
33
- year: year.to_i,
34
- url: flds["doc_id_l"],
35
- }
36
- s << Hit.new(hit_data, self)
37
- end.sort_by { |h| h.hit[:year].to_s + h.hit[:url] }.reverse
33
+ # hit_data = {
34
+ # ref: flds["meta_designation_l"],
35
+ # year: year.to_i,
36
+ # url: flds["doc_id_l"],
37
+ # }
38
+ # s << Hit.new(hit_data, self)
39
+ # end.sort_by { |h| h.hit[:year].to_s + h.hit[:url] }.reverse
38
40
  end
39
41
  end
40
42
  end
@@ -1,12 +1,30 @@
1
1
  module RelatonIeee
2
2
  class IeeeBibliographicItem < RelatonBib::BibliographicItem
3
- # @return [Array<RelatonIeee::Committee>]
4
- attr_reader :committee
3
+ TYPES = %w[guide recommended-practice standard].freeze
4
+ SUBTYPES = %w[amendment corrigendum erratum].freeze
5
5
 
6
- # @param committee [Array<RelatonIeee::Committee>]
6
+ # @return [RelatonIeee::EditorialGroup, nil]
7
+ attr_reader :editorialgroup
8
+
9
+ # @return [Boolean, nil] Trial use
10
+ attr_reader :trialuse
11
+
12
+ #
13
+ # @param [Hash] args
14
+ # @option args [Boolean, nil] :trialuse Trial use
15
+ # @option args [Array<RelatonIeee::EditorialGroup>] :editorialgroup Editorial group
16
+ #
7
17
  def initialize(**args)
8
- @committee = args.delete(:committee) || []
18
+ if args[:doctype] && !TYPES.include?(args[:doctype])
19
+ warn "[relaton-ieee] doctype should be one of #{TYPES.join(', ')}"
20
+ end
21
+ if args[:docsubtype] && !SUBTYPES.include?(args[:docsubtype])
22
+ warn "[relaton-ieee] docsubtype should be one of #{SUBTYPES.join(', ')}"
23
+ end
24
+ eg = args.delete(:editorialgroup)
25
+ @trialuse = args.delete(:trialuse)
9
26
  super
27
+ @editorialgroup = eg
10
28
  end
11
29
 
12
30
  # @param hash [Hash]
@@ -21,11 +39,15 @@ module RelatonIeee
21
39
  # @option opts [Boolean] :bibdata
22
40
  # @option opts [String] :lang language
23
41
  # @return [String] XML
24
- def to_xml(**opts)
42
+ def to_xml(**opts) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
25
43
  super(**opts) do |bldr|
26
- if opts[:bibdata] && committee.any?
44
+ if opts[:bibdata] && (doctype || subdoctype || !trialuse.nil? || editorialgroup || ics.any?)
27
45
  bldr.ext do |b|
28
- committee.each { |c| c.to_xml b }
46
+ b.doctype doctype if doctype
47
+ b.subdoctype subdoctype if subdoctype
48
+ b.send :"trial-use", trialuse unless trialuse.nil?
49
+ editorialgroup&.to_xml(b)
50
+ ics.each { |ic| ic.to_xml(b) }
29
51
  end
30
52
  end
31
53
  end
@@ -34,7 +56,7 @@ module RelatonIeee
34
56
  # @return [Hash]
35
57
  def to_hash
36
58
  hash = super
37
- hash["committee"] = committee.map &:to_hash if committee.any?
59
+ hash["trialuse"] = trialuse unless trialuse.nil?
38
60
  hash
39
61
  end
40
62
 
@@ -42,7 +64,7 @@ module RelatonIeee
42
64
  # @return [String]
43
65
  def to_asciibib(prefix = "")
44
66
  out = super
45
- committee.each { |c| out += c.to_asciibib prefix, committee.size }
67
+ out += "#{prefix}.trialuse:: #{trialuse}\n" unless trialuse.nil?
46
68
  out
47
69
  end
48
70
  end
@@ -1,12 +1,20 @@
1
1
  module RelatonIeee
2
2
  class IeeeBibliography
3
3
  class << self
4
- # @param text [String]
4
+ GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ieee/main/data/".freeze
5
+
6
+ # @param code [String]
5
7
  # @return [RelatonIeee::HitCollection]
6
- def search(text)
7
- HitCollection.new text
8
+ def search(code)
9
+ # HitCollection.new text
10
+ ref = code.sub(/Std\s/i, "").gsub(/[\s,:\/]/, "_").squeeze("_").upcase
11
+ url = "#{GH_URL}#{ref}.yaml"
12
+ resp = Faraday.get url
13
+ return unless resp.status == 200
14
+
15
+ IeeeBibliographicItem.from_hash YAML.safe_load resp.body
8
16
  rescue Faraday::ConnectionFailed
9
- raise RelatonBib::RequestError, "Could not access #{HitCollection::DOMAIN}"
17
+ raise RelatonBib::RequestError, "Could not access #{GH_URL}"
10
18
  end
11
19
 
12
20
  # @param code [String] the IEEE standard Code to look up (e..g "528-2019")
@@ -15,17 +23,17 @@ module RelatonIeee
15
23
  #
16
24
  # @return [Hash, NilClass] returns { ret: RelatonBib::BibliographicItem }
17
25
  # if document is found else returns NilClass
18
- def get(code, year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
26
+ def get(code, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
19
27
  warn "[relaton-ieee] (\"#{code}\") fetching..."
20
- result = search(code) || (return nil)
21
- year ||= code.match(/(?<=-)\d{4}/)&.to_s
22
- ret = bib_results_filter(result, code, year)
23
- if ret[:ret]
24
- item = ret[:ret].fetch
28
+ item = search(code)
29
+ # year ||= code.match(/(?<=-)\d{4}/)&.to_s
30
+ # ret = bib_results_filter(result, code, year)
31
+ if item # ret[:ret]
32
+ # item = ret[:ret].fetch
25
33
  warn "[relaton-ieee] (\"#{code}\") found #{item.docidentifier.first.id}"
26
34
  item
27
- else
28
- fetch_ref_err(code, year, ret[:years])
35
+ # else
36
+ # fetch_ref_err(code, year, ret[:years])
29
37
  end
30
38
  end
31
39
 
@@ -42,44 +50,44 @@ module RelatonIeee
42
50
  # @param opts [Hash] options
43
51
  #
44
52
  # @return [Hash]
45
- def bib_results_filter(result, ref, year) # rubocop:disable Metrics/AbcSize
46
- rp1 = ref_parts ref
47
- missed_years = []
48
- result.each do |hit|
49
- rp2 = ref_parts hit.hit[:ref]
50
- next if rp1[:code] != rp2[:code] || rp1[:corr] != rp2[:corr]
53
+ # def bib_results_filter(result, ref, year) # rubocop:disable Metrics/AbcSize
54
+ # rp1 = ref_parts ref
55
+ # missed_years = []
56
+ # result.each do |hit|
57
+ # rp2 = ref_parts hit.hit[:ref]
58
+ # next if rp1[:code] != rp2[:code] || rp1[:corr] != rp2[:corr]
51
59
 
52
- return { ret: hit } if !year
60
+ # return { ret: hit } if !year
53
61
 
54
- return { ret: hit } if year.to_i == hit.hit[:year]
62
+ # return { ret: hit } if year.to_i == hit.hit[:year]
55
63
 
56
- missed_years << hit.hit[:year]
57
- end
58
- { years: missed_years.uniq }
59
- end
64
+ # missed_years << hit.hit[:year]
65
+ # end
66
+ # { years: missed_years.uniq }
67
+ # end
60
68
 
61
- def ref_parts(ref)
62
- %r{
63
- ^(?:IEEE\s(?:Std\s)?)?
64
- (?<code>[^-/]+)
65
- (?:-(?<year>\d{4}))?
66
- (?:/(?<corr>\w+\s\d+-\d{4}))?
67
- }x.match ref
68
- end
69
+ # def ref_parts(ref)
70
+ # %r{
71
+ # ^(?:IEEE\s(?:Std\s)?)?
72
+ # (?<code>[^-/]+)
73
+ # (?:-(?<year>\d{4}))?
74
+ # (?:/(?<corr>\w+\s\d+-\d{4}))?
75
+ # }x.match ref
76
+ # end
69
77
 
70
78
  # @param code [Strig]
71
79
  # @param year [String]
72
80
  # @param missed_years [Array<Strig>]
73
- def fetch_ref_err(code, year, missed_years)
74
- id = year ? "#{code} year #{year}" : code
75
- warn "[relaton-ieee] WARNING: no match found online for #{id}. "\
76
- "The code must be exactly like it is on the standards website."
77
- unless missed_years.empty?
78
- warn "[relaton-ieee] (There was no match for #{year}, though there were matches "\
79
- "found for #{missed_years.join(', ')}.)"
80
- end
81
- nil
82
- end
81
+ # def fetch_ref_err(code, year, missed_years)
82
+ # id = year ? "#{code} year #{year}" : code
83
+ # warn "[relaton-ieee] WARNING: no match found online for #{id}. "\
84
+ # "The code must be exactly like it is on the standards website."
85
+ # unless missed_years.empty?
86
+ # warn "[relaton-ieee] (There was no match for #{year}, though there were matches "\
87
+ # "found for #{missed_years.join(', ')}.)"
88
+ # end
89
+ # nil
90
+ # end
83
91
  end
84
92
  end
85
93
  end
@@ -18,7 +18,7 @@ module RelatonIeee
18
18
  language: ["en"],
19
19
  script: ["Latn"],
20
20
  date: fetch_date(doc),
21
- committee: fetch_committee(doc),
21
+ editorialgroup: fetch_editorialgroup(doc),
22
22
  place: ["Piscataway, NJ, USA"],
23
23
  )
24
24
  end
@@ -59,7 +59,7 @@ module RelatonIeee
59
59
  stage = doc.at("//dd[@id='stnd-status']")
60
60
  return unless stage
61
61
 
62
- RelatonBib::DocumentStatus.new(stage: stage.text.split.first)
62
+ DocumentStatus.new(stage: stage.text.split.first)
63
63
  end
64
64
 
65
65
  # @param identifier [String]
@@ -117,8 +117,6 @@ module RelatonIeee
117
117
  # )
118
118
  # end
119
119
 
120
- # rubocop:disable Metrics/MethodLength
121
-
122
120
  # @param date [Nokogiri::HTML::Document]
123
121
  # @return [Array<RelatonBib::BibliographicDate>]
124
122
  def fetch_date(doc)
@@ -134,33 +132,23 @@ module RelatonIeee
134
132
  dates
135
133
  end
136
134
 
137
- # rubocop:disable Metrics/AbcSize
138
-
135
+ #
139
136
  # @param doc [Nokogiri::HTML::Document]
140
- # @return [Array<RelatonIeee::Committee>]
141
- def fetch_committee(doc)
142
- committees = []
143
- sponsor = doc.at "//dd[@id='stnd-committee']/text()"
144
- if sponsor
145
- committees << Committee.new(type: "sponsor", name: sponsor.text.strip)
146
- end
147
- sponsor = doc.at "//td[.='Standards Committee']/following-sibling::td/div/a"
148
- if sponsor
149
- committees << Committee.new(type: "standard", name: sponsor.text)
150
- end
151
- working = doc.at "//dd[@id='stnd-working-group']/text()"
152
- if working
153
- chair = doc.at "//dd[@id='stnd-working-group-chair']"
154
- committees << Committee.new(type: "working", name: working.text.strip,
155
- chair: chair.text)
156
- end
157
- society = doc.at "//dd[@id='stnd-society']/text()"
158
- if society
159
- committees << Committee.new(type: "society", name: society.text.strip)
160
- end
161
- committees
137
+ #
138
+ # @return [RelatonIeee::EditorialGroup]
139
+ #
140
+ def fetch_editorialgroup(doc) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
141
+ committees = doc.xpath(
142
+ "//dd[@id='stnd-committee']/text()",
143
+ "//td[.='Standards Committee']/following-sibling::td/div/a",
144
+ ).map { |c| c.text.strip }
145
+ wg = doc.at("//dd[@id='stnd-working-group']/text()")&.text&.strip
146
+ # chair = doc.at "//dd[@id='stnd-working-group-chair']"
147
+ society = doc.at("//dd[@id='stnd-society']/text()")&.text&.strip
148
+ return unless committees.any? || wg || society
149
+
150
+ EditorialGroup.new(society: society, working_group: wg, committee: committees)
162
151
  end
163
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
164
152
  end
165
153
  end
166
154
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIeee
2
- VERSION = "1.12.4".freeze
2
+ VERSION = "1.12.5".freeze
3
3
  end
@@ -11,18 +11,47 @@ module RelatonIeee
11
11
  ext = item.at "./ext"
12
12
  return data unless ext
13
13
 
14
- data[:committee] = ext.xpath("./committee").map do |c|
15
- Committee.new(
16
- type: c[:type], name: c.at("name").text, chair: c.at("chair")&.text
17
- )
18
- end
14
+ data[:editorialgroup] = parse_editorialgroup(item)
19
15
  data
20
16
  end
21
17
 
22
18
  # @param item_hash [Hash]
23
19
  # @return [RelatonIeee::IeeeBibliographicItem]
24
20
  def bib_item(item_hash)
25
- IeeeBibliographicItem.new **item_hash
21
+ IeeeBibliographicItem.new(**item_hash)
22
+ end
23
+
24
+ #
25
+ # Parse editorialgroup
26
+ #
27
+ # @param [Nokogiri::XML::Element] item XML element
28
+ #
29
+ # @return [RelatonIeee::EditorialGroup] Editorial group
30
+ #
31
+ def parse_editorialgroup(item)
32
+ eg = item.at "./ext/editorialgroup"
33
+ return unless eg
34
+
35
+ society = eg.at("./society")&.text
36
+ bg = parse_balloting_group(eg)
37
+ wg = eg.at("./working-group")&.text
38
+ committee = eg.xpath("./committee").map(&:text)
39
+ EditorialGroup.new(society: society, balloting_group: bg,
40
+ working_group: wg, committee: committee)
41
+ end
42
+
43
+ #
44
+ # Parse balloting group
45
+ #
46
+ # @param [Nokogiri::XML::Element] editorialgroup XML element
47
+ #
48
+ # @return [RelatonIeee::BallotingGroup] Balloting group
49
+ #
50
+ def parse_balloting_group(editorialgroup)
51
+ bg = editorialgroup.at("./balloting-group")
52
+ return unless bg
53
+
54
+ BallotingGroup.new type: bg[:type], content: bg.text
26
55
  end
27
56
  end
28
57
  end
data/lib/relaton_ieee.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  require "digest/md5"
2
+ require "faraday"
2
3
  require "yaml"
3
4
  require "relaton_bib"
4
5
  require "relaton_ieee/version"
6
+ require "relaton_ieee/document_status"
5
7
  require "relaton_ieee/ieee_bibliography"
6
- require "relaton_ieee/hit_collection"
7
- require "relaton_ieee/hit"
8
- require "relaton_ieee/scrapper"
8
+ # require "relaton_ieee/scrapper"
9
9
  require "relaton_ieee/ieee_bibliographic_item"
10
- require "relaton_ieee/committee"
10
+ require "relaton_ieee/editorial_group"
11
+ require "relaton_ieee/balloting_group"
11
12
  require "relaton_ieee/xml_parser"
12
13
  require "relaton_ieee/bibxml_parser"
13
14
  require "relaton_ieee/hash_converter"
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.12.4
4
+ version: 1.12.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-07-18 00:00:00.000000000 Z
11
+ date: 2022-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -146,10 +146,12 @@ files:
146
146
  - grammars/isodoc.rng
147
147
  - grammars/reqt.rng
148
148
  - lib/relaton_ieee.rb
149
+ - lib/relaton_ieee/balloting_group.rb
149
150
  - lib/relaton_ieee/bibxml_parser.rb
150
- - lib/relaton_ieee/committee.rb
151
151
  - lib/relaton_ieee/data_fetcher.rb
152
152
  - lib/relaton_ieee/data_parser.rb
153
+ - lib/relaton_ieee/document_status.rb
154
+ - lib/relaton_ieee/editorial_group.rb
153
155
  - lib/relaton_ieee/hash_converter.rb
154
156
  - lib/relaton_ieee/hit.rb
155
157
  - lib/relaton_ieee/hit_collection.rb
@@ -1,46 +0,0 @@
1
- module RelatonIeee
2
- class Committee
3
- # @return [String]
4
- attr_reader :type, :name
5
-
6
- # @return [String, NilClass]
7
- attr_reader :chair
8
-
9
- # @param type [String]
10
- # @param name [String]
11
- # @param chair [String, NilClass]
12
- def initialize(type:, name:, chair: nil)
13
- @type = type
14
- @name = name
15
- @chair = chair
16
- end
17
-
18
- # @param builder [Nokogiri::XML::Builder]
19
- def to_xml(builder)
20
- builder.committee type: type do |b|
21
- b.name name
22
- b.chair chair if chair
23
- end
24
- end
25
-
26
- # @return [Hash]
27
- def to_hash
28
- hash = { "type" => type, "name" => name }
29
- hash["chair"] = chair if chair
30
- hash
31
- end
32
-
33
- # @param prefix [String]
34
- # @param count [Integer]
35
- # @return [String]
36
- def to_asciibib(prefix, count)
37
- pref = prefix.empty? ? prefix : prefix + "."
38
- pref += "committee"
39
- out = count > 1 ? "#{pref}::\n" : ""
40
- out += "#{pref}.type:: #{type}\n"
41
- out += "#{pref}.name:: #{name}\n"
42
- out += "#{pref}.chair:: #{chair}\n" if chair
43
- out
44
- end
45
- end
46
- end