ablab 0.2.1 → 0.2.2

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: cd4478bb1810dd0d5afddf97eb299cf2ebaf343b
4
- data.tar.gz: 0290705fe61858b5b355fee0ade8d9bb3e44a5fc
3
+ metadata.gz: b0ea8de68dd059dc93af4147afa564a21013d2c3
4
+ data.tar.gz: 08b1cb3ab370d6b1d911c87f2fa17aadacbe30d8
5
5
  SHA512:
6
- metadata.gz: e6ec28c30693a9030cd5d995d2d73242be556d16b0ac8167458d8bcec811c76a309250c0e610a02158654b04f9cb3d565dca8dea141ccca4b65658a9e53c380a
7
- data.tar.gz: 1a4b4e194003966c232068aa3bc1f4e0bde85751746aee96c76ddf60b6ad1a828f63074185e57c5157f0a099589541bb172e4f00ec8cf23cc7b917ce68e4b5b4
6
+ metadata.gz: 4192a527df2c3df978db666bacebe20e94b064c9fb8fd000dcf439381e76e0fd15fbacf55a71f8e6706ab00b306811cc6f78bfda86a97ab71f9583a8a26119b9
7
+ data.tar.gz: bee0012554b0699013555eb85361c5c042fa12427e8da40f4b9fd095a64541c72bccde8598ee5f5c02d92ac5da2090b7d7392e363e852ebc9b7033b327d787d2
@@ -112,7 +112,9 @@ module Ablab
112
112
  end
113
113
 
114
114
  def draw
115
- Random.new(session_id.hash ^ experiment.name.hash).rand(1000)
115
+ sid_hash = Digest::SHA1.hexdigest(session_id)[-8..-1].to_i(16)
116
+ exp_hash = Digest::SHA1.hexdigest(experiment.name.to_s)[-8..-1].to_i(16)
117
+ sid_hash ^ exp_hash % 1000
116
118
  end
117
119
  end
118
120
 
@@ -1,3 +1,3 @@
1
1
  module Ablab
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -183,5 +183,14 @@ describe Ablab do
183
183
  allow(run).to receive(:draw).and_return 300
184
184
  expect(run.group).to be_nil
185
185
  end
186
+
187
+ describe "#draw" do
188
+ it "is stable across ruby processes" do
189
+ d1 = Ablab::Run.new(experiment, '8asd7f8asf7').draw
190
+ dir = File.expand_path(File.dirname(__FILE__), '../lib')
191
+ d2 = `bundle exec ruby -I#{dir} -e "require 'ablab'; require 'ostruct'; puts Ablab::Run.new(OpenStruct.new(name: :foo), '8asd7f8asf7').draw"`
192
+ expect(d1).to eq(d2.to_i)
193
+ end
194
+ end
186
195
  end
187
196
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ablab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Ongaro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  requirements: []
137
137
  rubyforge_project:
138
- rubygems_version: 2.2.2
138
+ rubygems_version: 2.5.1
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Ablab - A/B testing on Rails