0.0
No commit activity in last 3 years
No release in over 3 years
A Ruby wrapper around the 140Proof API. Documentation can be found here - http://developers.140proof.com/docs/
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.2.9

Runtime

>= 0
 Project Readme

140Proof API Wrapper¶ ↑

This is a wrapper around the 140 Proof API.

It is split into two parts. The first is a simple interface (One40Proof::UserAd) and the second is a multi interface (One40Proof::Multi::UserAd).

The simple interface requires:

The multi interface requires:

They both require:

The multi interface allows you to make parallel requests (benchmarks are below).

Documentation for the 140Proof API can be found here - developers.140proof.com/docs

RDoc¶ ↑

rdoc.info/projects/reddavis/One40Proof

Install¶ ↑

## Beta V2 ##
git clone git://github.com/reddavis/One40Proof.git
rake gemspec
rake build
rake install

## Stable ##
gem sources -a http://gemcutter.org
sudo gem install one40_proof

Benchmarks¶ ↑

## Broken ##

This can be found on the benchmark dir

n = 10
Benchmark.bm do |x|
  x.report("Simple") do
    n.times { One40Proof::Test.new }
  end
  x.report("Multi") do
    query = []
    n.times { query << {:method => :test} }
    One40Proof::Multi::UserAd.new(query)
  end
end

              ## Ruby 1.9.1 ##
          user      system      total      real
Simple  0.030000   0.020000   0.050000 (  2.507165)
Multi   0.010000   0.010000   0.020000 (  0.426687)

## End Broken ##

How To Use¶ ↑

Making Parallel Requests

Queries are created using a hash and then placed in an array

require 'rubygems'
require 'one40_proof/multi'

queries = []
queries << {:user_name => 'reddavis', :app_name => 'Test'}
queries << {:user_name => 'sferik', :app_name => 'Test'}

# We then initialize the calls to the service
a = One40Proof::Multi::UserAd.new(queries)

# Then we have access to all our ads
a.ads.each do |ad|
  # The Ad
  ad.advertiser
  ad.byline
  ad.text
  ad.type # Banner or Text
  ad.tweet_url
  ad.validate_impression!  # Sends a GET request to the impression_validation url
  ad.click_url
  ad.impression_url
end

# You can also specify what happens if a request fails
a = One40Proof::Multi::UserAd.new(queries, :on_fail => "Fail!")

# It can also take anything that responds to #call
# e.g. One40Proof::Multi::UserAd.new(queries, :on_fail => Proc.new {raise "fail"})

# If all our requests fail then:
a.ads
  #=> ["Fail!", "Fail!", "Fail!"]

# If nothing is specified on_fail then a nil object is just placed inside the array

Making Single Requests

require 'rubygems'
require 'one40_proof/simple'

ad = One40Proof::UserAd.new(:user_name => 'reddavis', :app_name => 'your app_name', :network => "Twitter")

# The Ad
ad.advertiser
ad.byline
ad.text
ad.type # Banner or Text
ad.tweet_url
ad.validate_impression!  # Sends a GET request to the impression_validation url
ad.click_url
ad.impression_url

TODO¶ ↑

  • Make it more difficult to make mistakes (passing wrong param names, incorrect params etc…)

Issues¶ ↑

Please report any problems or feature requests here.

Copyright © 2010 Red Davis. See LICENSE for details.