lib/rrimm/config.rb in rrimm-0.12.1 vs lib/rrimm/config.rb in rrimm-0.14.0
- old
+ new
@@ -1,19 +1,19 @@
require 'colorize'
module RRImm
class Config
attr :feeds, :cache
- attr :default_formatter, :pipe
+ attr :default_formatter, :publisher
attr_accessor :output
def initialize
@feeds = {}
cache "default cache" do
path File.join(ENV['HOME'], '.cache', 'rrimm')
end
- @pipe = "cat"
+ @publisher = RRImm::Pipe.new('cat')
end
def feeds
@feeds
end
@@ -39,10 +39,19 @@
ios.write "- #{fqdn.join ': '}\n"
end
end
end
+ def reset_caches(timestamp)
+ @feeds.each do |name, f|
+ if get_cache.read(f) > timestamp
+ get_cache.save(f, timestamp)
+ puts "Reset #{name}"
+ end
+ end
+ end
+
def status(ios, old_timestamp, very_old_timestamp, display_old_only, category=nil)
@feeds.values.
select { |f| category.nil? || f.category == category }.
map { |f| [ Time.at(get_cache.read(f)), f] }.
sort_by { |el| el.first }.
@@ -62,11 +71,11 @@
def evaluate_feed_definition(feed_name, &block)
#this allow to redefine feeds if necessary
existing_feed = @feeds[feed_name]
new_feed = (existing_feed || FeedConfig.new(feed_name))
new_feed.formatter = default_formatter if default_formatter
- new_feed.pipe = pipe if pipe
+ new_feed.publisher= publisher if publisher
new_feed.instance_eval(&block) if block
new_feed
end
def default_formatter(arg=nil)
@@ -74,14 +83,22 @@
@default_formatter = arg
end
@default_formatter
end
+ def publisher(arg=nil)
+ if arg
+ @publisher = arg
+ end
+ @publisher
+ end
+
+ # compatibility with "pipe" method
def pipe(arg=nil)
if arg
- @pipe = arg
+ publisher(RRImm::Pipe.new(arg))
end
- @pipe
+ publisher.command
end
def feed(name, *args, &block)
feed_def = evaluate_feed_definition(name, *args, &block)
@feeds[name] = feed_def