relaton-ieee 1.9.4 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
data/grammars/reqt.rng CHANGED
@@ -58,15 +58,23 @@
58
58
  <optional>
59
59
  <attribute name="type"/>
60
60
  </optional>
61
+ <optional>
62
+ <attribute name="tag"/>
63
+ </optional>
64
+ <optional>
65
+ <attribute name="multilingual-rendering">
66
+ <ref name="MultilingualRenderingType"/>
67
+ </attribute>
68
+ </optional>
61
69
  <optional>
62
70
  <ref name="reqtitle"/>
63
71
  </optional>
64
72
  <optional>
65
73
  <ref name="label"/>
66
74
  </optional>
67
- <optional>
75
+ <zeroOrMore>
68
76
  <ref name="subject"/>
69
- </optional>
77
+ </zeroOrMore>
70
78
  <zeroOrMore>
71
79
  <ref name="reqinherit"/>
72
80
  </zeroOrMore>
@@ -80,6 +88,7 @@
80
88
  <ref name="verification"/>
81
89
  <ref name="import"/>
82
90
  <ref name="description"/>
91
+ <ref name="component"/>
83
92
  </choice>
84
93
  </zeroOrMore>
85
94
  <optional>
@@ -100,17 +109,23 @@
100
109
  </define>
101
110
  <define name="label">
102
111
  <element name="label">
103
- <text/>
112
+ <oneOrMore>
113
+ <ref name="TextElement"/>
114
+ </oneOrMore>
104
115
  </element>
105
116
  </define>
106
117
  <define name="subject">
107
118
  <element name="subject">
108
- <text/>
119
+ <oneOrMore>
120
+ <ref name="TextElement"/>
121
+ </oneOrMore>
109
122
  </element>
110
123
  </define>
111
124
  <define name="reqinherit">
112
125
  <element name="inherit">
113
- <text/>
126
+ <oneOrMore>
127
+ <ref name="TextElement"/>
128
+ </oneOrMore>
114
129
  </element>
115
130
  </define>
116
131
  <define name="measurementtarget">
@@ -138,6 +153,12 @@
138
153
  <ref name="RequirementSubpart"/>
139
154
  </element>
140
155
  </define>
156
+ <define name="component">
157
+ <element name="component">
158
+ <attribute name="class"/>
159
+ <ref name="RequirementSubpart"/>
160
+ </element>
161
+ </define>
141
162
  <define name="reqt_references">
142
163
  <element name="references">
143
164
  <oneOrMore>
@@ -164,6 +185,14 @@
164
185
  <data type="boolean"/>
165
186
  </attribute>
166
187
  </optional>
188
+ <optional>
189
+ <attribute name="tag"/>
190
+ </optional>
191
+ <optional>
192
+ <attribute name="multilingual-rendering">
193
+ <ref name="MultilingualRenderingType"/>
194
+ </attribute>
195
+ </optional>
167
196
  <oneOrMore>
168
197
  <ref name="BasicBlock"/>
169
198
  </oneOrMore>
@@ -3,12 +3,21 @@ module RelatonIeee
3
3
  extend RelatonBib::BibXMLParser
4
4
  extend BibXMLParser
5
5
 
6
- FLAVOR = "IEEE".freeze
7
-
8
6
  # @param attrs [Hash]
9
7
  # @return [RelatonBib::IetfBibliographicItem]
10
8
  def bib_item(**attrs)
11
9
  IeeeBibliographicItem.new(**attrs)
12
10
  end
11
+
12
+ #
13
+ # Return PubID type
14
+ #
15
+ # @param [String] _ docidentifier
16
+ #
17
+ # @return [String] type
18
+ #
19
+ def pubid_type(_)
20
+ "IEEE"
21
+ end
13
22
  end
14
23
  end
@@ -11,23 +11,27 @@ module RelatonIeee
11
11
 
12
12
  # rubocop:disable Metrics/AbcSize
13
13
 
14
- # @param ref [Strig]
14
+ # @param reference [Strig]
15
15
  # @param opts [Hash]
16
- def initialize(ref) # rubocop:disable Metrics/MethodLength
16
+ def initialize(reference) # rubocop:disable Metrics/MethodLength
17
17
  super
18
- code = ref.sub(/^IEEE\s(Std\s)?/, "")
19
- search = CGI.escape({ data: { searchTerm: code } }.to_json)
20
- url = "#{DOMAIN}/bin/standards/search?data=#{search}"
21
- resp = Faraday.get url
22
- resp_json = JSON.parse resp.body
23
- json = JSON.parse resp_json["message"]
24
- @array = json["response"]["searchResults"]["resultsMapList"]
25
- .reduce([]) do |s, hit|
26
- /^(?:\w+\s)?(?<id>[A-Z\d.]+)(?:-(?<year>\d{4}))?/ =~ hit["record"]["recordTitle"]
27
- next s unless id && code =~ %r{^#{id}}
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
+ html = Nokogiri::HTML json["html"]
24
+ # @array = json["results"]["hits"]["hit"].reduce([]) do |s, hit|
25
+ @array = html.xpath("//h4/a").reduce([]) do |s, hit|
26
+ # fields = hit["fields"]
27
+ # ref = html.at("//h4/a[@href='#{fields['doc_id_l']}']").text.strip
28
+ ref = hit.text.strip
29
+ /^(?:\w+\s)?(?<code2>[A-Z\d.]+)(?:-(?<year>\d{4}))?/ =~ ref
30
+ next s unless code2 && code1 =~ %r{^#{code2}}
28
31
 
29
- s << Hit.new(hit["record"].merge(code: id, year: year.to_i), self)
30
- end.sort_by { |h| h.hit[:year].to_s + h.hit["recordURL"] }.reverse
32
+ hit_data = { ref: ref, year: year.to_i, url: hit[:href] }
33
+ s << Hit.new(hit_data, self)
34
+ end.sort_by { |h| h.hit[:year].to_s + h.hit[:url] }.reverse
31
35
  end
32
36
  # rubocop:enable Metrics/AbcSize
33
37
  end
@@ -15,7 +15,7 @@ module RelatonIeee
15
15
  #
16
16
  # @return [Hash, NilClass] returns { ret: RelatonBib::BibliographicItem }
17
17
  # if document is found else returns NilClass
18
- def get(code, year = nil, _opts = {})
18
+ def get(code, year = nil, _opts = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
19
19
  warn "[relaton-ieee] (\"#{code}\") fetching..."
20
20
  result = search(code) || (return nil)
21
21
  year ||= code.match(/(?<=-)\d{4}/)&.to_s
@@ -42,11 +42,11 @@ module RelatonIeee
42
42
  # @param opts [Hash] options
43
43
  #
44
44
  # @return [Hash]
45
- def bib_results_filter(result, ref, year)
45
+ def bib_results_filter(result, ref, year) # rubocop:disable Metrics/AbcSize
46
46
  rp1 = ref_parts ref
47
47
  missed_years = []
48
48
  result.each do |hit|
49
- rp2 = ref_parts hit.hit["recordTitle"]
49
+ rp2 = ref_parts hit.hit[:ref]
50
50
  next if rp1[:code] != rp2[:code] || rp1[:corr] != rp2[:corr]
51
51
 
52
52
  return { ret: hit } if !year
@@ -6,40 +6,39 @@ module RelatonIeee
6
6
  # papam hit [Hash]
7
7
  # @return [RelatonOgc::OrcBibliographicItem]
8
8
  def parse_page(hit)
9
- doc = Nokogiri::HTML Faraday.get(hit["recordURL"]).body
9
+ doc = Nokogiri::HTML Faraday.get(hit[:url]).body
10
10
  IeeeBibliographicItem.new(
11
11
  fetched: Date.today.to_s,
12
- title: fetch_title(hit["recordTitle"]),
13
- docid: fetch_docid(hit["recordTitle"]),
14
- link: fetch_link(hit["recordURL"]),
12
+ title: fetch_title(doc),
13
+ docid: fetch_docid(hit[:ref]),
14
+ link: fetch_link(hit[:url]),
15
15
  docstatus: fetch_status(doc),
16
16
  abstract: fetch_abstract(doc),
17
17
  contributor: fetch_contributor(doc),
18
18
  language: ["en"],
19
19
  script: ["Latn"],
20
20
  date: fetch_date(doc),
21
- committee: fetch_committee(doc)
21
+ committee: fetch_committee(doc),
22
22
  )
23
23
  end
24
24
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
25
25
 
26
26
  private
27
27
 
28
- # @param title [String]
28
+ # @param doc [String] Nokogiri::HTML4::Document
29
29
  # @return [Array<RelatonBib::TypedTitleString>]
30
- def fetch_title(title)
31
- [
30
+ def fetch_title(doc)
31
+ doc.xpath("//h2[@id='stnd-title']").map do |t|
32
32
  RelatonBib::TypedTitleString.new(
33
- type: "main", content: title, language: "en", script: "Latn"
34
- ),
35
- ]
33
+ type: "main", content: t.text, language: "en", script: "Latn",
34
+ )
35
+ end
36
36
  end
37
37
 
38
- # @param title [String]
38
+ # @param ref [String]
39
39
  # @return [Array<RelatonBib::DocumentIdentifier>]
40
- def fetch_docid(title)
41
- /^(?<identifier>(?:\w+\s)?\S+)/ =~ title
42
- [RelatonBib::DocumentIdentifier.new(id: identifier, type: "IEEE")]
40
+ def fetch_docid(ref)
41
+ [RelatonBib::DocumentIdentifier.new(id: ref, type: "IEEE")]
43
42
  end
44
43
 
45
44
  # @param url [String]
@@ -51,10 +50,10 @@ module RelatonIeee
51
50
  # @param doc [Nokogiri::HTML::Document]
52
51
  # @return [RelatonBib::DocumentStatus, NilClass]
53
52
  def fetch_status(doc)
54
- stage = doc.at("//td[.='Status']/following-sibling::td/div")
53
+ stage = doc.at("//dd[@id='stnd-status']")
55
54
  return unless stage
56
55
 
57
- RelatonBib::DocumentStatus.new(stage: stage.text)
56
+ RelatonBib::DocumentStatus.new(stage: stage.text.split.first)
58
57
  end
59
58
 
60
59
  # @param identifier [String]
@@ -67,33 +66,30 @@ module RelatonIeee
67
66
  # @param doc [Nokogiri::HTML::Document]
68
67
  # @return [Array<RelatonBib::FormattedString>]
69
68
  def fetch_abstract(doc)
70
- content = doc.at("//div[@class='description']")
71
- return [] unless content
72
-
73
- [RelatonBib::FormattedString.new(content: content.text, language: "en",
74
- script: "Latn")]
69
+ doc.xpath("//div[@id='stnd-description']").map do |a|
70
+ RelatonBib::FormattedString.new(
71
+ content: a.text.strip, language: "en", script: "Latn",
72
+ )
73
+ end
75
74
  end
76
75
 
77
76
  # @param doc [Nokogiri::HTML::Document]
78
77
  # @return [Array<RelatonBib::ContributionInfo>]
79
78
  def fetch_contributor(doc)
80
- name = doc.at(
81
- "//td[.='IEEE Program Manager']/following-sibling::td/div/a"
82
- )
83
- return [] unless name
84
-
85
- [personn_contrib(name.text)]
79
+ doc.xpath("//dd[@id='stnd-staff-liaison']/text()").map do |name|
80
+ person_contrib(name.text.strip)
81
+ end
86
82
  end
87
83
 
88
84
  # @param name [String]
89
85
  # @return [RelatonBib::ContributionInfo]
90
- def personn_contrib(name)
86
+ def person_contrib(name)
91
87
  fname = RelatonBib::FullName.new(
92
- completename: RelatonBib::LocalizedString.new(name)
88
+ completename: RelatonBib::LocalizedString.new(name),
93
89
  )
94
90
  entity = RelatonBib::Person.new(name: fname)
95
91
  RelatonBib::ContributionInfo.new(
96
- entity: entity, role: [type: "author"]
92
+ entity: entity, role: [type: "author"],
97
93
  )
98
94
  end
99
95
 
@@ -112,16 +108,13 @@ module RelatonIeee
112
108
  # @return [Array<RelatonBib::BibliographicDate>]
113
109
  def fetch_date(doc)
114
110
  dates = []
115
- issued = doc.at "//td[.='Board Approval']/following-sibling::td/div"
116
- if issued
117
- dates << RelatonBib::BibliographicDate.new(type: "issued",
118
- on: issued.text)
111
+ id = doc.at "//dd[@id='stnd-approval-date']"
112
+ if id
113
+ dates << RelatonBib::BibliographicDate.new(type: "issued", on: id.text)
119
114
  end
120
- published = doc.at("//td[.='History']/following-sibling::td/div")
121
- &.text&.match(/(?<=Published Date:)[\d-]+/)&.to_s
122
- if published
123
- dates << RelatonBib::BibliographicDate.new(type: "published",
124
- on: published)
115
+ pd = doc.at("//dd[@id='stnd-published-date']")
116
+ if pd
117
+ dates << RelatonBib::BibliographicDate.new(type: "published", on: pd.text)
125
118
  end
126
119
  dates
127
120
  end
@@ -132,23 +125,23 @@ module RelatonIeee
132
125
  # @return [Array<RelatonIeee::Committee>]
133
126
  def fetch_committee(doc)
134
127
  committees = []
135
- sponsor = doc.at "//td[.='Sponsor Committee']/following-sibling::td/div"
128
+ sponsor = doc.at "//dd[@id='stnd-committee']/text()"
136
129
  if sponsor
137
- committees << Committee.new(type: "sponsor", name: sponsor.text)
130
+ committees << Committee.new(type: "sponsor", name: sponsor.text.strip)
138
131
  end
139
132
  sponsor = doc.at "//td[.='Standards Committee']/following-sibling::td/div/a"
140
133
  if sponsor
141
134
  committees << Committee.new(type: "standard", name: sponsor.text)
142
135
  end
143
- working = doc.at "//td[.='Working Group']/following-sibling::td/div"
144
- chair = doc.at "//td[.='Working Group Chair']/following-sibling::td/div"
136
+ working = doc.at "//dd[@id='stnd-working-group']/text()"
145
137
  if working
146
- committees << Committee.new(type: "working", name: working.text,
138
+ chair = doc.at "//dd[@id='stnd-working-group-chair']"
139
+ committees << Committee.new(type: "working", name: working.text.strip,
147
140
  chair: chair.text)
148
141
  end
149
- society = doc.at "//td[.='Society']/following-sibling::td/div"
142
+ society = doc.at "//dd[@id='stnd-society']/text()"
150
143
  if society
151
- committees << Committee.new(type: "society", name: society.text)
144
+ committees << Committee.new(type: "society", name: society.text.strip)
152
145
  end
153
146
  committees
154
147
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIeee
2
- VERSION = "1.9.4".freeze
2
+ VERSION = "1.10.0".freeze
3
3
  end
data/relaton_ieee.gemspec CHANGED
@@ -38,6 +38,6 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency "webmock"
39
39
 
40
40
  spec.add_dependency "faraday", "~> 1.1"
41
- spec.add_dependency "relaton-bib", ">= 1.9.5"
41
+ spec.add_dependency "relaton-bib", "~> 1.10.0"
42
42
  spec.add_dependency "rubyzip", "~> 2.3.0"
43
43
  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.9.4
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-28 00:00:00.000000000 Z
11
+ date: 2022-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: relaton-bib
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.9.5
103
+ version: 1.10.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.9.5
110
+ version: 1.10.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubyzip
113
113
  requirement: !ruby/object:Gem::Requirement