Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jcf/visitors
Log visits to parts of your Rails app using Redis and a postgres archive
https://github.com/jcf/visitors
Last synced: 1 day ago
JSON representation
Log visits to parts of your Rails app using Redis and a postgres archive
- Host: GitHub
- URL: https://github.com/jcf/visitors
- Owner: jcf
- Created: 2011-02-24T21:59:40.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2011-03-15T12:03:51.000Z (over 13 years ago)
- Last Synced: 2024-10-28T17:20:08.754Z (17 days ago)
- Language: Ruby
- Homepage: http://github.com/jcf/visitors
- Size: 141 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this 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: localhostproduction:
redis_namespace: visitors_production
redis_config:
host: redis-cluster.domain.comWithout `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
endThe 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.