split-counters 0.3.0 → 0.3.1
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.
- checksums.yaml +4 -4
- data/Readme.mdown +8 -4
- data/lib/split/counters.rb +3 -1
- data/lib/split/counters/version.rb +1 -1
- data/spec/counters_spec.rb +3 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9c81db5233d5b9f5c1f4f12c6dd0fc5ed070efe
|
4
|
+
data.tar.gz: 8156386a3041a17f2f71ae5bc3e75ab5ba47ceb7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8da2383690a10a6399c7f313460b4ad5993bd77b2ca2c4db10852fc76fd911645b57ff911028b812a1844a6fd2e4d6b5fcadb87eccc8795399d229a7a69527f7
|
7
|
+
data.tar.gz: bce9992dea9629b319082696307413db71c7f95b5f6a4341f1493ce659f137d75b9d072b0efec2a4d777a6dabb9b12bc1170a0739d0e804de645cdde22345cb6
|
data/Readme.mdown
CHANGED
@@ -45,15 +45,19 @@ A simple example in a Rails app could be:
|
|
45
45
|
def index
|
46
46
|
the_ab_test = ab_test("exp", "alt1", "alt2")
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
if !exclude_visitor?
|
49
|
+
ab_counter_inc("IndexViews", "exp", the_ab_test)
|
50
|
+
ab_counter_inc("PageViews", "exp", ab_test("exp", "alt1", "alt2"))
|
51
|
+
end
|
50
52
|
end
|
51
53
|
|
52
54
|
def other
|
53
55
|
the_ab_test = ab_test("exp", "alt1", "alt2")
|
54
56
|
|
55
|
-
|
56
|
-
|
57
|
+
if !exclude_visitor?
|
58
|
+
ab_counter_inc("OtherViews", "exp", the_ab_test)
|
59
|
+
ab_counter_inc("PageViews", "exp", ab_test("exp", "alt1", "alt2"))
|
60
|
+
end
|
57
61
|
end
|
58
62
|
```
|
59
63
|
|
data/lib/split/counters.rb
CHANGED
@@ -21,6 +21,7 @@ module Split
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.inc(name, experiment, alternative)
|
24
|
+
Split.redis.sadd(:counters, name)
|
24
25
|
Split.redis.hincrby(Split::Counters.hash_name_for_name(name), Split::Counters.keyname_for_experiment_and_alternative(experiment, alternative), 1)
|
25
26
|
end
|
26
27
|
|
@@ -33,6 +34,7 @@ module Split
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def self.delete(name)
|
37
|
+
Split.redis.srem(:counters, name)
|
36
38
|
Split.redis.del(Split::Counters.hash_name_for_name(name))
|
37
39
|
end
|
38
40
|
|
@@ -52,7 +54,7 @@ module Split
|
|
52
54
|
end
|
53
55
|
|
54
56
|
def self.all_counter_names
|
55
|
-
Split.redis.
|
57
|
+
Split.redis.smembers(:counters)
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
data/spec/counters_spec.rb
CHANGED
@@ -17,6 +17,7 @@ describe Split::Counters do
|
|
17
17
|
it "should create a counter upon using it, if it does not exist" do
|
18
18
|
Split::Counters.inc('co', 'exp1', 'alt1')
|
19
19
|
Split::Counters.current_value('co', 'exp1', 'alt1').should eq("1")
|
20
|
+
Split::Counters.all_counter_names.should include('co')
|
20
21
|
end
|
21
22
|
|
22
23
|
it "should create a counter directly upon using it, if it does not exist" do
|
@@ -29,8 +30,10 @@ describe Split::Counters do
|
|
29
30
|
it "should be possible to delete a counter" do
|
30
31
|
Split::Counters.inc('co','exp1', 'alt1')
|
31
32
|
Split::Counters.exists?('co').should eq(true)
|
33
|
+
Split::Counters.all_counter_names.should include('co')
|
32
34
|
Split::Counters.delete('co')
|
33
35
|
Split::Counters.exists?('co').should eq(false)
|
36
|
+
Split::Counters.all_counter_names.should_not include('co')
|
34
37
|
end
|
35
38
|
|
36
39
|
it "should be possible to reset a counter" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: split-counters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernard Kroes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: split
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
85
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.1.11
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Split extension for counting things per experiment and alternative
|