Sha256: acdecef38054a2a1ca05a38621f1798b6fcc560eda1f284fe204d5a462abf15b

Contents?: true

Size: 1.16 KB

Versions: 2

Compression:

Stored size: 1.16 KB

Contents

require 'rubygems'
require 'thread'
require 'csv'
require 'twitter'
require 'marky_markov'
require 'yaml'

$:.unshift(File.dirname(__FILE__))

require 'ebooks/version'
require 'ebooks/core_ext'

module Ebooks
  autoload :Generator, 'ebooks/generator'
  autoload :Twitter,   'ebooks/twitter'

  class << self
    def read_config_file(file = '~/.ebooks')
      contents = File.read(file.sub('~', ENV["HOME"]))
      YAML.load(contents)
    end

    def configuration(overrides = {})
      {
        :tweets_csv_path => 'tweets.csv',
        :corpus_path     => 'markov_dict.txt',
        :dictionary_name => 'dictionary', # don't include the .mmd
        :twitter => {
          :consumer_key       => '',
          :consumer_secret    => '',
          :oauth_token        => '',
          :oauth_token_secret => ''
        }
      }.deep_merge(overrides)
    end

    def generate(overrides = {})
      config = configuration(overrides)
      generator = Ebooks::Generator.new(config)

      generator.generate_sentence
    end

    def tweet(overrides = {})
      config = configuration(overrides)
      Ebooks::Twitter.new(config[:twitter]).tweet(generate(overrides))
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ebooks-0.2.1 lib/ebooks.rb
ebooks-0.2.0 lib/ebooks.rb