Sha256: 69f1b4156b84ab46c923a9cd0006ed715e91df5613518972dbf64bbfc3cbb07f

Contents?: true

Size: 966 Bytes

Versions: 15

Compression:

Stored size: 966 Bytes

Contents

#!/usr/bin/env ruby
require 'consadole_aggregator'
require 'time'
require 'optparse'
require 'twitter'

module ConsadoleAggregator
  opt = OptionParser.new
  output = ->(post) { puts post }
  opt.on('-o output', '--output output') { |o|
    case o
    when 'twitter'
      Twitter.configure do |config|
        config.consumer_key = ENV['CONSUMER_KEY']
        config.consumer_secret = ENV['CONSUMER_SECRET']
        config.oauth_token = ENV['OAUTH_TOKEN']
        config.oauth_token_secret = ENV['OAUTH_TOKEN_SECRET']
      end
      output = ->(post) { Twitter.update Helper.truncate_for_twitter(post[:title], { url: post[:url], hashtag: '#consadole' }) }
    end
  }

  subcommand = ARGV.shift

  case subcommand
  when 'news'
    opt.parse!(ARGV)
    News.run &output
  when 'live'
    starting_time = Time.parse(ARGV.shift)
    opt.parse!(ARGV)
    Live.run starting_time, { writer: output }
  else
    raise 'first argument must be "news" or "live"'
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
consadole_aggregator-0.2.14 bin/consadole_aggregator
consadole_aggregator-0.2.13 bin/consadole_aggregator
consadole_aggregator-0.2.12 bin/consadole_aggregator
consadole_aggregator-0.2.11 bin/consadole_aggregator
consadole_aggregator-0.2.10 bin/consadole_aggregator
consadole_aggregator-0.2.9 bin/consadole_aggregator
consadole_aggregator-0.2.8 bin/consadole_aggregator
consadole_aggregator-0.2.7 bin/consadole_aggregator
consadole_aggregator-0.2.6 bin/consadole_aggregator
consadole_aggregator-0.2.5 bin/consadole_aggregator
consadole_aggregator-0.2.4 bin/consadole_aggregator
consadole_aggregator-0.2.3 bin/consadole_aggregator
consadole_aggregator-0.2.2 bin/consadole_aggregator
consadole_aggregator-0.2.1 bin/consadole_aggregator
consadole_aggregator-0.2.0 bin/consadole_aggregator