Sha256: 8e6e37170c9b86f59237b97b0f1d8d265f00ba0e8408e1222e81c4d15149f75d
Contents?: true
Size: 1.99 KB
Versions: 4
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
4 entries across 4 versions & 1 rubygems