1 # Copyright 2008 Dag Odenhall <dag.odenhall@gmail.com>
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 require 'amazing/widget'
20 description "Unread posts in raggle"
21 dependency "pstore", "Ruby standard library"
22 option :feed_list_path, "Path to feeds list", "~/.raggle/feeds.yaml"
23 option :feed_cache_path, "Path to feeds cache", "~/.raggle/feed_cache.store"
24 field :count, "Ammount of unread posts", 0
28 @feed_list_path = ::File.expand_path(@feed_list_path, "~")
29 feeds = YAML.load_file(@feed_list_path)
30 @feed_cache_path = ::File.expand_path(@feed_cache_path, "~")
31 cache = PStore.new(@feed_cache_path)
32 cache.transaction(false) do
34 cache[feed["url"]].each do |item|
35 @count += 1 unless item["read?"]