Sha256: 8cdc7daf8cbc68f3f20ca6ec85b1791d4188eca4c52e60f95cb178d5f0f713d9

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

#!/usr/bin/env ruby

require "gmail"
require "typhoeus"

# check for the config file
config_file = "#{ENV['HOME']}/.sandwich"
unless File.exist?(config_file)
  puts "You need to type the sandwich makers email, your email and password (one per line) into `~/.sandwich`"
  puts "Example:"
  puts "sandwicher@generalthings.com"
  puts "youremail@generalthings.com"
  puts "password"
  exit!(1)
end

# Establish all the params
sandwich_maker,email,password = File.read(config_file).split("\n")

# Inspirational quotes are very important
#
# you need to soothe the your sandwich maker first.
#
# http://www.iheartquotes.com/api/v1/random
quote = Typhoeus::Request.get("http://www.iheartquotes.com/api/v1/random")
msg = quote.body.split("\n")
msg.pop

# Building the Gmail connection
gmail = Gmail.new(email, password)

# Creating and sending the email
gmail.deliver do
  to "#{sandwich_maker}"
  subject "Favor pleaseeee! :)"
  text_part do
    body "Please sir,\n
    Could you make me a sandwich?\n
    #{msg.join("\n")}
    \nThank you!"
  end
end

# Close the connection.
gmail.logout

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
make-sandwich-0.0.4 bin/make_sandwich