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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3f6a298b34fbb6e817f9f200bcd4789a180a1d2
4
- data.tar.gz: 4dead8b7639298a0795c6f3863065c205abe7876
3
+ metadata.gz: e9c81db5233d5b9f5c1f4f12c6dd0fc5ed070efe
4
+ data.tar.gz: 8156386a3041a17f2f71ae5bc3e75ab5ba47ceb7
5
5
  SHA512:
6
- metadata.gz: 5e43a0776886cc1b5ef7a1e9182becd3a5dc4999eacc8a7b02ec957e3a58629961cec0657b7b71caedfe7393718f63078d286b59f9249844ce4d4e9f7c598188
7
- data.tar.gz: 69f8f55e94dfc7d4ac8c6d0cf030cf33638c92de65d0f1b95d31bcab9555417c4ea08dad8a691547fce644d813b552100f31860f579266ddc2d9e162771675bf
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
- ab_counter_inc("IndexViews", "exp", the_ab_test)
49
- ab_counter_inc("PageViews", "exp", ab_test("exp", "alt1", "alt2"))
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
- ab_counter_inc("OtherViews", "exp", the_ab_test)
56
- ab_counter_inc("PageViews", "exp", ab_test("exp", "alt1", "alt2"))
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
 
@@ -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.keys("co:*").collect { |k| k.gsub(/^.*:/,"") }
57
+ Split.redis.smembers(:counters)
56
58
  end
57
59
  end
58
60
  end
@@ -1,5 +1,5 @@
1
1
  module Split
2
2
  module Counters
3
- VERSION = "0.3.0"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -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.0
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: 2014-08-29 00:00:00.000000000 Z
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.0.6
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