diff options
author | Alex Legler <alex@a3li.li> | 2015-03-14 13:02:03 +0100 |
---|---|---|
committer | Alex Legler <alex@a3li.li> | 2015-03-14 13:02:03 +0100 |
commit | 130827d8abc0794b8496b06dc836303a35bc443e (patch) | |
tree | 59cf464419a725aa62994f948788465727801669 | |
parent | Update gem versions (diff) | |
download | security-130827d8abc0794b8496b06dc836303a35bc443e.tar.gz security-130827d8abc0794b8496b06dc836303a35bc443e.tar.bz2 security-130827d8abc0794b8496b06dc836303a35bc443e.zip |
Explicitly sort IDs
-rw-r--r-- | anzen.rb | 6 | ||||
-rw-r--r-- | lib/glsa_repository.rb | 9 |
2 files changed, 12 insertions, 3 deletions
@@ -24,13 +24,13 @@ GLSARepository.instance BASE_URL = 'https://security.gentoo.org/'.freeze get '/glsa/?' do - @ids = GLSARepository.instance.get.keys.reverse + @ids = GLSARepository.instance.latest_ids @nav = :glsa erb :glsa end get '/glsa/feed.:format' do - items = GLSARepository.instance.get.values.reverse[0..50] + items = GLSARepository.instance.latest 50 case params[:format] when 'atom' content_type :atom @@ -87,7 +87,7 @@ get '/subscribe' do end get '/' do - @ids = GLSARepository.instance.get.keys.reverse + @ids = GLSARepository.instance.latest_ids @nav = :index erb :index end diff --git a/lib/glsa_repository.rb b/lib/glsa_repository.rb index 90c9899..ee1096b 100644 --- a/lib/glsa_repository.rb +++ b/lib/glsa_repository.rb @@ -32,12 +32,21 @@ class GLSARepository @load_date = DateTime.now @advisories = advisories.freeze + @latest = advisories.keys.sort.reverse.freeze end def get @advisories end + def latest_ids + @latest + end + + def latest(n = 10) + @latest[0..n].map {|id| @advisories[id] } + end + def[](id) @advisories[id] end |