visitors 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +38 -7
- data/lib/visitors/version.rb +1 -1
- data/spec/visitors_spec.rb +0 -10
- metadata +1 -1
data/README.md
CHANGED
@@ -1,12 +1,43 @@
|
|
1
1
|
# Visitors
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
The visitors gem gives you a simple tracking system for use in your
|
4
|
+
Ruby-based web application. Anywhere in your app you can call…
|
5
5
|
|
6
|
-
Visitors
|
7
|
-
Visitors::Day.new
|
6
|
+
Visitors.increment(1, 'show')
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
…to increment a counter that corresponds to the resource with an
|
9
|
+
identifier of 1.
|
11
10
|
|
12
|
-
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
First off install the gem
|
14
|
+
|
15
|
+
gem install visitors
|
16
|
+
|
17
|
+
Next make sure you have Redis running and the config.yml file has the
|
18
|
+
right configuration settings to connect to your Redis instance.
|
19
|
+
|
20
|
+
development:
|
21
|
+
database: postgres://localhost/visitors_development
|
22
|
+
redis_namespace: visitors_development
|
23
|
+
redis_config:
|
24
|
+
host: localhost
|
25
|
+
|
26
|
+
You can specify which settings to use with a `VISITORS_ENV` variable.
|
27
|
+
|
28
|
+
Require the visitors gem in your Rails app via your Gemfile?
|
29
|
+
|
30
|
+
gem 'visitors', '~> 0.0.2'
|
31
|
+
|
32
|
+
Now add `Visitors.increment(params[:id], 'show')` to a show action in
|
33
|
+
your application.
|
34
|
+
|
35
|
+
Launch a Vegas-powered Sinatra web console to see who's been visiting
|
36
|
+
your pages using `visitors web`.
|
37
|
+
|
38
|
+
## Warning
|
39
|
+
|
40
|
+
This code is likely to change a lot and probably shouldn't be used in
|
41
|
+
your beautiful production app because of this. Feel free to fork and use
|
42
|
+
the code but take bear in mind I make no committment to support,
|
43
|
+
maintain or even acknowledge the existence of this small cluster fluck.
|
data/lib/visitors/version.rb
CHANGED
data/spec/visitors_spec.rb
CHANGED
@@ -1,14 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Visitors do
|
4
|
-
describe '.assert_valid_field!' do
|
5
|
-
it 'protects against using unknown fields' do
|
6
|
-
error_message = %{Invalid field "invalid_field". Valid fields are []}
|
7
|
-
|
8
|
-
expect {
|
9
|
-
Visitors.stub!(:fields => %w[])
|
10
|
-
Visitors.assert_valid_field!('invalid_field')
|
11
|
-
}.to raise_error(Visitors::UnsupportedField, error_message)
|
12
|
-
end
|
13
|
-
end
|
14
4
|
end
|