Sha256: 491618ff3697239bf618baf28aa0ba19e7599c12001aedbdfb77b592b5ee2cad

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'thor'
require 'whos_dated_who'

module WhosDatedWho
  class CLI < Thor
    desc 'version', 'Return the version of WhosDatedWho'
    def version
      puts WhosDatedWho::VERSION
    end

    desc 'query', 'Return the relationship status of a celebrity'
    def query(name)
      result = Client.new.fetch(name)
      status = [
        result[:relationship_status], result[:current_relationship][:human]
      ].join(': ')

      puts status
      puts result[:current_relationship][:dates].join(', ')
    end

    desc 'explore', 'Return the relationship status of everyone in celebs.yml'
    def explore
      my_celebs.map do |celeb|
        puts "Processing #{celeb}..."
        begin
          Client.new.fetch(celeb)
        rescue
          puts "Error processing #{celeb}"
        end
      end.compact
    end

    desc 'import_mine', 'Import my favorites into RethinkDB'
    def import_mine
      Importer.new('celebs', 'mine').fetch_and_import(my_celebs)
    end

    desc 'import_maxim', 'Import maxim hot 100'
    def import_maxim
      # TODO
      # resp = Faraday.get('http://www.maxim.com/hot100/2014')
    end

    private

    def my_celebs
      YAML.load_file(File.expand_path('../../../celebs.yml', __FILE__))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whos_dated_who-1.0.0 lib/whos_dated_who/cli.rb