relaton-ietf 1.9.12 → 1.10.2

Sign up to get free protection for your applications and to get access to all the features.
data/grammars/reqt.rng CHANGED
@@ -64,9 +64,9 @@
64
64
  <optional>
65
65
  <ref name="label"/>
66
66
  </optional>
67
- <optional>
67
+ <zeroOrMore>
68
68
  <ref name="subject"/>
69
- </optional>
69
+ </zeroOrMore>
70
70
  <zeroOrMore>
71
71
  <ref name="reqinherit"/>
72
72
  </zeroOrMore>
@@ -80,6 +80,7 @@
80
80
  <ref name="verification"/>
81
81
  <ref name="import"/>
82
82
  <ref name="description"/>
83
+ <ref name="component"/>
83
84
  </choice>
84
85
  </zeroOrMore>
85
86
  <optional>
@@ -105,12 +106,16 @@
105
106
  </define>
106
107
  <define name="subject">
107
108
  <element name="subject">
108
- <text/>
109
+ <oneOrMore>
110
+ <ref name="TextElement"/>
111
+ </oneOrMore>
109
112
  </element>
110
113
  </define>
111
114
  <define name="reqinherit">
112
115
  <element name="inherit">
113
- <text/>
116
+ <oneOrMore>
117
+ <ref name="TextElement"/>
118
+ </oneOrMore>
114
119
  </element>
115
120
  </define>
116
121
  <define name="measurementtarget">
@@ -138,6 +143,12 @@
138
143
  <ref name="RequirementSubpart"/>
139
144
  </element>
140
145
  </define>
146
+ <define name="component">
147
+ <element name="component">
148
+ <attribute name="class"/>
149
+ <ref name="RequirementSubpart"/>
150
+ </element>
151
+ </define>
141
152
  <define name="reqt_references">
142
153
  <element name="references">
143
154
  <oneOrMore>
@@ -3,18 +3,31 @@ module RelatonIetf
3
3
  include RelatonBib::BibXMLParser
4
4
  extend BibXMLParser
5
5
 
6
- FLAVOR = "IETF".freeze
7
-
8
6
  # @param attrs [Hash]
9
7
  # @return [RelatonIetf::IetfBibliographicItem]
10
8
  def bib_item(**attrs)
11
9
  unless attrs.delete(:is_relation)
12
10
  attrs[:fetched] = Date.today.to_s
13
- attrs[:place] = ["Fremont, CA"]
11
+ # attrs[:place] = ["Fremont, CA"]
14
12
  end
15
13
  RelatonIetf::IetfBibliographicItem.new(**attrs)
16
14
  end
17
15
 
16
+ #
17
+ # Extract document identifier type form identifier
18
+ #
19
+ # @param [String] id identifier
20
+ #
21
+ # @return [String] type
22
+ #
23
+ def pubid_type(id)
24
+ type = super
25
+ case type
26
+ when "BCP", "FYI", "STD", "RFC" then "RFC"
27
+ else "IETF"
28
+ end
29
+ end
30
+
18
31
  # @param [RelatonBib::WorkGroup]
19
32
  # @return [RelatonIetf::Committee]
20
33
  def committee(wgr)
@@ -24,7 +37,10 @@ module RelatonIetf
24
37
  # @param reference [Nokogiri::XML::Element]
25
38
  # @return [Array<Hash>]
26
39
  def contributors(reference)
27
- [{ entity: new_org("Internet Engineering Task Force", "IETF"), role: [type: "publisher"] }] + super
40
+ [{
41
+ entity: new_org("Internet Engineering Task Force", "IETF"),
42
+ role: [type: "publisher"],
43
+ }] + super
28
44
  # persons(reference) + organizations(reference)
29
45
  end
30
46
  end
@@ -64,17 +64,6 @@ module RelatonIetf
64
64
  # Fetches ietf-internet-drafts documents
65
65
  #
66
66
  def fetch_ieft_internet_drafts # rubocop:disable Metrics/MethodLength
67
- # gz = OpenURI.open_uri("https://www.ietf.org/lib/dt/sprint/bibxml-ids.tgz")
68
- # z = Zlib::GzipReader.new(gz)
69
- # io = StringIO.new(z.read)
70
- # z.close
71
- # Gem::Package::TarReader.new io do |tar|
72
- # tar.each do |tarfile|
73
- # next if tarfile.directory?
74
-
75
- # save_doc BibXMLParser.parse(tarfile.read)
76
- # end
77
- # end
78
67
  Dir["bibxml-ids/*.xml"].each do |file|
79
68
  save_doc BibXMLParser.parse(File.read(file, encoding: "UTF-8"))
80
69
  end
@@ -83,6 +72,9 @@ module RelatonIetf
83
72
  def fetch_ieft_rfcs
84
73
  rfc_index.xpath("xmlns:rfc-entry").each do |doc|
85
74
  save_doc RfcEntry.parse(doc)
75
+ rescue StandardError => e
76
+ warn "Error parsing #{doc.at('./xmlns:doc-id').text}: #{e.message}"
77
+ warn e.backtrace[0..5].join("\n")
86
78
  end
87
79
  end
88
80
 
@@ -67,7 +67,7 @@ module RelatonIetf
67
67
  #
68
68
  def parse_docid
69
69
  ids = [
70
- RelatonBib::DocumentIdentifier.new(id: pub_id, type: "IETF"),
70
+ RelatonBib::DocumentIdentifier.new(id: pub_id, type: "IETF", primary: true),
71
71
  RelatonBib::DocumentIdentifier.new(id: code, type: "IETF", scope: "anchor"),
72
72
  ]
73
73
  doi = @doc.at("./xmlns:doi").text
@@ -142,19 +142,66 @@ module RelatonIetf
142
142
  #
143
143
  # @return [Array<RelatonBib::ContributionInfo>] document contributors
144
144
  #
145
- def parse_contributor
146
- @doc.xpath("./xmlns:author").map do |contributor|
145
+ def parse_contributor # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity
146
+ @doc.xpath("./xmlns:author").map do |contributor| # rubocop:disable Metrics/BlockLength
147
147
  n = contributor.at("./xmlns:name").text
148
- int, snm = n.split
149
- initial = [RelatonBib::LocalizedString.new(int, "en", "Latn")]
150
- surname = RelatonBib::LocalizedString.new(snm, "en", "Latn")
151
- name = RelatonBib::LocalizedString.new(n, "en", "Latn")
152
- fname = RelatonBib::FullName.new(completename: name, initial: initial, surname: surname)
153
- person = RelatonBib::Person.new(name: fname)
154
- RelatonBib::ContributionInfo.new(entity: person, role: [{ type: "author" }])
148
+ case n
149
+ when "ISO"
150
+ entity = RelatonBib::Organization.new(abbrev: n, name: "International Organization for Standardization")
151
+ when "International Organization for Standardization"
152
+ entity = RelatonBib::Organization.new(abbrev: "ISO", name: n)
153
+ when "IAB"
154
+ entity = RelatonBib::Organization.new(abbrev: n, name: "Internet Architecture Board")
155
+ when "IESG"
156
+ entity = RelatonBib::Organization.new(abbrev: n, name: "Internet Engineering Steering Group")
157
+ when "Internet Engineering Steering Group", "Federal Networking Council", "Internet Architecture Board",
158
+ "Internet Activities Board", "Defense Advanced Research Projects Agency", "National Science Foundation",
159
+ "National Research Council", "National Bureau of Standards"
160
+ abbr = n.split.map { |w| w[0] if w[0] == w[0].upcase }.join
161
+ entity = RelatonBib::Organization.new(abbrev: abbr, name: n)
162
+ when "IETF Secretariat"
163
+ entity = RelatonBib::Organization.new(abbrev: "IETF", name: n)
164
+ when "Audio-Video Transport Working Group", /North American Directory Forum/, "EARN Staff",
165
+ "Vietnamese Standardization Working Group", "ACM SIGUCCS", "ESCC X.500/X.400 Task Force",
166
+ "Sun Microsystems", "NetBIOS Working Group in the Defense Advanced Research Projects Agency",
167
+ "End-to-End Services Task Force", "Network Technical Advisory Group", "Bolt Beranek",
168
+ "Newman Laboratories", "Gateway Algorithms and Data Structures Task Force",
169
+ "Network Information Center. Stanford Research Institute", "RFC Editor",
170
+ "Information Sciences Institute University of Southern California"
171
+ entity = RelatonBib::Organization.new(name: n)
172
+ when "Internet Assigned Numbers Authority (IANA)"
173
+ entity = RelatonBib::Organization.new(abbrev: "IANA", name: "Internet Assigned Numbers Authority")
174
+ when "ESnet Site Coordinating Comittee (ESCC)"
175
+ entity = RelatonBib::Organization.new(abbrev: "ESCC", name: "ESnet Site Coordinating Comittee")
176
+ when "Energy Sciences Network (ESnet)"
177
+ entity = RelatonBib::Organization.new(abbrev: "ESnet", name: "Energy Sciences Network")
178
+ when "International Telegraph and Telephone Consultative Committee of the International Telecommunication Union"
179
+ entity = RelatonBib::Organization.new(abbrev: "CCITT", name: n)
180
+ else
181
+ # int, snm = n.split
182
+ /^(?:(?<int>(?:\p{Lu}+(?:-\w|\(\w\))?\.{0,2}[-\s]?)+)\s)?(?<snm>[[:alnum:]\s'-.]+)$/ =~ n
183
+ surname = RelatonBib::LocalizedString.new(snm, "en", "Latn")
184
+ name = RelatonBib::LocalizedString.new(n, "en", "Latn")
185
+ fname = RelatonBib::FullName.new(completename: name, initial: initials(int), surname: surname)
186
+ entity = RelatonBib::Person.new(name: fname)
187
+ end
188
+ RelatonBib::ContributionInfo.new(entity: entity, role: [{ type: "author" }])
155
189
  end
156
190
  end
157
191
 
192
+ #
193
+ # Ctreat initials
194
+ #
195
+ # @param [String] int
196
+ #
197
+ # @return [Array<RelatonBib::LocalizedString>]
198
+ #
199
+ def initials(int)
200
+ return [] unless int
201
+
202
+ int.split(/\.-?\s?|\s/).map { |i| RelatonBib::LocalizedString.new i, "en", "Latn" }
203
+ end
204
+
158
205
  #
159
206
  # Parse document keywords
160
207
  #
@@ -54,7 +54,7 @@ module RelatonIetf
54
54
 
55
55
  def parse_docid
56
56
  [
57
- RelatonBib::DocumentIdentifier.new(type: "IETF", id: pub_id),
57
+ RelatonBib::DocumentIdentifier.new(type: "IETF", id: pub_id, primary: true),
58
58
  RelatonBib::DocumentIdentifier.new(type: "IETF", scope: "anchor", id: @doc_id),
59
59
  ]
60
60
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIetf
2
- VERSION = "1.9.12".freeze
2
+ VERSION = "1.10.2".freeze
3
3
  end
data/relaton_ietf.gemspec CHANGED
@@ -38,6 +38,6 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency "vcr"
39
39
  spec.add_development_dependency "webmock"
40
40
 
41
- spec.add_dependency "relaton-bib", ">= 1.9.19"
41
+ spec.add_dependency "relaton-bib", "~> 1.10.1"
42
42
  # spec.add_dependency "zlib", "~> 1.1.0"
43
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-ietf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.12
4
+ version: 1.10.2
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-01-21 00:00:00.000000000 Z
11
+ date: 2022-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -126,16 +126,16 @@ dependencies:
126
126
  name: relaton-bib
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.9.19
131
+ version: 1.10.1
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.9.19
138
+ version: 1.10.1
139
139
  description: "RelatonIetf: retrieve IETF Standards for bibliographic use \nusing the
140
140
  BibliographicItem model.\n\nFormerly known as rfcbib.\n"
141
141
  email: