vinted-ab 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0a21ffb413b2b0c68b513cc983fae9e5073f0a1b
4
- data.tar.gz: 7508566e6b56ff075d45180d7da2dc3aa84b4566
3
+ metadata.gz: 3566b6e9c6dc50f3ca1e435644b7e3bb1eab9fd1
4
+ data.tar.gz: 062d9118532a050d1155981c7ca4633911365421
5
5
  SHA512:
6
- metadata.gz: 8f4f9ae4e40487dcbfebe92e1828711c0b40ebde3711141fe477623e421cda679400365e7a6855d02742479290905fd9c7d682766525af4dafc6bd2035ecf628
7
- data.tar.gz: 5691f5a0724ce36648a7029d7c095a4034c50c8e675e747ef44b69083b149e68342a3597494d07fb7d79c57296235f2ec9c30655b9491663e740d0742f9b7aba
6
+ metadata.gz: 3a23e68efe7ebd7e8442f088feb526f1718338b4b41e94375de361deca94b865ad526634a4fd267999b6aebed3d4729d419a7a0a1bbc6159480e38e2b4516e42
7
+ data.tar.gz: 5f40b68ced5a8adf1f9eed2a34066e68ca94d7716419694bcba22004b3df738509a079d9eb37aeb3987bfecafd279c40114c7dbb7e03c8d9813acf89e90ec903
@@ -40,7 +40,7 @@ module Ab
40
40
  end
41
41
 
42
42
  def weight_id
43
- @variant_digest ||= digest(@experiment.seed + @id.to_s) % positive_weight_sum
43
+ @variant_digest ||= digest("#{@experiment.seed}#{@id}") % positive_weight_sum
44
44
  end
45
45
 
46
46
  def positive_weight_sum
data/lib/ab/experiment.rb CHANGED
@@ -22,7 +22,7 @@ module Ab
22
22
  end
23
23
 
24
24
  def start_at
25
- @start_at ||= DateTime.parse(hash['start_at'])
25
+ @start_at ||= hash['start_at'].nil? ? DateTime.new(0) : DateTime.parse(hash['start_at'])
26
26
  end
27
27
 
28
28
  def end_at
@@ -15,6 +15,7 @@ module Ab
15
15
 
16
16
  (config['ab_tests'] || []).each do |experiment|
17
17
  name = experiment['name']
18
+ @assigned_experiments[name] = nil
18
19
  define_singleton_method(name) do
19
20
  experiment = Experiment.new(experiment, config['salt'], config['bucket_count'])
20
21
  @assigned_experiments[name] ||= AssignedExperiment.new(experiment, id)
@@ -22,6 +23,13 @@ module Ab
22
23
  end
23
24
  end
24
25
 
26
+ def all
27
+ result = @assigned_experiments.keys.map do |name|
28
+ [name, send(name).variant]
29
+ end
30
+ Hash[result]
31
+ end
32
+
25
33
  def method_missing(meth, *args, &block)
26
34
  @null_experiment ||= NullExperiment.new
27
35
  end
data/lib/ab/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ab
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -10,7 +10,7 @@ module Ab
10
10
  let(:config) { {} }
11
11
 
12
12
  specify 'has no public methods' do
13
- (subject.public_methods(false) - [:method_missing, :respond_to?]).count.should == 0
13
+ (subject.public_methods(false) - [:method_missing, :respond_to?, :all]).count.should == 0
14
14
  end
15
15
 
16
16
  specify 'does not raise if method is not existant' do
@@ -25,11 +25,13 @@ module Ab
25
25
  'bucket_count' => 1000,
26
26
  'ab_tests' => [{
27
27
  'name' => 'feed',
28
+ 'buckets' => 'all',
28
29
  'variants' => [{ 'name' => 'enabled', 'chance_weight' => 1 }]
29
30
  }]
30
31
  }
31
32
  }
32
33
  its(:feed) { should be_kind_of AssignedExperiment }
34
+ its(:all) { should == { 'feed' => 'enabled' } }
33
35
  end
34
36
  end
35
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vinted-ab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindaugas Mozūras
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-29 00:00:00.000000000 Z
12
+ date: 2014-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hooks