Skip to content

Instantly share code, notes, and snippets.

@tujlaky
Created January 21, 2016 13:30
Show Gist options
  • Save tujlaky/e0d5971524f57009d49b to your computer and use it in GitHub Desktop.
Save tujlaky/e0d5971524f57009d49b to your computer and use it in GitHub Desktop.
Get arch linux RSS
#!/usr/local/rvm/wrappers/ruby-2.1.1/ruby
# encoding: UTF-8
require 'rss'
require 'open-uri'
require 'i18n'
I18n.backend.store_translations :hu, {
:date => {
:formats => {
:default => "%Y.%m.%d"
},
:month_names => %w(január február március április május június július augusztus szeptember október november december).unshift(nil)
}
}
I18n.config.enforce_available_locales = false
# Class to get arch linux rss feed
class ArchRss
attr_accessor :url
def initialize(url)
@url = url
end
def fetch_rss
open(@url) do |rss|
feed = RSS::Parser.parse(rss)
first=feed.items.first
puts first.title
puts I18n::localize(first.pubDate, :format => '%Y. %B %d. %H:%M', :locale => 'hu')
end
end
end
rss=ArchRss.new('https://www.archlinux.org/feeds/news/')
rss.fetch_rss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment