Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby gem for pulling data from a Pwnalytics server

tag: v0.1.4

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .project
Octocat-spinner-32 .rspec
Octocat-spinner-32 Gemfile
Octocat-spinner-32 Gemfile.lock
Octocat-spinner-32 LICENSE.txt
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 pwnalytics_client.gemspec
README.rdoc

pwnalytics_client

Ruby gem providing a client for the Pwnalytics REST API.

Usage

First, create a PwnalyticsClient pointing to your Pwnalytics instance:

client = PwnalyticsClient.new :host => 'localhost', :port => 3000,
                              :user => 'config', :password => 'vars'

Or, if you're using SSL:

client = PwnalyticsClient.new :host => 'localhost', :port => 3000,
                              :user => 'config', :password => 'vars',
                              :ssl => true,
                              :net_http => { :ca_path => '/etc/ssl/certs' }

Get the site that you want data for:

site = client.site('AA123456')

Or, if you don't know the site's UID, you can list all of them.

sites = client.sites

Finally, get the logged events for that site:

# Get everything.
events = site.events

# Restrict query to events with certain names.
events = site.events :names => ['page', 'unload']

# Avoid a data flood.
events = site.events :limit => 200

Events have the same data as in the JSON output.

event.name        # "page"
event.visitor     # "12f49459540.11faa9b963f5c4f0"
event.ip          # "127.0.0.1"
event.browser_ua  # "Mozilla/5.0 ..."
event.url         # <URI::HTTP:0x7f6750505078 URL:http://localhost>
event.ref         # <URI::HTTP:0x7f6750505078 URL:http://www.google.com>
event.data.your_property  # "your_value"
event.pixels.document.width  # 1680

The RSpec tests cover the entire API.

Testing

Clone the Pwnalytics repository and run the Rails server locally.

git clone git://github.com/pwnall/pwnalytics.git
cd pwnalytics
bundle
rake db:create db:migrate db:seed
rails s

The specs assume a local server for integration testing.

Contributing to pwnalytics_client

  • Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet

  • Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright © 2011 Victor Costan. See LICENSE.txt for further details.

Something went wrong with that request. Please try again.