<commit_before>= url_shortener_client

Description goes here.

== Note on Patches/Pull Requests
 
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
  future version unintentionally.
* Commit, do not mess with rakefile, version, or history.
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.<commit_msg>Added usage info to README.<commit_after>= url_shortener_client

The url shortener itself (https://github.com/dealerignition/di_url_shortener) runs on the engineyard instance, and responds to requests at http://l.d5i7.net. The client gem (https://github.com/dealerignition/di_url_shortener_client) posts a url to http://l.d5i7.net/, and gets back a shortened url and the id of the url (used later to retrieve stats). The shortener service stores the url in a database, and uses the base58 encoded id (using http://github.com/dougal/base58) as the abbreviation in the short url. When the url is accessed, the shortener redirects to the source url, and stores the requesters referrer and ip address. You can later use the client to make a stats() call, passing it the id it received from the create call, and currently just get back a total of the clicks (the referrer and ip data is stored, but not currently exposed via the stats call).

Here is an example of usage:

irb:
ruby-1.8.7-p302 > ap UrlShortenerClient.create('http://google.com')
{
    "shortened_url" => "http://l.d5i7.net/9M",
       "created_at" => "2010/10/23 06:46:45 -0700",
       "updated_at" => "2010/10/23 06:46:45 -0700",
              "url" => "http://google.com",
               "id" => 509
}

bash:
$ wget http://l.d5i7.net/9M
--2010-10-23 09:54:47--  http://l.d5i7.net/9M
Resolving l.d5i7.net... 172.16.17.32
Connecting to l.d5i7.net|172.16.17.32|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://google.com [following]
--2010-10-23 09:54:47--  http://google.com/
...

irb:
ruby-1.8.7-p302 > ap UrlShortenerClient.stats(509)
{
    "click_count" => 1
}

{'fraction_non_alphanumeric': 0.11080332409972299, 'fraction_numerical': 0.05863342566943675, 'mean_word_length': 3.5334728033472804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '44304', 'n_tokens_mistral': 780, 'n_tokens_neox': 697, 'n_words': 273}