relaton-ieee 1.12.7 → 1.12.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: 495622b50a4332e32e7d8b72c6258ffadeeeab45ee2fa848132f6c1284f638c2
4
- data.tar.gz: 8b4c163ce241e5f3db57df8993f7a0aea2ea47729e1ff92b62b53bfa07347c97
3
+ metadata.gz: c1dc5898477bc082d2628a9420f042304ec97c7e763adaf3ad6029470a800743
4
+ data.tar.gz: 25ff4f71fe0c8aa9a3549f1f463008032195450291062f2735ea73b620ef9fa1
5
5
  SHA512:
6
- metadata.gz: 4903079f76d6efbba076699e00ac7a2c7f5c7b0fa3d808995d34afb3d59781d08d1eb3eda804a0991b8fd89206fb537fc34b58f14eae586e3014c6265c4aed47
7
- data.tar.gz: c57c445a08a38cb0568510544c8c89fca246bc5c3e2c6299e8d44cc1bdcf60862ddbb34dfc8f2351ccda527050c6725bd6adce300539e7e0dfcd075aec8c0f3b
6
+ metadata.gz: f805694634b0dcad0829b255d6f984eae49f6d86d3049279ee9d0357f9d2618f6f2c9a6139ca347b8810dfb75669233e7aa985202bd5b80474df2dc284c4135c
7
+ data.tar.gz: e08ea8f9f27bba582fd7e448dfb54624f62c8d0aa7fd9b16f7457170cc1297a75f5ef08a7622ea19f6704e69194629a1b38475aed8192de6bb808ca03be49ff2
@@ -46,7 +46,7 @@ module RelatonIeee
46
46
  copyright: parse_copyright,
47
47
  language: ["en"],
48
48
  script: ["Latn"],
49
- status: parse_status,
49
+ docstatus: parse_status,
50
50
  relation: parse_relation,
51
51
  link: parse_link,
52
52
  keyword: parse_keyword,
@@ -12,14 +12,17 @@ module RelatonIeee
12
12
  #
13
13
  # @param [Hash] args
14
14
  # @option args [Boolean, nil] :trialuse Trial use
15
- # @option args [Array<RelatonIeee::EditorialGroup>] :editorialgroup Editorial group
15
+ # @option args [Array<RelatonIeee::EditorialGroup>] :editorialgroup
16
+ # Editorial group
16
17
  #
17
- def initialize(**args)
18
+ def initialize(**args) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
18
19
  if args[:doctype] && !TYPES.include?(args[:doctype])
19
- warn "[relaton-ieee] doctype should be one of #{TYPES.join(', ')}"
20
+ warn "[relaton-ieee] invalid doctype \"#{args[:doctype]}\". " \
21
+ "It should be one of: #{TYPES.join(', ')}."
20
22
  end
21
23
  if args[:docsubtype] && !SUBTYPES.include?(args[:docsubtype])
22
- warn "[relaton-ieee] docsubtype should be one of #{SUBTYPES.join(', ')}"
24
+ warn "[relaton-ieee] invalid docsubtype \"#{args[:docsubtype]}\". " \
25
+ "It should be one of: #{SUBTYPES.join(', ')}."
23
26
  end
24
27
  eg = args.delete(:editorialgroup)
25
28
  @trialuse = args.delete(:trialuse)
@@ -3,10 +3,14 @@ module RelatonIeee
3
3
  class << self
4
4
  GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ieee/main/data/".freeze
5
5
 
6
+ #
7
+ # Search IEEE bibliography item by reference.
8
+ #
6
9
  # @param code [String]
10
+ #
7
11
  # @return [RelatonIeee::HitCollection]
12
+ #
8
13
  def search(code)
9
- # HitCollection.new text
10
14
  ref = code.sub(/Std\s/i, "").gsub(/[\s,:\/]/, "_").squeeze("_").upcase
11
15
  url = "#{GH_URL}#{ref}.yaml"
12
16
  resp = Faraday.get url
@@ -17,77 +21,26 @@ module RelatonIeee
17
21
  raise RelatonBib::RequestError, "Could not access #{GH_URL}"
18
22
  end
19
23
 
24
+ #
25
+ # Get IEEE bibliography item by reference.
26
+ #
20
27
  # @param code [String] the IEEE standard Code to look up (e..g "528-2019")
21
28
  # @param year [String] the year the standard was published (optional)
22
29
  # @param opts [Hash] options
23
30
  #
24
31
  # @return [Hash, NilClass] returns { ret: RelatonBib::BibliographicItem }
25
32
  # if document is found else returns NilClass
33
+ #
26
34
  def get(code, _year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
27
35
  warn "[relaton-ieee] (\"#{code}\") fetching..."
28
36
  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
37
+ if item
33
38
  warn "[relaton-ieee] (\"#{code}\") found #{item.docidentifier.first.id}"
34
39
  item
35
- # else
36
- # fetch_ref_err(code, year, ret[:years])
40
+ else
41
+ warn "[relaton-ieee] (\"#{code}\") not found"
37
42
  end
38
43
  end
39
-
40
- private
41
-
42
- # Sort through the results from RelatonIeee, fetching them three at a time,
43
- # and return the first result that matches the code,
44
- # matches the year (if provided), and which # has a title (amendments do not).
45
- # Only expects the first page of results to be populated.
46
- # Does not match corrigenda etc (e.g. ISO 3166-1:2006/Cor 1:2007)
47
- # If no match, returns any years which caused mismatch, for error reporting
48
- #
49
- # @param result [RelatonIeee::HitCollection]
50
- # @param opts [Hash] options
51
- #
52
- # @return [Hash]
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]
59
-
60
- # return { ret: hit } if !year
61
-
62
- # return { ret: hit } if year.to_i == hit.hit[:year]
63
-
64
- # missed_years << hit.hit[:year]
65
- # end
66
- # { years: missed_years.uniq }
67
- # end
68
-
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
77
-
78
- # @param code [Strig]
79
- # @param year [String]
80
- # @param missed_years [Array<Strig>]
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
91
44
  end
92
45
  end
93
46
  end
@@ -41,7 +41,7 @@ module RelatonIeee
41
41
  # @param hash [Hash]
42
42
  # @return [RelatonIeee::IeeeBibliographicItem]
43
43
  def hash_to_bib(hash)
44
- ::RelatonIeee::IeeeBibliographicItem.new hash
44
+ ::RelatonIeee::IeeeBibliographicItem.new(**hash)
45
45
  end
46
46
 
47
47
  # Returns hash of XML grammar
@@ -1,3 +1,3 @@
1
1
  module RelatonIeee
2
- VERSION = "1.12.7".freeze
2
+ VERSION = "1.12.8".freeze
3
3
  end
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.7
4
+ version: 1.12.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: 2022-07-28 00:00:00.000000000 Z
11
+ date: 2022-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -154,7 +154,6 @@ files:
154
154
  - lib/relaton_ieee/editorial_group.rb
155
155
  - lib/relaton_ieee/hash_converter.rb
156
156
  - lib/relaton_ieee/hit.rb
157
- - lib/relaton_ieee/hit_collection.rb
158
157
  - lib/relaton_ieee/ieee_bibliographic_item.rb
159
158
  - lib/relaton_ieee/ieee_bibliography.rb
160
159
  - lib/relaton_ieee/processor.rb
@@ -1,42 +0,0 @@
1
- require "faraday"
2
- require "relaton_ieee/hit"
3
- require "fileutils"
4
-
5
- module RelatonIeee
6
- class HitCollection < RelatonBib::HitCollection
7
- # DOMAIN = "https://standards.ieee.org".freeze
8
- GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ieee/main/data/".freeze
9
-
10
- # @param reference [Strig]
11
- # @param opts [Hash]
12
- def initialize(reference) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
13
- super
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
27
-
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}}
32
-
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
40
- end
41
- end
42
- end