Document how to obtain a github OAuth token for APIv3

Without this patch it's not clear how to obtain an API token to
authenticate against the OAuth API.  This patch clarifies the situation
with a single curl command.
Add example json payload for a pull request

Without this patch we don't have any example fixture data for the data
that Github sends to the webhook when a pull request is opened.  This is
a problem because it's hard to know what we're working with.

This patch adds a file containing the string that is posted to the
webhook and made available in `params['payload']` inside of the Sinatra
application handler.
Pretty Print the example json payload

Without this patch the example payload is the raw string posted from
Github.  This is a big long line with little whitespace and is difficult
to read.  This patch reformats the string using Ruby's
JSON.pretty_generate
Add example JSON posted when a pull request is synchronized

This patch adds an example of the JSON that is posted to the webhook
when a pull request has been synchronized against the reference branch.
This generally happens when the branch changes, e.g. from a force push.
Pretty print the JSON before writing

Before writing the JSON payload, pretty print it to make the web UI a
bit easier.
Add fixture data when pull request is closed.
Add watchr script, example test and reorganize

Without this patch we don't yet have any tests for this project.  I'd
like to write using TDD so this lack of tests is a problem.

This patch adds a single test to cover the hello world method.  A
watchr script is in place to automatically run the tests.
Create a card on the Trello board.

Without this patch we're not actually creating the card.  This patch
addresses the problem by using the Trello REST API to create a card
immediately on the target board.
Add rake spec task to run the example behaviors
Update README with configuration settings
Fix warning already initialized constant AuthPolicy

Without this patch applied, running the tests in watchr constantly gives
the following warning on the output:

    web.rb:58: warning: already initialized constant AuthPolicy

This patch fixes the problem by checking if the constant is already set
to the desired value.  If it is not, it deletes the constant and then
immediately re-defines it to the correct value.  This completely avoids
the warning at the cost of silently changing the internal behavior of
the Trello gem.
Reflow the code in web.rb to match Github style

This patch does not change the behavior of the application and instead
simply reformats the code to match up with the Github style guidelines
at https://github.com/styleguide/ruby
Add yard options.  Start with yard server --reload

This patch adds the options to run a local yard server to document
inline documentation for the application.
Add db:create and db:migrate tasks

Without this patch there is no way to easily create the Postgres
database used by the ActiveRecord and Delayed Job libraries.

This patch addresses the problem by implementing a rake `db:create` and
`db:migrate` task.  These tasks use a `database.yml` file configured to
use the [Postgres.app](http://postgresapp.com/) server recommended by
Heroku.

The migration of the database to create the delayed jobs table is
implemented in the `db/migrate` directory.  The behavior of this
migration is as follows, which will completely re-initialize the queue:

    $ rake db:create
    Created database puppet_webhooks_dev
    $ rake db:migrate
    D, [2012-12-26T22:22:24.494747 #57656] DEBUG -- :    (2.6ms)  CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL)
    D, [2012-12-26T22:22:24.498370 #57656] DEBUG -- :    (1.5ms)  CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
    D, [2012-12-26T22:22:24.501645 #57656] DEBUG -- :    (0.4ms)  SELECT "schema_migrations"."version" FROM "schema_migrations"
    I, [2012-12-26T22:22:24.501712 #57656]  INFO -- : Migrating to CreateDelayedJobs (1)
    D, [2012-12-26T22:22:24.501991 #57656] DEBUG -- :    (0.2ms)  BEGIN
    ==  CreateDelayedJobs: migrating ==============================================
    -- create_table(:delayed_jobs, {:force=>true})
    NOTICE:  CREATE TABLE will create implicit sequence "delayed_jobs_id_seq" for serial column "delayed_jobs.id"
    NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "delayed_jobs_pkey" for table "delayed_jobs"
    D, [2012-12-26T22:22:24.510485 #57656] DEBUG -- :    (3.6ms)  CREATE TABLE "delayed_jobs" ("id" serial primary key, "priority" integer DEFAULT 0, "attempts" integer DEFAULT 0, "handler" text, "last_error" text, "run_at" timestamp, "locked_at" timestamp, "failed_at" timestamp, "locked_by" character varying(255), "queue" character varying(255), "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
       -> 0.0080s
    -- add_index(:delayed_jobs, [:priority, :run_at], {:name=>"delayed_jobs_priority"})
    D, [2012-12-26T22:22:24.512473 #57656] DEBUG -- :    (0.9ms)  CREATE INDEX "delayed_jobs_priority" ON "delayed_jobs" ("priority", "run_at")
       -> 0.0019s
    ==  CreateDelayedJobs: migrated (0.0100s) =====================================
    D, [2012-12-26T22:22:24.514054 #57656] DEBUG -- :    (0.4ms)  INSERT INTO "schema_migrations" ("version") VALUES ('1')
    D, [2012-12-26T22:22:24.514753 #57656] DEBUG -- :    (0.6ms)  COMMIT

At this point the database is initialized and ready for jobs to be queued up.

References:

 * [Sinatra ActiveRecord migrations][sinatra_ar_migrations]
 * [Dead simple ActiveRecord migrations without
   Rails][ar_migrations_no_rails]

[sinatra_ar_migrations]: http://www.sinatrarb.com/faq.html#ar-migrations
[ar-migrations-without-rails]: http://goo.gl/zDafn
Fix heroku run rake db:migrate error `adapter = uri.scheme'

Without this patch running `heroku run rake db:migrate` returns the
following error message:

    syntax error on line 27, col 0: `adapter = uri.scheme'

This is a problem because the delayed job database tables aren't being
created.

The root cause of the problem is that Heroku overwrites this file with
an ERB template that parses the DATABASE_URL environment variable.  This
template looks like the example at the bottom of this commit.

The solution is simple and mentioned at http://goo.gl/eL2ms, just run
the file through ERB.  This patch does just that.

`config/database.yml` written by Heroku:

    <%

    require 'cgi'
    require 'uri'

    begin
      uri = URI.parse(ENV["DATABASE_URL"])
    rescue URI::InvalidURIError
      raise "Invalid DATABASE_URL"
    end

    raise "No RACK_ENV or RAILS_ENV found" unless ENV["RAILS_ENV"] || ENV["RACK_ENV"]

    def attribute(name, value, force_string = false)
      if value
        value_string =
          if force_string
            '"' + value + '"'
          else
            value
          end
        "#{name}: #{value_string}"
      else
        ""
      end
    end

    adapter = uri.scheme
    adapter = "postgresql" if adapter == "postgres"

    database = (uri.path || "").split("/")[1]

    username = uri.user
    password = uri.password

    host = uri.host
    port = uri.port

    params = CGI.parse(uri.query || "")

    %>

    <%= ENV["RAILS_ENV"] || ENV["RACK_ENV"] %>:
      <%= attribute "adapter",  adapter %>
      <%= attribute "database", database %>
      <%= attribute "username", username %>
      <%= attribute "password", password, true %>
      <%= attribute "host",     host %>
      <%= attribute "port",     port %>

    <% params.each do |key, value| %>
      <%= key %>: <%= value.first %>
    <% end %>
Update documentation with setup steps

Without this patch the documentation does not contain information about
how to setup things quickly.  This patch adds that section, though it
needs to be verified later.
Update locked dependencies with bundle update
web.rb to lib/web.rb
Update code to reflect renamed files

Without this patch the renamed file structure does not match the code.
This is a problem because the app will not deploy properly.

This patch addresses the problem by adjusting the `$LOAD_PATH`,
introducing a new spec_helper file to help load code, and updating the
Procfile which starts the application process (aka dyno in Heroku
terminology).
Queue up Pull Request jobs at /event/pull_request

Without this patch we are not creating and storing jobs that are
executable by DJ.  This patch addresses the problem by introducing new
models for the Pull Request data, and associating these models with a
PullRequestJob instance.  This instance is then written to the databases
when post data includes the payload parameter routed to
/event/pull_request.

This patch also adds two rake jobs.  `api:run` and `api:pull_request`.
These tasks start a local copy of the web server using foreman and thin.
This requires the heroku toolbelt.  The `api:pull_request` task uses the
system curl command to an HTTP POST request similar to how Github would
make one when a new pull request is created.

This patch adds a queue_job helper method.  This method is intended to
be available using `helpers PuppetLabs::SinatraDJ`.  Any object that
responds to `perform` can be queued with queue_job(obj).

In addition, this patch initializes an in-memory SQLite database for
spec testing.

This patch also switches to config.ru and thin