Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
An API to match Facebook users with Innovations.
tree: 8f00be6649

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
log
tmp
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.rdoc
Rakefile
config.ru
innovation_matcher.rb
settings.example.yml
unicorn-conf.example.rb

README.rdoc

Setup

Installation

First make sure you've installed

- Git[http://git-scm.com/]
- Ruby
- Bundler[http://gembundler.com/]

And then

$ git clone https://github.com/infochimps/chiat_day_innovation_matcher.git
$ cd chiat_day_innovation_matcher
$ bundle install

Configuration

There are two configuration files this app depends upon.

The settings.yml file points at the MySQL database so provide an appropriate host and credentials. Copy it from the given example:

$ cp settings.example.yml settings.yml

The unicorn-conf.rb file is required if you want to run the app behind the Unicorn webserver.

$ cp unicorn-conf.example.rb unicorn-conf.example.rb

Here you can define where the app will log, leave its pids, and how it listens. You can also define the number of worker processes you want to run.

Running

You can run the app locally on port 4567 by just running it with Ruby:

$ ruby innovation_matcher.rb
== Sinatra/1.3.3 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:4567, CTRL+C to stop

You can also run it with Unicorn

$ unicorn -c unicorn-conf.rb

which is what you should do in production, after you've tweaked the unicorn-conf.rb file.

Make sure that the user you're running this unicorn with can write to the directories you point at in the unicorn-conf.rb file. If you're using the example unicorn-conf.rb file then you might want to run a command like

$ chmod -R www-data:www-data log tmp

Usage

Create a match

Returns an array of innovations matching given parameters dob and hometown. Also returns a match_id that can be used to retrieve this match later.

Example:

$ curl -s -X POST http://localhost:4567/matches -d '{"dob": "1983-05-23", "hometown": "New York, NY"}'
{
  "match_id": "6b73f010-d469-012f-ad21-002219342852",
  "innovations": [
    {
      "id": "280",
      "type": "Automotive",
      "name": "internal combustion engine",
      "photo": "http://www.flickr.com/photos/ell-r-brown/6050366599/",
      "innovator_name": "NICOLAUS OTTO",
      "innovation_date": "8/14/1877"
      ...
    },
    { ... },
    ...
  ]
}

Retrieve a match

Returns an array of innovations from a previously returned match_id.

Example:

$ curl -s -X GET http://localhost:4567/matches/6b73f010-d469-012f-ad21-002219342852
{
  "match_id": "6b73f010-d469-012f-ad21-002219342852",
  "innovations": [
    {
      "id": "280",
      "type": "Automotive",
      "name": "internal combustion engine",
      "photo": "http://www.flickr.com/photos/ell-r-brown/6050366599/",
      "innovator_name": "NICOLAUS OTTO",
      "innovation_date": "8/14/1877",
      ...
    },
    { ... },
    ...
  ]
}
Something went wrong with that request. Please try again.