Sha256: 2ba426e8758f95d6675e2c2c72babc3f025db753b1fd998d5ee281f021b8efa1
Contents?: true
Size: 1.28 KB
Versions: 2
Compression:
Stored size: 1.28 KB
Contents
#!/usr/bin/env ruby $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'twhere' require 'optparse' config_file = nil OptionParser.new do |opts| opts.banner = 'usage: twhere.rb [options]' opts.on('-c', '--config FILE', 'specify config file') do |c| config_file = c end opts.on_tail('-h', '--help', 'show this message') do puts opts exit end opts.on_tail('--version', 'show version') do version = YAML::load(File.open(File.join(File.dirname(__FILE__), '..', 'VERSION.yml'))) puts "#{version[:major]}.#{version[:minor]}.#{version[:patch]}" exit end end.parse! # load config config = YAML::load(File.open(config_file)) # load known locations locations = YAML::load(File.open(config[:twhere][:locations_file])) # load template template = File.read(config[:twhere][:template_file]) # load saved tweets (or don't) tweets = [] begin tweets = YAML::load(File.open(config[:twhere][:tweets_file])) if config[:twhere][:tweets_file] rescue Errno::ENOENT end # create Twhere instance and puts result twhere = Twhere.new(locations, template, config[:twitter][:username], config[:twitter][:password], tweets) puts twhere.result # save tweets to file File.open(config[:twhere][:tweets_file], 'w') { |f| f.puts tweets.to_yaml } if config[:twhere][:tweets_file]
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sarnesjo-twhere-0.0.8 | bin/twhere |
sarnesjo-twhere-0.0.9 | bin/twhere |