1 # Copyright (C) 2008 Dag Odenhall <dag.odenhall@gmail.com>
2 # Licensed under the Academic Free License version 3.0
4 require 'amazing/widget'
9 description "Unread posts in raggle"
10 dependency "pstore", "Ruby standard library"
11 option :feed_list_path, "Path to feeds list", ".raggle/feeds.yaml"
12 option :feed_cache_path, "Path to feeds cache", ".raggle/feed_cache.store"
13 field :count, "Ammount of unread posts", 0
17 @feed_list_path = "#{ENV["HOME"]}/#@feed_list_path" if @feed_list_path[0] != ?/
18 feeds = YAML.load_file(@feed_list_path)
19 @feed_cache_path = "#{ENV["HOME"]}/#{@feed_cache_path}" if @feed_cache_path[0] != ?/
20 cache = PStore.new(@feed_cache_path)
21 cache.transaction(false) do
23 cache[feed["url"]].each do |item|
24 @count += 1 unless item["read?"]