Module: RfcReader::Recent

Defined in:
lib/rfc_reader/recent.rb

Class Method Summary collapse

Class Method Details

.fetchString



18
19
20
21
22
# File 'lib/rfc_reader/recent.rb', line 18

def self.fetch
  ErrorContext.wrap("Fetching the recent RFCs list") do
    Net::HTTP.get(RECENT_RFCS_RSS_URI)
  end
end

.listHash<String, String>



12
13
14
15
# File 'lib/rfc_reader/recent.rb', line 12

def self.list
  xml = fetch
  parse(xml)
end

.parse(xml) ⇒ Hash<String, String>

Example: XML fragment we’re trying to parse title and link data from.

“‘xml <item>

<title>
RFC 9624: EVPN Broadcast, Unknown Unicast, or Multicast (BUM) Using Bit Index Explicit Replication (BIER)
</title>
<link>https://www.rfc-editor.org/info/rfc9624</link>
<description>
This document specifies protocols and procedures for forwarding Broadcast, Unknown Unicast, or Multicast (BUM) traffic of Ethernet VPNs (EVPNs) using Bit Index Explicit Replication (BIER).
</description>

</item> “‘



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rfc_reader/recent.rb', line 40

def self.parse(xml)
  ErrorContext.wrap("Parsing the recent RFCs list") do
    RSS::Parser.parse(xml).items.to_h do |item|
      # The link is to the webpage and not the plaintext document so we must convert it.
      file_name = File.basename(item.link.href)

      [
        item.title.content,
        "https://www.rfc-editor.org/rfc/#{file_name}.txt",
      ]
    end
  end
end