Sha256: a10cd4af380ad120d29414e791587796adfcd4ea7feb24a9430cf9a368418f97
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
require 'rubygems' require File.join(File.dirname(__FILE__), 'environments') require File.join(File.dirname(__FILE__), 'duration_string') require 'twibot' class CuckooTwitterer include CuckooEnvironment # the idea is to include a module with a well-defined API with three methods: # - load_tweets # - next # - store(tweet) attr_accessor :time_to_sleep def initialize @time_to_sleep = "1d" super end def tweet next_tweet = self.next unless next_tweet.nil? store(next_tweet) if testing? puts "(test) Tweeting #{next_tweet}" else twitter.status(:post, next_tweet) end end next_tweet end def get_config_values_from_file config_values = {} open('config/cuckoo.yml', 'r') do |f| config_values = YAML.load(f.read) end config_values end def setup get_config_values_from_file.each_pair do |attr, value| self.send("#{attr}=".to_sym, value) end end def relax seconds_to_sleep = DurationString.to_seconds(time_to_sleep) sleep(seconds_to_sleep) end def run setup load_tweets loop do tweeted = tweet quit if tweeted.nil? relax end end def quit exit end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
balinterdi-cuckoo_twitterer-0.1.3 | lib/cuckoo_twitterer.rb |