class Augury::CLI

Public Instance Methods

generate(username, *path) click to toggle source
# File lib/augury/cli.rb, line 61
def generate(username, *path)
  path = File.expand_path(path[0] || username)
  augury = Augury::Fortune.new(username, path, options)
  augury.twitter_setup
  augury.retrieve_tweets
  augury.write_fortune
  say "Fortune written out to #{path}"
rescue StandardError => e
  say 'There was an error running the command. Details below:'
  say e.message
  puts e.backtrace if options[:debug]
  exit 1
end

Private Instance Methods

options() click to toggle source

TODO: This override doesn’t work in Thor 1.1+

Calls superclass method
# File lib/augury/cli.rb, line 78
def options
  original_options = super
  defaults = Thor::CoreExt::HashWithIndifferentAccess.new(
    {
      width: 72,
      count: 200,
    },
  )

  config_path = File.expand_path(ENV.fetch('AUGURY_CFG_PATH', '~/.augury.yml'))
  if File.file?(config_path)
    config_options = Thor::CoreExt::HashWithIndifferentAccess.new(YAML.load_file(config_path) || {})
    defaults = defaults.merge(config_options)
  end

  # Enforce implied options
  defaults[:links] = true if original_options[:remove_links] || defaults[:remove_links]

  Thor::CoreExt::HashWithIndifferentAccess.new(defaults.merge(original_options))
end