Sha256: 675a38ef9124b4b650ccfc647e25b9743e6d385f7c09f53afb991b59b31c59da
Contents?: true
Size: 1.99 KB
Versions: 1
Compression:
Stored size: 1.99 KB
Contents
#!/usr/bin/env ruby require 'optparse' params = ARGV.getopts(nil, "module:news", "output:log", "date") $:.unshift(File.expand_path('../../lib', __FILE__)) if $0 == __FILE__ require 'consadole_aggregator' output = case params['output'] when 'log' require 'logger' path = File.expand_path('../../log', __FILE__) + '/exec_result.log' log = Logger.new(path) puts "output to #{path}" ->(element){ if element.kind_of?(ConsadoleAggregator::Live::Timeline) log.debug ConsadoleAggregator::Helper.concat(element.to_s, hashtag:'#consadole') else title, url = element[:title], element[:url] log.debug ConsadoleAggregator::Helper.concat(title, url:url, hashtag:'#consadole') end } when 'twitter' require 'oauth' require 'rubytter' path = File.expand_path('../../', __FILE__) + 'account.yaml' ACCOUNT = YAML.load_file(path) oauth = Rubytter::OAuth.new(ACCOUNT['consumer']['key'], ACCOUNT['consumer']['secret']) access_token = OAuth::AccessToken.new(oauth.create_consumer, ACCOUNT['access']['key'], ACCOUNT['access']['secret']) t = OAuthRubytter.new(access_token) ->(element){ if element.kind_of?(ConsadoleAggregator::Live::Timeline) t.update ConsadoleAggregator::Helper.concat(element.to_s, hashtag:'#consadole') else title, url = element[:title], element[:url] t.update ConsadoleAggregator::Helper.concat(title, url:url, hashtag:'#consadole') end } end case params['module'] when 'news' modules = ConsadoleAggregator::News.constants.map{ |k| ConsadoleAggregator::News.const_get(k).new } modules.each{ |m| m.update &output } when 'live' reservation_time = params['date'] ? Time.parse(params['date']) : nil ConsadoleAggregator::Live.reserve(reservation_time).execute &output end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
consadole_aggregator-0.1.2 | bin/consadole_aggregator |