From f417a871ab16e63a64e07a4ff29a1ab39ef764f5 Mon Sep 17 00:00:00 2001 From: wjoe Date: Tue, 7 Feb 2012 13:10:43 +0000 Subject: Historic commit 1.0.2 - config file added (02-Feb-2012 15:31) --- blatweet.rb | 16 +++++++++------- config.yaml | 4 ++++ 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 config.yaml diff --git a/blatweet.rb b/blatweet.rb index cef1f83..46b2112 100644 --- a/blatweet.rb +++ b/blatweet.rb @@ -4,7 +4,7 @@ require 'optparse' username = nil number_of_tweets = 1 -output = '' +output = [] STDIN.gets.split(' ').each{|arg| ARGV << arg} if ARGV == [] args = ARGV.dup @@ -21,17 +21,19 @@ if args == [] exit(-1) end +twitter_config = YAML::load( File.open( 'config.yaml' ) ) + Twitter.configure do |config| - config.consumer_key = 'vXaBVIrxiJw2TKVJyI1w' - config.consumer_secret = 'Xrg8ezA461OlLP94951kWxONMs9CkDCVkW25KZICjY8' - config.oauth_token = '143847685-6uQb9mhDCqhNASYtsi6ZwZoO3Am5Yq2IbPtcjUJ0' - config.oauth_token_secret = 'YxnmXtywSbIvJHyX6pdGhDnkQiR2Z1KJ84DQyzVpUk' + config.consumer_key = twitter_config[:consumer_key] + config.consumer_secret = twitter_config[:consumer_secret] + config.oauth_token = twitter_config[:oauth_token] + config.oauth_token_secret = twitter_config[:oauth_token_secret] end begin if username - Twitter.search("from:#{username}", :rpp => number_of_tweets, :result_type => "recent").each{|tweet| output += "#{tweet.text}\n"} - puts output + Twitter.search("from:#{username}", :rpp => number_of_tweets, :result_type => "recent").each_with_index{|tweet, index| output << "#{index+1}: #{tweet.text}"} + puts output.join ' ' else Twitter.update ARGV.join ' ' end diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..6d452cd --- /dev/null +++ b/config.yaml @@ -0,0 +1,4 @@ +consumer_key: vXaBVIrxiJw2TKVJyI1w +consumer_secret: Xrg8ezA461OlLP94951kWxONMs9CkDCVkW25KZICjY8 +oauth_token: 143847685-6uQb9mhDCqhNASYtsi6ZwZoO3Am5Yq2IbPtcjUJ0 +oauth_token_secret: YxnmXtywSbIvJHyX6pdGhDnkQiR2Z1KJ84DQyzVpUk -- cgit v1.2.3