relaton-ietf 1.5.pre → 1.7.1

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: 825a59e8e6fda564fe22820f18caffb3ea73875f460f1a27485b87916292dcdf
4
- data.tar.gz: 5e226dcdf18b845ee918d93da5d1985a65682ff1ce5f1205bcd476c71cac096c
3
+ metadata.gz: 90f95ffe25f46c8cd5ae35332277f6b39bd787c7840a30c9315b4ca393076033
4
+ data.tar.gz: 0e591717abcf1ae0ff27feb518469ca5703103c9d8184fea7286b3eb43b3764c
5
5
  SHA512:
6
- metadata.gz: 453047515b0b04cb3de58ec2738c21f670e1ee3b0816afa78e58c9dd4c91cb8c0869d4f25e871829be30b4f43d6415b291a2b08a76b63a15fc19ec5549595b5e
7
- data.tar.gz: 3777394b195714e7cddcd34f2d47202ff5c1b5c1015b1050451934d3c28c09e0e035e453c1bb67f0985aa92b22521b959fe50f8e21e39aef0e93e5498ca8a1f2
6
+ metadata.gz: 4d4cee3c808eedf011dbf3ee0199b6baa70c4e390821a88a685e34dd486a53ba330cda666597521c70f26670c9063cb20c98c867139bee710efe857f0623d734
7
+ data.tar.gz: 1e9297ebf9b3897ce346a0b1fdedf04779220c7f0210a10fa667a67df923382293029cc3126c0edf6a40857712e9bbf3a72d7fb2f4d94fc90a40f896b8e5dbc2
@@ -26,6 +26,8 @@ jobs:
26
26
  - name: Update gems
27
27
  run: |
28
28
  sudo gem install bundler --force
29
+ ruby -v | grep 2.5 && bundle config set build.debase --with-cflags="-Wno-error=implicit-function-declaration"
30
+ ruby -v | grep 2.5 && bundle config set build.ruby-debug-ide --with-cflags="-Wno-error=implicit-function-declaration"
29
31
  bundle install --jobs 4 --retry 3
30
32
  - name: Run specs
31
33
  run: |
data/grammars/ietf.rng CHANGED
@@ -868,6 +868,13 @@
868
868
  </define>
869
869
  <define name="ietf-standard">
870
870
  <element name="ietf-standard">
871
+ <attribute name="version"/>
872
+ <attribute name="type">
873
+ <choice>
874
+ <value>semantic</value>
875
+ <value>presentation</value>
876
+ </choice>
877
+ </attribute>
871
878
  <ref name="bibdata"/>
872
879
  <zeroOrMore>
873
880
  <ref name="termdocsource"/>
data/grammars/isodoc.rng CHANGED
@@ -24,6 +24,14 @@
24
24
  <start>
25
25
  <ref name="standard-document"/>
26
26
  </start>
27
+ <define name="doctype">
28
+ <element name="doctype">
29
+ <optional>
30
+ <attribute name="abbreviation"/>
31
+ </optional>
32
+ <ref name="DocumentType"/>
33
+ </element>
34
+ </define>
27
35
  <define name="hyperlink">
28
36
  <element name="link">
29
37
  <attribute name="target">
@@ -42,7 +50,6 @@
42
50
  </define>
43
51
  <define name="xref">
44
52
  <element name="xref">
45
- <!-- attribute target { xsd:IDREF }, -->
46
53
  <attribute name="target">
47
54
  <data type="string">
48
55
  <param name="pattern">\i\c*|\c+#\c+</param>
@@ -142,6 +149,11 @@
142
149
  <data type="boolean"/>
143
150
  </attribute>
144
151
  </optional>
152
+ <optional>
153
+ <attribute name="key">
154
+ <data type="boolean"/>
155
+ </attribute>
156
+ </optional>
145
157
  <oneOrMore>
146
158
  <ref name="dt"/>
147
159
  <ref name="dd"/>
@@ -864,6 +876,13 @@
864
876
  </define>
865
877
  <define name="standard-document">
866
878
  <element name="standard-document">
879
+ <attribute name="version"/>
880
+ <attribute name="type">
881
+ <choice>
882
+ <value>semantic</value>
883
+ <value>presentation</value>
884
+ </choice>
885
+ </attribute>
867
886
  <ref name="bibdata"/>
868
887
  <optional>
869
888
  <ref name="boilerplate"/>
@@ -1158,49 +1177,7 @@
1158
1177
  </define>
1159
1178
  <define name="annex">
1160
1179
  <element name="annex">
1161
- <optional>
1162
- <attribute name="id">
1163
- <data type="ID"/>
1164
- </attribute>
1165
- </optional>
1166
- <optional>
1167
- <attribute name="language"/>
1168
- </optional>
1169
- <optional>
1170
- <attribute name="script"/>
1171
- </optional>
1172
- <optional>
1173
- <attribute name="inline-header">
1174
- <data type="boolean"/>
1175
- </attribute>
1176
- </optional>
1177
- <attribute name="obligation">
1178
- <choice>
1179
- <value>normative</value>
1180
- <value>informative</value>
1181
- </choice>
1182
- </attribute>
1183
- <optional>
1184
- <ref name="section-title"/>
1185
- </optional>
1186
- <group>
1187
- <group>
1188
- <zeroOrMore>
1189
- <ref name="BasicBlock"/>
1190
- </zeroOrMore>
1191
- <zeroOrMore>
1192
- <ref name="note"/>
1193
- </zeroOrMore>
1194
- </group>
1195
- <zeroOrMore>
1196
- <choice>
1197
- <ref name="annex-subsection"/>
1198
- <ref name="terms"/>
1199
- <ref name="definitions"/>
1200
- <ref name="references"/>
1201
- </choice>
1202
- </zeroOrMore>
1203
- </group>
1180
+ <ref name="Annex-Section"/>
1204
1181
  </element>
1205
1182
  </define>
1206
1183
  <define name="terms">
data/lib/relaton_ietf.rb CHANGED
@@ -6,11 +6,6 @@ require "relaton_ietf/ietf_bibliographic_item"
6
6
  require "relaton_ietf/xml_parser"
7
7
  require "relaton_ietf/hash_converter"
8
8
 
9
- # if defined? Relaton
10
- # require_relative "relaton_ietf/processor"
11
- # Relaton::Registry.instance.register(RelatonIetf::Processor)
12
- # end
13
-
14
9
  require "relaton/provider_ietf"
15
10
 
16
11
  module RelatonIetf
@@ -22,4 +17,4 @@ module RelatonIetf
22
17
  grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
23
18
  Digest::MD5.hexdigest grammars
24
19
  end
25
- end
20
+ end
@@ -1,23 +1,14 @@
1
1
  module RelatonIetf
2
2
  class HashConverter < RelatonBib::HashConverter
3
3
  class << self
4
- # @override RelatonBib::HashConverter.hash_to_bib
5
- # @param args [Hash]
6
- # @param nested [TrueClass, FalseClass]
7
- # @return [Hash]
8
- # def hash_to_bib(args, nested = false)
9
- # ret = super
10
- # return if ret.nil?
11
-
12
- # doctype_hash_to_bib(ret)
13
- # ret
14
- # end
15
-
16
- # private
17
-
18
- # def doctype_hash_to_bib(ret)
19
- # ret
20
- # end
4
+ #
5
+ # Ovverides superclass's method
6
+ #
7
+ # @param item [Hash]
8
+ # @retirn [RelatonIec::IecBibliographicItem]
9
+ def bib_item(item)
10
+ IecBibliographicItem.new(item)
11
+ end
21
12
  end
22
13
  end
23
14
  end
@@ -10,6 +10,7 @@ module RelatonIetf
10
10
 
11
11
  # Scrapper module
12
12
  module Scrapper
13
+ GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-ietf/master/data/reference."
13
14
  RFC_URI_PATTERN = "https://xml2rfc.tools.ietf.org/public/rfc/bibxml"
14
15
  # ID_URI_PATTERN = "https://xml2rfc.tools.ietf.org/public/rfc/bibxml-ids/reference.CODE"
15
16
  BCP_URI_PATTERN = "https://www.rfc-editor.org/info/CODE"
@@ -23,18 +24,8 @@ module RelatonIetf
23
24
  def scrape_page(text, is_relation = false)
24
25
  # Remove initial "IETF " string if specified
25
26
  ref = text.gsub(/^IETF /, "")
26
-
27
- case ref
28
- when /^RFC/ then rfc_item [""], ref, is_relation
29
- when /^I-D/ then rfc_item ["3"], ref, is_relation
30
- when /^W3C/ then rfc_item ["4", "2"], ref, is_relation
31
- when /^(ANSI|CCITT|FIPS|IANA|ISO|ITU|NIST|OASIS|PKCS)/
32
- rfc_item ["2"], ref, is_relation
33
- when /^(3GPP|SDO-3GPP)/ then rfc_item ["5"], ref, is_relation
34
- when /^IEEE/ then rfc_item ["6", "2"], ref, is_relation
35
- when /^BCP/ then bcp_item BCP_URI_PATTERN.dup, ref
36
- else
37
- raise RelatonBib::RequestError, "#{ref}: not recognised for RFC"
27
+ if ref.match? /^BCP/ then bcp_item BCP_URI_PATTERN.dup, ref
28
+ else rfc_item ref, is_relation
38
29
  end
39
30
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
40
31
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
@@ -42,12 +33,12 @@ module RelatonIetf
42
33
  raise RelatonBib::RequestError, "No document found for #{ref} reference."
43
34
  end
44
35
 
45
- # @param reference [String]
36
+ # @param reference [Nokogiri::XML::Element, nil]
46
37
  # @param is_relation [TrueClass, FalseClass]
47
38
  # @param url [String, NilClass]
48
39
  # @param ver [String, NilClass] Internet Draft version
49
40
  # @return [RelatonIetf::IetfBibliographicItem]
50
- def fetch_rfc(reference, is_relation = false, url = nil, ver = nil)
41
+ def fetch_rfc(reference, is_relation = false, url = nil, ver = nil) # rubocop:disable Metrics/AbcSize
51
42
  return unless reference
52
43
 
53
44
  ietf_item(
@@ -65,7 +56,7 @@ module RelatonIetf
65
56
  series: series(reference),
66
57
  place: ["Fremont, CA"],
67
58
  keyword: reference.xpath("front/keyword").map(&:text),
68
- doctype: doctype(reference[:anchor]),
59
+ doctype: doctype(reference[:anchor])
69
60
  )
70
61
  end
71
62
  # rubocop:enable Metrics/MethodLength
@@ -75,7 +66,7 @@ module RelatonIetf
75
66
  # @param anchor [String]
76
67
  # @return [String]
77
68
  def doctype(anchor)
78
- anchor =~ /I-D/ ? "internet-draft" : "rfc"
69
+ anchor&.include?("I-D") ? "internet-draft" : "rfc"
79
70
  end
80
71
 
81
72
  # @param reference [Nokogiri::XML::Element]
@@ -86,7 +77,7 @@ module RelatonIetf
86
77
  l = []
87
78
  l << { type: "xml", content: url } if url
88
79
  l << { type: "src", content: reference[:target] } if reference[:target]
89
- if reference[:anchor] =~ /^I-D/
80
+ if /^I-D/.match? reference[:anchor]
90
81
  reference.xpath("format").each do |f|
91
82
  c = ver ? f[:target].sub(/(?<=-)\d{2}(?=\.)/, ver) : f[:target]
92
83
  l << { type: f[:type], content: c }
@@ -103,35 +94,24 @@ module RelatonIetf
103
94
  RelatonIetf::IetfBibliographicItem.new **attrs
104
95
  end
105
96
 
106
- # @param uri_nums [Array<String>]
107
97
  # @param ref [String]
108
98
  # @return [RelatonIetf::IetfBibliographicItem]
109
- def rfc_item(uri_nums, ref, is_relation)
110
- uri = nil
111
- error = nil
112
- uri_nums.each do |n|
113
- /(?<=-)(?<ver>\d{2})$/ =~ ref
114
- if n == "3"
115
- ref.sub! /-\d{2}/, "" if ver
116
- ref.sub! /(?<=I-D\.)draft-/, ""
117
- end
118
-
119
- uri = "#{RFC_URI_PATTERN}#{n}/reference.#{ref.sub(/\s|\u00a0/, ".")}.xml"
120
- begin
121
- doc = Nokogiri::XML get_page(uri)
122
- resp = fetch_rfc doc.at("//reference"), is_relation, uri, ver
123
- return resp if resp
124
- rescue RelatonBib::RequestError => e
125
- error = e
126
- end
99
+ def rfc_item(ref, is_relation)
100
+ /(?<=-)(?<ver>\d{2})$/ =~ ref
101
+ if /^I-D/.match? ref
102
+ ref.sub! /-\d{2}/, "" if ver
103
+ ref.sub! /(?<=I-D\.)draft-/, ""
127
104
  end
128
- raise error
105
+
106
+ uri = "#{GH_URL}#{ref.sub(/\s|\u00a0/, '.')}.xml"
107
+ doc = Nokogiri::XML get_page(uri)
108
+ fetch_rfc doc.at("//reference"), is_relation, uri, ver
129
109
  end
130
110
 
131
111
  # @param uri_template [String]
132
112
  # @param reference [String]
133
113
  # @return [RelatonIetf::IetfBibliographicItem]
134
- def bcp_item(uri_template, reference)
114
+ def bcp_item(uri_template, reference) # rubocop:disable Metrics/MethodLength
135
115
  uri = uri_template.sub "CODE", reference.sub(" ", "").downcase
136
116
  doc = Nokogiri::HTML get_page(uri)
137
117
  ietf_item(
@@ -141,7 +121,7 @@ module RelatonIetf
141
121
  language: ["en"],
142
122
  link: [{ type: "src", content: uri }],
143
123
  relation: fetch_relations(doc),
144
- doctype: "rfc",
124
+ doctype: "rfc"
145
125
  )
146
126
  end
147
127
 
@@ -149,7 +129,7 @@ module RelatonIetf
149
129
  doc.xpath("//table/tr/td/a[contains(., 'RFC')]").map do |r|
150
130
  RelatonBib::DocumentRelation.new(
151
131
  type: "merges",
152
- bibitem: scrape_page(r.text, true),
132
+ bibitem: scrape_page(r.text, true)
153
133
  )
154
134
  end
155
135
  end
@@ -163,10 +143,6 @@ module RelatonIetf
163
143
  res.body
164
144
  end
165
145
 
166
- # def make_uri(uri_template, reference)
167
- # uri_template.gsub("CODE", reference)
168
- # end
169
-
170
146
  # @return [String]
171
147
  def language(reference)
172
148
  reference[:lang] || "en"
@@ -195,12 +171,12 @@ module RelatonIetf
195
171
 
196
172
  # @return [Array<Hash{Symbol=>RelatonBib::Person,Symbol=>Array<String>}>]
197
173
  def persons(reference)
198
- reference.xpath("./front/author[@surname]|./front/author[@fullname]").
199
- map do |author|
174
+ reference.xpath("./front/author[@surname]|./front/author[@fullname]")
175
+ .map do |author|
200
176
  entity = RelatonBib::Person.new(
201
177
  name: full_name(author, reference),
202
178
  affiliation: [affiliation(author)],
203
- contact: contacts(author.at("./address")),
179
+ contact: contacts(author.at("./address"))
204
180
  )
205
181
  { entity: entity, role: [contributor_role(author)] }
206
182
  end
@@ -215,7 +191,7 @@ module RelatonIetf
215
191
  mem << { entity: new_org(si[:stream], nil), role: [type: "author"] }
216
192
  end
217
193
  orgs + reference.xpath(
218
- "front/author[not(@surname)][not(@fullname)]/organization",
194
+ "front/author[not(@surname)][not(@fullname)]/organization"
219
195
  ).map do |org|
220
196
  { entity: new_org(org.text, nil), role: [type: "author"] }
221
197
  end
@@ -229,7 +205,7 @@ module RelatonIetf
229
205
  RelatonBib::FullName.new(
230
206
  completename: localized_string(author[:fullname], lang),
231
207
  initial: [localized_string(author[:initials], lang)].compact,
232
- surname: localized_string(author[:surname], lang),
208
+ surname: localized_string(author[:surname], lang)
233
209
  )
234
210
  end
235
211
 
@@ -258,13 +234,13 @@ module RelatonIetf
258
234
 
259
235
  # @param postal [Nokogiri::XML::Document]
260
236
  # @rerurn [RelatonBib::Address]
261
- def address(postal)
237
+ def address(postal) # rubocop:disable Metrics/CyclomaticComplexity
262
238
  RelatonBib::Address.new(
263
239
  street: [(postal.at("./postalLine") || postal.at("./street"))&.text],
264
240
  city: postal.at("./city")&.text,
265
241
  postcode: postal.at("./code")&.text,
266
242
  country: postal.at("./country")&.text,
267
- state: postal.at("./region")&.text,
243
+ state: postal.at("./region")&.text
268
244
  )
269
245
  end
270
246
 
@@ -303,7 +279,7 @@ module RelatonIetf
303
279
 
304
280
  def month(mon)
305
281
  return 1 if !mon || mon.empty?
306
- return mon if /^\d+$/ =~ mon
282
+ return mon if /^\d+$/.match? mon
307
283
 
308
284
  Date::MONTHNAMES.index(mon)
309
285
  end
@@ -332,12 +308,12 @@ module RelatonIetf
332
308
  #
333
309
  # @return [Array<RelatonBib::DocumentIdentifier>]
334
310
  #
335
- def docids(reference, ver)
311
+ def docids(reference, ver) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
336
312
  id = (reference[:anchor] || reference[:docName] || reference[:number])
337
313
  ret = []
338
314
  if id
339
315
  ret << RelatonBib::DocumentIdentifier.new(
340
- type: "IETF", id: id.sub(/^(RFC)/, "\\1 "),
316
+ type: "IETF", id: id.sub(/^(RFC)/, "\\1 ")
341
317
  )
342
318
  end
343
319
  if (id = reference[:anchor])
@@ -365,10 +341,10 @@ module RelatonIetf
365
341
 
366
342
  RelatonBib::Series.new(
367
343
  title: RelatonBib::TypedTitleString.new(
368
- content: si[:name], language: language(reference), script: "Latn",
344
+ content: si[:name], language: language(reference), script: "Latn"
369
345
  ),
370
346
  number: si[:value],
371
- type: "main",
347
+ type: "main"
372
348
  )
373
349
  end.compact
374
350
  end
@@ -383,9 +359,7 @@ module RelatonIetf
383
359
  st = reference.at("./seriesinfo[@status]")
384
360
  return unless st
385
361
 
386
- RelatonBib::DocumentStatus.new(
387
- stage: st[:status],
388
- )
362
+ RelatonBib::DocumentStatus.new(stage: st[:status])
389
363
  end
390
364
  end
391
365
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIetf
2
- VERSION = "1.5.pre".freeze
2
+ VERSION = "1.7.1".freeze
3
3
  end
data/relaton_ietf.gemspec CHANGED
@@ -40,5 +40,5 @@ Gem::Specification.new do |spec|
40
40
  spec.add_development_dependency "vcr"
41
41
  spec.add_development_dependency "webmock"
42
42
 
43
- spec.add_dependency "relaton-bib", "~> 1.5.pre"
43
+ spec.add_dependency "relaton-bib", "~> 1.7.0"
44
44
  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.5.pre
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-07 00:00:00.000000000 Z
11
+ date: 2021-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.5.pre
159
+ version: 1.7.0
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: 1.5.pre
166
+ version: 1.7.0
167
167
  description: "RelatonIetf: retrieve IETF Standards for bibliographic use \nusing the
168
168
  BibliographicItem model.\n\nFormerly known as rfcbib.\n"
169
169
  email:
@@ -216,9 +216,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
216
216
  version: 2.4.0
217
217
  required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  requirements:
219
- - - ">"
219
+ - - ">="
220
220
  - !ruby/object:Gem::Version
221
- version: 1.3.1
221
+ version: '0'
222
222
  requirements: []
223
223
  rubygems_version: 3.0.6
224
224
  signing_key: