relaton-ietf 1.9.8 → 1.9.12

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: 9c56a40e6b16ec11c29b7b10ade3c09b071f4eddc84402d8d22909af910af8fa
4
- data.tar.gz: 619f416b504b40dc9515cc2ca05c2bd3abffc2fc800eb473adfd2366bb63e068
3
+ metadata.gz: c189b76c5cd1565d79d2b910449c708bd759419e38fafd7cc8a96d0bfc2eab9a
4
+ data.tar.gz: cefad1d99e228226e1ac6ac5fdaf627911006a1e67d8ed93babb108150f4631b
5
5
  SHA512:
6
- metadata.gz: 27fe700492c5e5d7b4f437a281912c2719cc18ec9656c85db6289a978847043f5e52ba011d2e1801304744166ce9091ba24ce5ec00005d5edde09d4d10a0cd8c
7
- data.tar.gz: 94919d5a441b27673e10315d5f5cd8670515de252b0e925fb431d9698bfd8e5a40e719684ad61019e93471eb0add922743a6abd98abafd2402b18de764ca09a5
6
+ metadata.gz: fec8da43d98eadd06a4e511399fee9832dccbd4783a69268bd4762901270051c4eb275b8c91b9da3d9360fe86ba740e488d263cd697884f144a3749dfc6e26bf
7
+ data.tar.gz: 4a7c370e2e1825df2474be9796855f024aed008c30f737e087abb0bf8b02aed03d1332221c3eb8f71a7a3d51913eee215c1b77c21e6848ab01731e77fa8b5da6
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /bibxml-ids/
9
10
  .vscode/
10
11
 
11
12
  # rspec failure tracking
data/README.adoc CHANGED
@@ -138,7 +138,7 @@ RelatonIetf::IetfBibliographicItem.from_hash hash
138
138
  There is a 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
- - `ietf-internet-drafts` - https://www.ietf.org/lib/dt/sprint/bibxml-ids.tgz
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.
142
142
  - `ietf-rfc-entries` - https://www.rfc-editor.org/rfc-index.xml (`<rfc-entry>`)
143
143
 
144
144
  The method `RelatonIetf::DataFetcher.fetch(source, output: "data", format: "yaml")` converts all the documents from the dataset and save them to the `./data` folder in YAML format.
@@ -1,6 +1,6 @@
1
- require "rubygems"
2
- require "rubygems/package"
3
- require "zlib"
1
+ # require "rubygems"
2
+ # require "rubygems/package"
3
+ # require "zlib"
4
4
  require "relaton_ietf/rfc_index_entry"
5
5
  require "relaton_ietf/rfc_entry"
6
6
 
@@ -64,16 +64,19 @@ 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?
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
74
 
75
- save_doc RelatonBib::BibXMLParser.parse(tarfile.read)
76
- end
75
+ # save_doc BibXMLParser.parse(tarfile.read)
76
+ # end
77
+ # end
78
+ Dir["bibxml-ids/*.xml"].each do |file|
79
+ save_doc BibXMLParser.parse(File.read(file, encoding: "UTF-8"))
77
80
  end
78
81
  end
79
82
 
@@ -41,17 +41,35 @@ module RelatonIetf
41
41
  abstract: parse_abstract,
42
42
  relation: parse_relation,
43
43
  status: parse_status,
44
+ series: parse_series,
44
45
  editorialgroup: parse_editorialgroup,
45
46
  )
46
47
  end
47
48
 
49
+ #
50
+ # Parse series
51
+ #
52
+ # @return [Array<RelatonBib::Series>] series
53
+ #
54
+ def parse_series
55
+ title = RelatonBib::TypedTitleString.new(content: "RFC")
56
+ @doc.xpath("./xmlns:is-also/xmlns:doc-id").map do |s|
57
+ /^(?<name>\D+)(?<num>\d+)/ =~ s.text
58
+ t = RelatonBib::TypedTitleString.new(content: name)
59
+ RelatonBib::Series.new title: t, number: num.gsub(/^0+/, "")
60
+ end + [RelatonBib::Series.new(title: title, number: docnum)]
61
+ end
62
+
48
63
  #
49
64
  # Parse document identifiers
50
65
  #
51
66
  # @return [Array<RelatonBib::DocumentIdettifier>] document identifiers
52
67
  #
53
68
  def parse_docid
54
- ids = [RelatonBib::DocumentIdentifier.new(id: pub_id, type: "IETF")]
69
+ ids = [
70
+ RelatonBib::DocumentIdentifier.new(id: pub_id, type: "IETF"),
71
+ RelatonBib::DocumentIdentifier.new(id: code, type: "IETF", scope: "anchor"),
72
+ ]
55
73
  doi = @doc.at("./xmlns:doi").text
56
74
  ids << RelatonBib::DocumentIdentifier.new(id: doi, type: "DOI")
57
75
  ids
@@ -73,7 +91,16 @@ module RelatonIetf
73
91
  # @return [String] PubID
74
92
  #
75
93
  def pub_id
76
- "IETF #{code.sub(/^(RFC)(\d+)/, '\1 \2')}"
94
+ "RFC #{docnum}"
95
+ end
96
+
97
+ #
98
+ # Parse document number
99
+ #
100
+ # @return [String] document number
101
+ #
102
+ def docnum
103
+ /\d+$/.match(code).to_s.sub(/^0+/, "")
77
104
  end
78
105
 
79
106
  #
@@ -118,8 +145,11 @@ module RelatonIetf
118
145
  def parse_contributor
119
146
  @doc.xpath("./xmlns:author").map do |contributor|
120
147
  n = contributor.at("./xmlns:name").text
121
- name = RelatonBib::LocalizedString.new( n, "en", "Latn")
122
- fname = RelatonBib::FullName.new(completename: name)
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)
123
153
  person = RelatonBib::Person.new(name: fname)
124
154
  RelatonBib::ContributionInfo.new(entity: person, role: [{ type: "author" }])
125
155
  end
@@ -141,7 +171,10 @@ module RelatonIetf
141
171
  #
142
172
  def parse_abstract
143
173
  @doc.xpath("./xmlns:abstract").map do |c|
144
- RelatonBib::FormattedString.new(content: c.text, language: "en",
174
+ content = c.xpath("./xmlns:p").map do |p|
175
+ "<#{p.name}>#{p.text.strip}</#{p.name}>"
176
+ end.join
177
+ RelatonBib::FormattedString.new(content: content, language: "en",
145
178
  script: "Latn", format: "text/html")
146
179
  end
147
180
  end
@@ -19,7 +19,7 @@ module RelatonIetf
19
19
  #
20
20
  # @param [Nokogiri::XML::Element] doc document
21
21
  #
22
- # @return [RelatonIetf:RfcIndexEntry, nil]
22
+ # @return [RelatonIetf:IetfBibliographicItem, nil]
23
23
  #
24
24
  def self.parse(doc)
25
25
  doc_id = doc.at("./xmlns:doc-id")
@@ -54,14 +54,14 @@ module RelatonIetf
54
54
 
55
55
  def parse_docid
56
56
  [
57
- RelatonBib::DocumentIdentifier.new(type: "IETF", scope: "rfc-anchor", id: anchor),
58
- # RelatonBib::DocumentIdentifier.new(type: "rfc-anchor", id: anchor),
57
+ RelatonBib::DocumentIdentifier.new(type: "IETF", id: pub_id),
58
+ RelatonBib::DocumentIdentifier.new(type: "IETF", scope: "anchor", id: @doc_id),
59
59
  ]
60
60
  end
61
61
 
62
- # def pub_id
63
- # "IETF #{@name.upcase} #{@shortnum}"
64
- # end
62
+ def pub_id
63
+ "#{@name.upcase} #{@shortnum}"
64
+ end
65
65
 
66
66
  def anchor
67
67
  "#{@name.upcase}#{@shortnum}"
@@ -1,3 +1,3 @@
1
1
  module RelatonIetf
2
- VERSION = "1.9.8".freeze
2
+ VERSION = "1.9.12".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.12"
42
- spec.add_dependency "zlib", "~> 1.1.0"
41
+ spec.add_dependency "relaton-bib", ">= 1.9.19"
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.8
4
+ version: 1.9.12
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-12-28 00:00:00.000000000 Z
11
+ date: 2022-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: equivalent-xml
@@ -128,28 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
- version: 1.9.12
131
+ version: 1.9.19
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.12
139
- - !ruby/object:Gem::Dependency
140
- name: zlib
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 1.1.0
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 1.1.0
138
+ version: 1.9.19
153
139
  description: "RelatonIetf: retrieve IETF Standards for bibliographic use \nusing the
154
140
  BibliographicItem model.\n\nFormerly known as rfcbib.\n"
155
141
  email: