Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created February 1, 2012 23:58
Show Gist options
  • Select an option

  • Save practicingruby/1720253 to your computer and use it in GitHub Desktop.

Select an option

Save practicingruby/1720253 to your computer and use it in GitHub Desktop.
require_relative "../lib/postal_service"
app = PostalService::Application.new do
match :genre, '\S+'
match :title, '.*'
match :email, '[\w\d\._-]+@[\w\d\._-]+' #not legit, I'm sure
subject(:match, "a {genre} story '{title}'") do
respond :subject => "No one would consider '#{params[:title]}' to be #{params[:genre]}"
end
subject(:match, "what stories do you know?") do
respond :subject => "What stories do YOU know?"
end
subject(:match, "tell something {genre} to {email}") do
respond :subject => "Why don't you tell something #{params[:genre]} to #{params[:email]}?"
end
subject(:match, "tell me something {genre}") do
respond :subject => "Your face is #{params[:genre]}"
end
subject(:match, "tell me '{title}'") do
respond :subject => "Once upon a time there was a #{params[:title]}. THE END."
end
subject(:match, "help") do
respond :subject => "Please deposit $10, and then try again"
end
default do
respond :subject => "FAIL"
end
end
PostalService::Server.run(:config => eval(File.read("config.rb")),
:apps => [app])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment