laboratory 0.1.2 → 0.1.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
  SHA256:
3
- metadata.gz: f2c796f9282f1162446569e2625bd596b0505132362949dd86cb2436db4fa760
4
- data.tar.gz: 66289aae59ab02f88b92af86c070688e1b37f2f47044e0454f9ee00733413b9f
3
+ metadata.gz: 55e19407d1d182b0d5f0a9530b0b18b739d0773c17755373d46309c78af10c99
4
+ data.tar.gz: 5581f4f721d03c9608b17c6e028766c7642d42139e91489729c301fa1d0d6335
5
5
  SHA512:
6
- metadata.gz: 74dd54de95625344b74c61f8ade928e72f1a4642420a059cd6a75b4733e639ffa15541a73d65b87328c4e653ad1f44707e71eb1ca49d3a44dd562cd9e8fda475
7
- data.tar.gz: f737d73fa7f214a9ce4e9a50e5d9351cc660df42ba8cc470f5c034e5bd065fe4e602fdfed6b62dbff4039e91be1932bcafe58fd4fe0ff07bef5ed208b2f19bb7
6
+ metadata.gz: 597b0b0be8cd204955109ede2e49d7a7c35b14380e6bf60fa93b8332ec2bdb19dd20b3067b1f21e5a37119115753d94f7b81c9ae54a67b4fa01b62c9fa510814
7
+ data.tar.gz: 9716b7aa6e505c7082517c77cdf13647b7d02c6107ebf5e2fcc10d89837b429a8fe96808105b06849359f0d714ab846a2da9b35b10e86d791330d109f6ee1ddd
@@ -0,0 +1,33 @@
1
+ name: Continuous Integration
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - master
8
+
9
+ jobs:
10
+ ruby_unit_tests:
11
+ runs-on: ubuntu-latest
12
+
13
+ env:
14
+ RAILS_ENV: test
15
+
16
+ steps:
17
+ - uses: actions/checkout@v1
18
+ - uses: actions/setup-ruby@v1
19
+ with:
20
+ ruby-version: '2.6.x'
21
+
22
+ - run: gem install bundler -v 2.1.4
23
+
24
+ - uses: actions/cache@v1
25
+ with:
26
+ path: vendor/bundle
27
+ key: v1-bundle-cache-${{ hashFiles('**/Gemfile.lock') }}
28
+ restore-keys: |
29
+ v1-bundle-cache-
30
+
31
+ - run: bundle config set path 'vendor/bundle'
32
+ - run: bundle install --jobs 4 --retry 3
33
+ - run: bundle exec rspec spec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- laboratory (0.1.2)
4
+ laboratory (0.1.3)
5
5
  redis (>= 2.1)
6
6
  sinatra (>= 1.2.6)
7
7
 
data/README.md CHANGED
@@ -287,8 +287,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
287
287
 
288
288
  ### Todo List
289
289
 
290
- - [ ] Test in a multi-threaded puma environment
291
- - [ ] Test performance in a A/A test on production
290
+ - [ ] Test performance in an A/A test on production
291
+ - [ ] Use for an A/B test on production
292
292
 
293
293
  ## Contributing
294
294
 
@@ -1,17 +1,15 @@
1
1
  module Laboratory
2
2
  class Config
3
- class << self
4
- attr_accessor(
5
- :current_user_id,
6
- :adapter,
7
- :actor,
8
- :on_assignment_to_variant,
9
- :on_event_recorded
10
- )
3
+ attr_accessor(
4
+ :current_user_id,
5
+ :adapter,
6
+ :actor,
7
+ :on_assignment_to_variant,
8
+ :on_event_recorded
9
+ )
11
10
 
12
- def current_user
13
- @current_user ||= Laboratory::User.new(id: current_user_id)
14
- end
11
+ def current_user
12
+ @current_user ||= Laboratory::User.new(id: current_user_id)
15
13
  end
16
14
  end
17
15
  end
@@ -110,7 +110,7 @@ module Laboratory
110
110
  variant = algorithm.pick!(variants)
111
111
  variant.add_participant(user)
112
112
 
113
- Laboratory::Config.on_assignment_to_variant&.call(self, variant, user)
113
+ Laboratory.config.on_assignment_to_variant&.call(self, variant, user)
114
114
 
115
115
  save
116
116
  variant
@@ -124,7 +124,7 @@ module Laboratory
124
124
  variant = variants.find { |s| s.id == variant_id }
125
125
  variant.add_participant(user)
126
126
 
127
- Laboratory::Config.on_assignment_to_variant&.call(self, variant, user)
127
+ Laboratory.config.on_assignment_to_variant&.call(self, variant, user)
128
128
 
129
129
  save
130
130
  variant
@@ -147,7 +147,7 @@ module Laboratory
147
147
 
148
148
  event.event_recordings << event_recording
149
149
 
150
- Laboratory::Config.on_event_recorded&.call(self, variant, user, event)
150
+ Laboratory.config.on_event_recorded&.call(self, variant, user, event)
151
151
 
152
152
  save
153
153
  event_recording
@@ -1,3 +1,3 @@
1
1
  module Laboratory
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
data/lib/laboratory.rb CHANGED
@@ -17,7 +17,7 @@ require 'laboratory/calculations/confidence_level'
17
17
  module Laboratory
18
18
  class << self
19
19
  def config
20
- Laboratory::Config
20
+ Thread.current[:laboratory_config] ||= Laboratory::Config.new
21
21
  end
22
22
  end
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: laboratory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niall Paterson
@@ -87,6 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".github/workflows/continuous-integration.yml"
90
91
  - ".github/workflows/linters.yml"
91
92
  - ".gitignore"
92
93
  - ".rspec"