Project

visitors

0.0
No commit activity in last 3 years
No release in over 3 years
Redis-backed activity storage to track visits to different parts of your Ruby web app in real-time.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.1.9
~> 0.3.10
~> 2.5.0
~> 0.9

Runtime

~> 3.0.25
~> 2.1.1
~> 1.1.3
~> 0.14.6
~> 0.1.8
 Project Readme

Visitors

The visitors gem gives you a simple tracking system for use in your Ruby-based web application. Anywhere in your app you can call…

Visitors.increment(1, :show)

…to increment a counter that corresponds to the resource with an identifier of 1.

Installation

First off install the gem

gem install visitors

Require the visitors gem in your Rails app via your Gemfile.

gem 'visitors', '~> 0.0.2'

Now add Visitors.increment(@resource.id, :show) to a show action in your application.

Configuration

When RAILS_ROOT is defined visitors will work based upon the assumption your using it in combination with Rails. Make sure you have Redis running and that you have a config.yml file in your Rails config directory, similar to this:

development:
  redis_namespace: visitors_development
  redis_config:
    host: localhost

production:
  redis_namespace: visitors_production
  redis_config:
    host: redis-cluster.domain.com

Without RAILS_ROOT visitors will use a local development connection. Not enough to be really useful! Here's the code that decides where to load the config from:

if defined?(RAILS_ROOT)
  def yaml
    @yaml ||= YAML.load_file("#{RAILS_ROOT}/config/visitors.yml")
  end
else
  def yaml
    @yaml ||= YAML.load_file(File.expand_path('../../../config.yml', __FILE__))
  end
end

The environment will be selected using the RAILS_ENV, the VISITORS_ENV or default to development.

Warning

This code is likely to change a lot and probably shouldn't be used in your beautiful production app because of this. It's something I put together quickly for use in work as writing all our activity to disk was crippling servers.

Feel free to fork and use the code but take heed, I make no committment to support, maintain or even acknowledge the existence of this small cluster fuck.