verdict 0.4.1 → 0.5.0

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: 2e529fa9948f7f7176df69a622210e40594d3c91
4
- data.tar.gz: e576284cd0a3eed14ebb597acf31bbf87b86a681
3
+ metadata.gz: e5d867e9231108358536850b04548a9a43594d79
4
+ data.tar.gz: 272e5fb808e0083732fd5516660812ce92ade4c9
5
5
  SHA512:
6
- metadata.gz: 8347a5f689329717098cb9d9d42c3c78731a55863e5f1fe8c6debf6db3f8155ffd65fb22b4d7af50d05a05e1980af41d42e5a72bef81ce84cd43371b045bf0e9
7
- data.tar.gz: 3a27b4ff3dd5db6705be1f715cfd1e8860a5df9c1b54344f5e3693ea6bf426d8c40f6b3d2a1e6f2007f0a7c94057325fb18c2dabe9e1ed5f1dc287e5c1db7a8e
6
+ metadata.gz: 4883a16667083e18a41955708c0624abf6caa0360df42b7a58968b528a4a04cef3aee013733f4e046ce37994b437834a14182429324c454313f3061e68cf6767
7
+ data.tar.gz: a62aba796b913ca660d039881149edfa5cbda21f240683b9fe66e28441058e4f0ce6e0c49dcd2e7af02f224005824d91c5b72731963cda6f6e3f52871c56402d
@@ -1,4 +1,6 @@
1
1
  language: ruby
2
+ cache: bundler
3
+ before_install: gem update bundler
2
4
  script: bundle exec rake
3
5
  rvm:
4
6
  - 1.9.3
@@ -1,12 +1,11 @@
1
1
  class Verdict::Assignment
2
-
3
2
  attr_reader :experiment, :subject_identifier, :group, :created_at
4
3
 
5
4
  def initialize(experiment, subject_identifier, group, originally_created_at, temporary = false)
6
5
  @experiment = experiment
7
6
  @subject_identifier = subject_identifier
8
7
  @group = group
9
- @returning = !originally_created_at.nil?
8
+ @first = originally_created_at.nil? || experiment.manual_assignment_timestamps?
10
9
  @created_at = originally_created_at || Time.now.utc
11
10
  @temporary = temporary
12
11
  end
@@ -32,7 +31,7 @@ class Verdict::Assignment
32
31
  end
33
32
 
34
33
  def returning?
35
- @returning
34
+ @first.nil?
36
35
  end
37
36
 
38
37
  def handle
@@ -14,13 +14,14 @@ class Verdict::Experiment
14
14
  @handle = handle.to_s
15
15
 
16
16
  options = default_options.merge(options)
17
- @qualifier = options[:qualifier]
18
- @event_logger = options[:event_logger] || Verdict::EventLogger.new(Verdict.default_logger)
19
- @storage = storage(options[:storage] || :memory)
20
- @store_unqualified = options[:store_unqualified]
21
- @segmenter = options[:segmenter]
22
- @subject_type = options[:subject_type]
23
- @disqualify_empty_identifier = options[:disqualify_empty_identifier]
17
+ @qualifier = options[:qualifier]
18
+ @event_logger = options[:event_logger] || Verdict::EventLogger.new(Verdict.default_logger)
19
+ @storage = storage(options[:storage] || :memory)
20
+ @store_unqualified = options[:store_unqualified]
21
+ @segmenter = options[:segmenter]
22
+ @subject_type = options[:subject_type]
23
+ @disqualify_empty_identifier = options[:disqualify_empty_identifier]
24
+ @manual_assignment_timestamps = options[:manual_assignment_timestamps]
24
25
 
25
26
  instance_eval(&block) if block_given?
26
27
  end
@@ -35,6 +36,10 @@ class Verdict::Experiment
35
36
  @store_unqualified
36
37
  end
37
38
 
39
+ def manual_assignment_timestamps?
40
+ @manual_assignment_timestamps
41
+ end
42
+
38
43
  def group(handle)
39
44
  segmenter.groups[handle.to_s]
40
45
  end
@@ -1,3 +1,3 @@
1
1
  module Verdict
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -73,4 +73,22 @@ class AssignmentTest < Minitest::Test
73
73
  assert_equal '2012-01-01T00:00:00Z', json['created_at']
74
74
  end
75
75
  end
76
+
77
+ def test_returning_assignment
78
+ assignment_with_timestamp = Verdict::Assignment.new(@experiment, 'test_subject_id', @group, Time.now.utc)
79
+ assert assignment_with_timestamp.returning?
80
+
81
+ assignment_without_timestamp = Verdict::Assignment.new(@experiment, 'test_subject_id', @group, nil)
82
+ refute assignment_without_timestamp.returning?
83
+ end
84
+
85
+ def test_returning_with_manual_assignment_timestamps_experiment_option
86
+ experiment = Verdict::Experiment.new('assignment test', manual_assignment_timestamps: true)
87
+
88
+ assignment_with_timestamp = Verdict::Assignment.new(experiment, 'test_subject_id', @group, Time.now.utc)
89
+ refute assignment_with_timestamp.returning?
90
+
91
+ assignment_without_timestamp = Verdict::Assignment.new(experiment, 'test_subject_id', @group, nil)
92
+ refute assignment_without_timestamp.returning?
93
+ end
76
94
  end
@@ -75,6 +75,22 @@ class ExperimentTest < Minitest::Test
75
75
  assert_equal nil, e.switch(3)
76
76
  end
77
77
 
78
+ def test_experiment_without_manual_assignment_timestamps_option
79
+ e = Verdict::Experiment.new('test') do
80
+ groups { group :all, 100 }
81
+ end
82
+
83
+ refute e.manual_assignment_timestamps?
84
+ end
85
+
86
+ def test_experiment_with_manual_assignment_timestamps_option
87
+ e = Verdict::Experiment.new('test', manual_assignment_timestamps: true) do
88
+ groups { group :all, 100 }
89
+ end
90
+
91
+ assert e.manual_assignment_timestamps?
92
+ end
93
+
78
94
  def test_subject_identifier
79
95
  e = Verdict::Experiment.new('test')
80
96
  assert_equal '123', e.retrieve_subject_identifier(stub(id: 123, to_s: '456'))
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verdict
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 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: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '5.2'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mocha
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: timecop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: redis
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Shopify Experiments classes
@@ -88,8 +88,8 @@ executables: []
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
- - .gitignore
92
- - .travis.yml
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
93
  - Gemfile
94
94
  - LICENSE
95
95
  - README.md
@@ -144,17 +144,17 @@ require_paths:
144
144
  - lib
145
145
  required_ruby_version: !ruby/object:Gem::Requirement
146
146
  requirements:
147
- - - '>='
147
+ - - ">="
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - '>='
152
+ - - ">="
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
156
  rubyforge_project:
157
- rubygems_version: 2.0.14
157
+ rubygems_version: 2.2.3
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: A library to centrally define experiments for your application, and collect