visitors 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +39 -14
- data/config.yml +5 -0
- data/lib/visitors/config.rb +3 -1
- data/lib/visitors/version.rb +1 -1
- metadata +3 -5
- data/bin/visitors +0 -11
- data/lib/visitors/cli.rb +0 -15
data/README.md
CHANGED
@@ -8,35 +8,60 @@ Ruby-based web application. Anywhere in your app you can call…
|
|
8
8
|
…to increment a counter that corresponds to the resource with an
|
9
9
|
identifier of 1.
|
10
10
|
|
11
|
-
##
|
11
|
+
## Installation
|
12
12
|
|
13
13
|
First off install the gem
|
14
14
|
|
15
15
|
gem install visitors
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
Require the visitors gem in your Rails app via your Gemfile.
|
18
|
+
|
19
|
+
gem 'visitors', '~> 0.0.2'
|
20
|
+
|
21
|
+
Now add `Visitors.increment(@resource.id, :show)` to a show action in
|
22
|
+
your application.
|
23
|
+
|
24
|
+
## Configuration
|
25
|
+
|
26
|
+
When `RAILS_ROOT` is defined visitors will work based upon the
|
27
|
+
assumption your using it in combination with Rails. Make sure you have
|
28
|
+
Redis running and that you have a config.yml file in your Rails config
|
29
|
+
directory, similar to this:
|
19
30
|
|
20
31
|
development:
|
21
32
|
redis_namespace: visitors_development
|
22
33
|
redis_config:
|
23
34
|
host: localhost
|
24
35
|
|
25
|
-
|
26
|
-
|
27
|
-
|
36
|
+
production:
|
37
|
+
redis_namespace: visitors_production
|
38
|
+
redis_config:
|
39
|
+
host: redis-cluster.domain.com
|
28
40
|
|
29
|
-
|
41
|
+
Without `RAILS_ROOT` visitors will use a local development connection.
|
42
|
+
Not enough to be really useful! Here's the code that decides where to
|
43
|
+
load the config from:
|
30
44
|
|
31
|
-
|
32
|
-
|
45
|
+
if defined?(RAILS_ROOT)
|
46
|
+
def yaml
|
47
|
+
@yaml ||= YAML.load_file("#{RAILS_ROOT}/config/visitors.yml")
|
48
|
+
end
|
49
|
+
else
|
50
|
+
def yaml
|
51
|
+
@yaml ||= YAML.load_file(File.expand_path('../../../config.yml', __FILE__))
|
52
|
+
end
|
53
|
+
end
|
33
54
|
|
34
|
-
|
35
|
-
|
55
|
+
The environment will be selected using the `RAILS_ENV`, the
|
56
|
+
`VISITORS_ENV` or default to `development`.
|
36
57
|
|
37
58
|
## Warning
|
38
59
|
|
39
60
|
This code is likely to change a lot and probably shouldn't be used in
|
40
|
-
your beautiful production app because of this.
|
41
|
-
|
42
|
-
|
61
|
+
your beautiful production app because of this. It's something I put
|
62
|
+
together quickly for use in work as writing all our activity to disk was
|
63
|
+
crippling servers.
|
64
|
+
|
65
|
+
Feel free to fork and use the code but take heed, I make no committment
|
66
|
+
to support, maintain or even acknowledge the existence of this small
|
67
|
+
cluster fuck.
|
data/config.yml
CHANGED
data/lib/visitors/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
class Visitors::Config
|
2
4
|
class MissingEnvironmentError < StandardError; end
|
3
5
|
|
@@ -31,7 +33,7 @@ class Visitors::Config
|
|
31
33
|
end
|
32
34
|
|
33
35
|
def env
|
34
|
-
ENV['VISITORS_ENV'] || 'development'
|
36
|
+
ENV['RAILS_ENV'] || ENV['VISITORS_ENV'] || 'development'
|
35
37
|
end
|
36
38
|
|
37
39
|
def define_methods_from_yaml
|
data/lib/visitors/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: visitors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James Conroy-Finn
|
@@ -126,8 +126,8 @@ dependencies:
|
|
126
126
|
description: Redis-backed activity storage to track visits to different parts of your Ruby web app in real-time.
|
127
127
|
email:
|
128
128
|
- james@logi.cl
|
129
|
-
executables:
|
130
|
-
|
129
|
+
executables: []
|
130
|
+
|
131
131
|
extensions: []
|
132
132
|
|
133
133
|
extra_rdoc_files: []
|
@@ -140,11 +140,9 @@ files:
|
|
140
140
|
- Guardfile
|
141
141
|
- README.md
|
142
142
|
- Rakefile
|
143
|
-
- bin/visitors
|
144
143
|
- config.ru
|
145
144
|
- config.yml
|
146
145
|
- lib/visitors.rb
|
147
|
-
- lib/visitors/cli.rb
|
148
146
|
- lib/visitors/config.rb
|
149
147
|
- lib/visitors/helpers.rb
|
150
148
|
- lib/visitors/resource.rb
|
data/bin/visitors
DELETED
data/lib/visitors/cli.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
|
3
|
-
class Visitors::CLI < Thor
|
4
|
-
desc 'store', 'start the redis in-memory store'
|
5
|
-
def store
|
6
|
-
say "You're running in development, do it yourself!", :blue
|
7
|
-
end
|
8
|
-
|
9
|
-
desc 'web', 'start the web console (NOT IMPLEMENTED)'
|
10
|
-
def web
|
11
|
-
require 'vegas'
|
12
|
-
require File.expand_path('../../../server', __FILE__)
|
13
|
-
Vegas::Runner.new(Visitors::Server, 'visitors_app')
|
14
|
-
end
|
15
|
-
end
|