Module: Twog::Twog

Includes:
BlogPostsHandler, RssEntryToTwogPostMapper, RssParser, TwitterHandler
Defined in:
lib/twog.rb

Instance Method Summary collapse

Methods included from TwitterHandler

#ensure_text_is_of_length, #tweet, #update_config_file_with_latest_tweet_date, #use_twitter_oauth

Methods included from BlogPostsHandler

#get_new_blog_posts

Methods included from RssEntryToTwogPostMapper

#map

Methods included from RssParser

#get_content, #parse_feed

Instance Method Details

#get_bitly_from(conf) ⇒ Object



38
39
40
41
42
43
# File 'lib/twog.rb', line 38

def get_bitly_from(conf)
  bitly_username = conf['bitly_username']
  bitly_api_key = conf['bitly_api_key']
  return nil unless (bitly_username && bitly_api_key)
  Bitly.new(bitly_username, bitly_api_key)
end

#get_posts_to_tweet(conf) ⇒ Object



32
33
34
35
36
# File 'lib/twog.rb', line 32

def get_posts_to_tweet(conf)
  posts = parse_feed(conf['rss_feed'])
  posts = map(posts) 
  posts = get_new_blog_posts(posts, conf['last_blog_post_tweeted'])
end

#run(conf) ⇒ Object



25
26
27
28
29
30
# File 'lib/twog.rb', line 25

def run(conf)
  posts = get_posts_to_tweet(conf)
  return unless posts && posts.length > 0
  bitly = get_bitly_from(conf)
  tweet(posts, conf, bitly)
end

#versionObject



45
46
47
48
# File 'lib/twog.rb', line 45

def version
  yml = YAML.load(File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION.yml])))
  "#{yml[:major]}.#{yml[:minor]}.#{yml[:patch]}"
end