relaton-ietf 1.10.4 → 1.11.0

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: aea00f6f466ab9780b8fbb93cd69ea04e7bd099ab8793be0edd6be843143a3f6
4
- data.tar.gz: a9259ce6290b92dc98679aded761e2563d4771118f4a44434142cd26b3248c4e
3
+ metadata.gz: 487865677406ccb87b65d3f4064c60bef7d26b7955817dd7030c4272eabf3e3f
4
+ data.tar.gz: 818d190f6bcb3d91a9b5a0bf7ebe8e5acd20e3f1e46de30c1b7e6e9b4435116b
5
5
  SHA512:
6
- metadata.gz: 7d4cf8fc6b8ce6483732b0c8f350596a41cd76ac35001e0257f683ebf854646cb473f08d293e40b8fc84cee61527ab421bd6178ba5a2f14ec32a29c4c2ac97c0
7
- data.tar.gz: c8016eb29a720c92dc25c4e364a5877d31fa1aa0cffa6bb5acae164ec9a169c0022e4c6eb6cc5b3b05963ae74b5a922cb036e0c196d205fe85907cd9d22cd79c
6
+ metadata.gz: 1f2553900686f5c7a1a3653b0e9546510448e79dde9965d8c1aa604377bde3489d805bdd13ae68128bfa7f49fd4037d588584c3dcc3ca594579f5410c6cb0b6e
7
+ data.tar.gz: 1a0599db3efa91cfd7360f53cc77bffdb1fcf7b445f2fc56e9d2957634826adf71be8c54a75e71e2b5e4619e91c00d7b351b01eb01c16535be2c3602281ba45d
data/README.adoc CHANGED
@@ -135,7 +135,7 @@ RelatonIetf::IetfBibliographicItem.from_hash hash
135
135
 
136
136
  === Fetch data
137
137
 
138
- There is a IETF datasets what can be converted into RelatonXML/BibXML/BibYAML formats:
138
+ There are IETF datasets what can be converted into RelatonXML/BibXML/BibYAML formats:
139
139
 
140
140
  - `ietf-rfcsubseries` - https://www.rfc-editor.org/rfc-index.xml (`<bcp-entry>`, `<fyi-entry>`, `<std-entry>`)
141
141
  - `ietf-internet-drafts` - converts files from local directory `./bibxml-ids`. Use `rsync -avcizxL rsync.ietf.org::bibxml-ids ./bibxml-ids` command to fetch the files.
@@ -173,9 +173,11 @@
173
173
  <data type="dateTime"/>
174
174
  </attribute>
175
175
  </optional>
176
- <attribute name="from">
177
- <data type="IDREF"/>
178
- </attribute>
176
+ <optional>
177
+ <attribute name="from">
178
+ <data type="IDREF"/>
179
+ </attribute>
180
+ </optional>
179
181
  <optional>
180
182
  <attribute name="to">
181
183
  <data type="IDREF"/>
@@ -624,6 +626,9 @@
624
626
  <choice>
625
627
  <ref name="PureTextElement"/>
626
628
  <ref name="stem"/>
629
+ <ref name="eref"/>
630
+ <ref name="xref"/>
631
+ <ref name="hyperlink"/>
627
632
  </choice>
628
633
  </zeroOrMore>
629
634
  </element>
@@ -634,6 +639,9 @@
634
639
  <choice>
635
640
  <ref name="PureTextElement"/>
636
641
  <ref name="stem"/>
642
+ <ref name="eref"/>
643
+ <ref name="xref"/>
644
+ <ref name="hyperlink"/>
637
645
  </choice>
638
646
  </zeroOrMore>
639
647
  </element>
@@ -641,7 +649,12 @@
641
649
  <define name="tt">
642
650
  <element name="tt">
643
651
  <zeroOrMore>
644
- <ref name="PureTextElement"/>
652
+ <choice>
653
+ <ref name="PureTextElement"/>
654
+ <ref name="eref"/>
655
+ <ref name="xref"/>
656
+ <ref name="hyperlink"/>
657
+ </choice>
645
658
  </zeroOrMore>
646
659
  </element>
647
660
  </define>
@@ -822,7 +835,9 @@
822
835
  <attribute name="alt"/>
823
836
  </optional>
824
837
  <ref name="CitationType"/>
825
- <text/>
838
+ <oneOrMore>
839
+ <ref name="PureTextElement"/>
840
+ </oneOrMore>
826
841
  </define>
827
842
  <define name="hyperlink">
828
843
  <element name="link">
@@ -835,7 +850,9 @@
835
850
  <optional>
836
851
  <attribute name="alt"/>
837
852
  </optional>
838
- <text/>
853
+ <oneOrMore>
854
+ <ref name="PureTextElement"/>
855
+ </oneOrMore>
839
856
  </element>
840
857
  </define>
841
858
  <define name="xref">
@@ -849,7 +866,9 @@
849
866
  <optional>
850
867
  <attribute name="alt"/>
851
868
  </optional>
852
- <text/>
869
+ <oneOrMore>
870
+ <ref name="PureTextElement"/>
871
+ </oneOrMore>
853
872
  </element>
854
873
  </define>
855
874
  <define name="fn">
data/grammars/biblio.rng CHANGED
@@ -677,6 +677,9 @@
677
677
  <zeroOrMore>
678
678
  <ref name="extent"/>
679
679
  </zeroOrMore>
680
+ <optional>
681
+ <ref name="bibliographic_size"/>
682
+ </optional>
680
683
  <zeroOrMore>
681
684
  <ref name="accesslocation"/>
682
685
  </zeroOrMore>
@@ -922,9 +925,29 @@
922
925
  <text/>
923
926
  </element>
924
927
  </define>
928
+ <define name="sizevalue">
929
+ <element name="value">
930
+ <attribute name="type"/>
931
+ <text/>
932
+ </element>
933
+ </define>
934
+ <define name="bibliographic_size">
935
+ <element name="size">
936
+ <oneOrMore>
937
+ <ref name="sizevalue"/>
938
+ </oneOrMore>
939
+ </element>
940
+ </define>
925
941
  <define name="extent">
926
942
  <element name="extent">
927
- <ref name="BibItemLocality"/>
943
+ <choice>
944
+ <zeroOrMore>
945
+ <ref name="locality"/>
946
+ </zeroOrMore>
947
+ <zeroOrMore>
948
+ <ref name="localityStack"/>
949
+ </zeroOrMore>
950
+ </choice>
928
951
  </element>
929
952
  </define>
930
953
  <define name="series">
data/grammars/ietf.rng CHANGED
@@ -345,7 +345,7 @@
345
345
  <optional>
346
346
  <attribute name="format"/>
347
347
  </optional>
348
- <text/>
348
+ <ref name="XrefBody"/>
349
349
  </element>
350
350
  </define>
351
351
  <define name="erefType">
data/grammars/isodoc.rng CHANGED
@@ -152,9 +152,7 @@
152
152
  <data type="boolean"/>
153
153
  </attribute>
154
154
  </optional>
155
- <oneOrMore>
156
- <ref name="PureTextElement"/>
157
- </oneOrMore>
155
+ <ref name="XrefBody"/>
158
156
  </element>
159
157
  </define>
160
158
  <define name="erefType">
@@ -188,6 +186,42 @@
188
186
  <ref name="PureTextElement"/>
189
187
  </oneOrMore>
190
188
  </define>
189
+ <define name="localityStack">
190
+ <element name="localityStack">
191
+ <optional>
192
+ <attribute name="connective">
193
+ <choice>
194
+ <value>and</value>
195
+ <value>or</value>
196
+ <value>from</value>
197
+ <value>to</value>
198
+ <value/>
199
+ </choice>
200
+ </attribute>
201
+ </optional>
202
+ <zeroOrMore>
203
+ <ref name="locality"/>
204
+ </zeroOrMore>
205
+ </element>
206
+ </define>
207
+ <define name="sourceLocalityStack">
208
+ <element name="sourceLocalityStack">
209
+ <optional>
210
+ <attribute name="connective">
211
+ <choice>
212
+ <value>and</value>
213
+ <value>or</value>
214
+ <value>from</value>
215
+ <value>to</value>
216
+ <value/>
217
+ </choice>
218
+ </attribute>
219
+ </optional>
220
+ <zeroOrMore>
221
+ <ref name="sourceLocality"/>
222
+ </zeroOrMore>
223
+ </element>
224
+ </define>
191
225
  <define name="ul">
192
226
  <element name="ul">
193
227
  <attribute name="id">
@@ -1098,6 +1132,16 @@
1098
1132
  </define>
1099
1133
  </include>
1100
1134
  <!-- end overrides -->
1135
+ <define name="image" combine="choice">
1136
+ <element name="svg">
1137
+ <oneOrMore>
1138
+ <choice>
1139
+ <text/>
1140
+ <ref name="AnyElement"/>
1141
+ </choice>
1142
+ </oneOrMore>
1143
+ </element>
1144
+ </define>
1101
1145
  <define name="MultilingualRenderingType">
1102
1146
  <choice>
1103
1147
  <value>common</value>
@@ -2631,4 +2675,30 @@
2631
2675
  </zeroOrMore>
2632
2676
  </element>
2633
2677
  </define>
2678
+ <define name="XrefBody">
2679
+ <zeroOrMore>
2680
+ <ref name="XrefTarget"/>
2681
+ </zeroOrMore>
2682
+ <oneOrMore>
2683
+ <ref name="PureTextElement"/>
2684
+ </oneOrMore>
2685
+ </define>
2686
+ <define name="XrefTarget">
2687
+ <element name="location">
2688
+ <attribute name="target">
2689
+ <data type="string">
2690
+ <param name="pattern">\i\c*|\c+#\c+</param>
2691
+ </data>
2692
+ </attribute>
2693
+ <attribute name="connective">
2694
+ <choice>
2695
+ <value>and</value>
2696
+ <value>or</value>
2697
+ <value>from</value>
2698
+ <value>to</value>
2699
+ <value/>
2700
+ </choice>
2701
+ </attribute>
2702
+ </element>
2703
+ </define>
2634
2704
  </grammar>
data/grammars/reqt.rng CHANGED
@@ -58,6 +58,14 @@
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>
@@ -101,7 +109,9 @@
101
109
  </define>
102
110
  <define name="label">
103
111
  <element name="label">
104
- <text/>
112
+ <oneOrMore>
113
+ <ref name="TextElement"/>
114
+ </oneOrMore>
105
115
  </element>
106
116
  </define>
107
117
  <define name="subject">
@@ -175,6 +185,14 @@
175
185
  <data type="boolean"/>
176
186
  </attribute>
177
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>
178
196
  <oneOrMore>
179
197
  <ref name="BasicBlock"/>
180
198
  </oneOrMore>
@@ -64,11 +64,93 @@ module RelatonIetf
64
64
  # Fetches ietf-internet-drafts documents
65
65
  #
66
66
  def fetch_ieft_internet_drafts # rubocop:disable Metrics/MethodLength
67
- Dir["bibxml-ids/*.xml"].each do |file|
68
- save_doc BibXMLParser.parse(File.read(file, encoding: "UTF-8"))
67
+ versions = Dir["bibxml-ids/*.xml"].each_with_object([]) do |path, vers|
68
+ file = File.basename path, ".xml"
69
+ if file.include?("D.draft-")
70
+ vers << file.sub(/^reference\.I-D\./, "")
71
+ end
72
+ save_doc BibXMLParser.parse(File.read(path, encoding: "UTF-8"))
69
73
  end
74
+ update_versions(versions) if versions.any? && @format != "bibxml"
70
75
  end
71
76
 
77
+ #
78
+ # Updates I-D's versions
79
+ #
80
+ # @param [Array<String>] versions list of versions
81
+ #
82
+ def update_versions(versions) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
83
+ series = ""
84
+ bib_versions = []
85
+ Dir["#{@output}/*.#{@ext}"].each do |file|
86
+ match = /(?<series>draft-.+)-(?<ver>\d{2})\.#{@ext}$/.match file
87
+ if match
88
+ if series != match[:series]
89
+ bib_versions = versions.select { |ref| ref.include? match[:series] }
90
+ create_series match[:series], bib_versions
91
+ end
92
+ lv = bib_versions.select { |ref| ref.match(/\d+$/).to_s.to_i < match[:ver].to_i }
93
+ hv = bib_versions.select { |ref| ref.match(/\d+$/).to_s.to_i > match[:ver].to_i }
94
+ if lv.any? || hv.any?
95
+ bib = read_doc(file)
96
+ bib.relation << version_relation(lv.last, "updates") if lv.any?
97
+ bib.relation << version_relation(hv.first, "updatedBy") if hv.any?
98
+ save_doc bib, check_duplicate: false
99
+ end
100
+ series = match[:series]
101
+ end
102
+ end
103
+ end
104
+
105
+ #
106
+ # Create unversioned bibliographic item
107
+ #
108
+ # @param [String] ref reference
109
+ # @param [Array<String>] versions list of versions
110
+ #
111
+ def create_series(ref, versions)
112
+ return if versions.size < 2
113
+
114
+ fref = RelatonBib::FormattedRef.new content: ref
115
+ rel = versions.map do |v|
116
+ version_relation v, "includes"
117
+ end
118
+ save_doc IetfBibliographicItem.new(formattedref: fref, relation: rel)
119
+ end
120
+
121
+ #
122
+ # Create bibitem relation
123
+ #
124
+ # @param [String] ref reference
125
+ # @param [String] type relation type
126
+ #
127
+ # @return [RelatonBib::DocumentRelation] relation
128
+ #
129
+ def version_relation(ref, type)
130
+ fref = RelatonBib::FormattedRef.new content: ref
131
+ bibitem = IetfBibliographicItem.new formattedref: fref
132
+ RelatonBib::DocumentRelation.new(type: type, bibitem: bibitem)
133
+ end
134
+
135
+ #
136
+ # Redad saved documents
137
+ #
138
+ # @param [String] file path to file
139
+ #
140
+ # @return [RelatonIetf::IetfBibliographicItem] bibliographic item
141
+ #
142
+ def read_doc(file)
143
+ doc = File.read(file, encoding: "UTF-8")
144
+ case @format
145
+ when "xml" then XMLParser.from_xml(doc)
146
+ when "yaml" then IetfBibliographicItem.from_hash YAML.safe_load(doc)
147
+ else BibXMLParser.parse(doc)
148
+ end
149
+ end
150
+
151
+ #
152
+ # Fetches ietf-rfc-entries documents
153
+ #
72
154
  def fetch_ieft_rfcs
73
155
  rfc_index.xpath("xmlns:rfc-entry").each do |doc|
74
156
  save_doc RfcEntry.parse(doc)
@@ -78,6 +160,11 @@ module RelatonIetf
78
160
  end
79
161
  end
80
162
 
163
+ #
164
+ # Get RFC index
165
+ #
166
+ # @return [Nokogiri::XML::Document] RFC index
167
+ #
81
168
  def rfc_index
82
169
  uri = URI "https://www.rfc-editor.org/rfc-index.xml"
83
170
  Nokogiri::XML(Net::HTTP.get(uri)).at("/xmlns:rfc-index")
@@ -87,8 +174,9 @@ module RelatonIetf
87
174
  # Save document to file
88
175
  #
89
176
  # @param [RelatonIetf::RfcIndexEntry, nil] rfc index entry
177
+ # @param [Boolean] check_duplicate check for duplicate
90
178
  #
91
- def save_doc(entry) # rubocop:disable Metrics/MethodLength
179
+ def save_doc(entry, check_duplicate: true) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
92
180
  return unless entry
93
181
 
94
182
  c = case @format
@@ -97,9 +185,9 @@ module RelatonIetf
97
185
  else entry.send("to_#{@format}")
98
186
  end
99
187
  file = file_name entry
100
- if @files.include? file
188
+ if check_duplicate && @files.include?(file)
101
189
  warn "File #{file} already exists. Document: #{entry.docnumber}"
102
- else
190
+ elsif check_duplicate
103
191
  @files << file
104
192
  end
105
193
  File.write file, c, encoding: "UTF-8"
@@ -112,11 +200,11 @@ module RelatonIetf
112
200
  #
113
201
  # @return [String] file name
114
202
  #
115
- def file_name(entry)
203
+ def file_name(entry) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
116
204
  id = if entry.respond_to? :docidentifier
117
205
  entry.docidentifier.detect { |i| i.type == "Internet-Draft" }&.id
118
206
  end
119
- id ||= entry.docnumber
207
+ id ||= entry.docnumber || entry.formattedref.content
120
208
  if @source == "ietf-internet-drafts" then id.downcase!
121
209
  else id.upcase!
122
210
  end
@@ -68,7 +68,7 @@ module RelatonIetf
68
68
  def parse_docid
69
69
  ids = [
70
70
  RelatonBib::DocumentIdentifier.new(id: pub_id, type: "IETF", primary: true),
71
- RelatonBib::DocumentIdentifier.new(id: code, type: "IETF", scope: "anchor"),
71
+ RelatonBib::DocumentIdentifier.new(id: anchor, type: "IETF", scope: "anchor"),
72
72
  ]
73
73
  doi = @doc.at("./xmlns:doi").text
74
74
  ids << RelatonBib::DocumentIdentifier.new(id: doi, type: "DOI")
@@ -112,14 +112,22 @@ module RelatonIetf
112
112
  @doc.at("./xmlns:doc-id").text
113
113
  end
114
114
 
115
+ #
116
+ # Create acnhor
117
+ #
118
+ # @return [String] anchor
119
+ #
120
+ def anchor
121
+ "RFC#{docnum}"
122
+ end
123
+
115
124
  #
116
125
  # Create link
117
126
  #
118
127
  # @return [Array<RelatonBib::TypedUri>]
119
128
  #
120
129
  def parse_link
121
- num = code[-4..-1].sub(/^0+/, "")
122
- url = "https://www.rfc-editor.org/info/rfc#{num}"
130
+ url = "https://www.rfc-editor.org/info/rfc#{docnum}"
123
131
  [RelatonBib::TypedUri.new(content: url, type: "src")]
124
132
  end
125
133
 
@@ -19,7 +19,7 @@ module RelatonIetf
19
19
  #
20
20
  # @param [Nokogiri::XML::Element] doc document
21
21
  #
22
- # @return [RelatonIetf:IetfBibliographicItem, nil]
22
+ # @return [RelatonIetf::IetfBibliographicItem, nil]
23
23
  #
24
24
  def self.parse(doc)
25
25
  doc_id = doc.at("./xmlns:doc-id")
@@ -55,7 +55,7 @@ module RelatonIetf
55
55
  def parse_docid
56
56
  [
57
57
  RelatonBib::DocumentIdentifier.new(type: "IETF", id: pub_id, primary: true),
58
- RelatonBib::DocumentIdentifier.new(type: "IETF", scope: "anchor", id: @doc_id),
58
+ RelatonBib::DocumentIdentifier.new(type: "IETF", scope: "anchor", id: anchor),
59
59
  ]
60
60
  end
61
61
 
@@ -78,9 +78,9 @@ module RelatonIetf
78
78
  end
79
79
 
80
80
  def parse_relation
81
- @is_also.map do |ref|
81
+ @is_also.each_with_object([]) do |ref, a|
82
82
  bib = IetfBibliography.get ref.sub(/^(RFC)(\d+)/, '\1 \2')
83
- { type: "includes", bibitem: bib }
83
+ a << { type: "includes", bibitem: bib } if bib
84
84
  end
85
85
  end
86
86
  end
@@ -1,3 +1,3 @@
1
1
  module RelatonIetf
2
- VERSION = "1.10.4".freeze
2
+ VERSION = "1.11.0".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.10.1"
41
+ spec.add_dependency "relaton-bib", "~> 1.11.0"
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.10.4
4
+ version: 1.11.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: 2022-03-01 00:00:00.000000000 Z
11
+ date: 2022-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.10.1
131
+ version: 1.11.0
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.10.1
138
+ version: 1.11.0
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: