split 1.4.5 → 1.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: 1c048eebd0c41a821d257be6a6ee61175df3d413
4
- data.tar.gz: 1585aa44b15a8ba0258f545f84a880d06b1b58fc
3
+ metadata.gz: ee14a60caa6a0c07d046a7496ed7134f8fcc2693
4
+ data.tar.gz: 81f5c53dbb61c759e28d646f38ec498354d6b02d
5
5
  SHA512:
6
- metadata.gz: d65b2592b5c29c53da81491234d00264444a5261bcb354eed72914aa3b6e9faf9b9b9a533412895899d54dffb93b9483b6943318b53771a257faf71518860361
7
- data.tar.gz: 856c23b850dee54c658c73cca8bb6b5f02220f5c44d394bb2281c4d948eeb7529773867fa1403ca6b20122c2a032c405378faa1baac7dff8eaf6e9f64e153066
6
+ metadata.gz: cd05eba6701c96c861f688416e56ee4fc7086a2fcbba07ce81ca6cfa0a9bc5b0c070f135bc1de99693610009b557dff082a9882a8e129109284beaefbb4cdc4a
7
+ data.tar.gz: cdc9d7430bba23a5ca53656b3cd3509de65b605821126853cdee23424cd017097bacb534d64f0cd3631907cf88b28dee49d6bd800cb2a10235a2ddeefea5a183
data/.travis.yml CHANGED
@@ -9,7 +9,5 @@ gemfile:
9
9
  before_install:
10
10
  - gem install bundler
11
11
 
12
- services:
13
- - redis-server
14
12
  cache: bundler
15
13
  sudo: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 1.5.0 (June 8th, 2016)
2
+
3
+ Features:
4
+
5
+ - Add `expire_seconds:` TTL option to RedisAdapter (@karmakaze, #409)
6
+ - Optional custom persistence adapter (@ndelage, #411)
7
+
8
+ Misc:
9
+
10
+ - Use fakeredis for testing (@andrew, #412)
11
+
1
12
  ## 1.4.5 (June 7th, 2016)
2
13
 
3
14
  Bugfixes:
data/README.md CHANGED
@@ -221,6 +221,7 @@ end
221
221
  Options:
222
222
  * `lookup_by`: method to invoke per request for uniquely identifying ab_users (mandatory configuration)
223
223
  * `namespace`: separate namespace to store these persisted values (default "persistence")
224
+ * `expire_seconds`: sets TTL for user key. (if a user is in multiple experiments most recent update will reset TTL for all their assignments)
224
225
 
225
226
  #### Custom Adapter
226
227
 
@@ -27,6 +27,8 @@ module Split
27
27
 
28
28
  def []=(field, value)
29
29
  Split.redis.hset(redis_key, field, value)
30
+ expire_seconds = self.class.config[:expire_seconds]
31
+ Split.redis.expire(redis_key, expire_seconds) if expire_seconds
30
32
  end
31
33
 
32
34
  def delete(field)
data/lib/split/user.rb CHANGED
@@ -4,8 +4,8 @@ module Split
4
4
  def_delegators :@user, :keys, :[], :[]=, :delete
5
5
  attr_reader :user
6
6
 
7
- def initialize(context)
8
- @user = Split::Persistence.adapter.new(context)
7
+ def initialize(context, adapter=nil)
8
+ @user = adapter || Split::Persistence.adapter.new(context)
9
9
  end
10
10
 
11
11
  def cleanup_old_experiments!
data/lib/split/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Split
3
3
  MAJOR = 1
4
- MINOR = 4
5
- PATCH = 5
4
+ MINOR = 5
5
+ PATCH = 0
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
7
7
  end
data/spec/spec_helper.rb CHANGED
@@ -14,10 +14,15 @@ require 'complex' if RUBY_VERSION.match(/1\.8/)
14
14
 
15
15
  Dir['./spec/support/*.rb'].each { |f| require f }
16
16
 
17
+ require "fakeredis"
18
+
19
+ fakeredis = Redis.new
20
+
17
21
  RSpec.configure do |config|
18
22
  config.order = 'random'
19
23
  config.before(:each) do
20
24
  Split.configuration = Split::Configuration.new
25
+ Split.redis = fakeredis
21
26
  Split.redis.flushall
22
27
  @ab_user = mock_user
23
28
  params = nil
data/spec/user_spec.rb CHANGED
@@ -60,4 +60,17 @@ describe Split::User do
60
60
  end
61
61
  end
62
62
  end
63
+
64
+ context "instantiated with custom adapter" do
65
+ let(:custom_adapter) { double(:persistence_adapter) }
66
+
67
+ before do
68
+ @subject = described_class.new(context, custom_adapter)
69
+ end
70
+
71
+ it "sets user to the custom adapter" do
72
+ expect(@subject.user).to eq(custom_adapter)
73
+ end
74
+ end
75
+
63
76
  end
data/split.gemspec CHANGED
@@ -31,4 +31,5 @@ Gem::Specification.new do |s|
31
31
  s.add_development_dependency 'rake', '~> 11.1'
32
32
  s.add_development_dependency 'rspec', '~> 3.4'
33
33
  s.add_development_dependency 'pry', '~> 0.10'
34
+ s.add_development_dependency 'fakeredis', '~> 0.5.0'
34
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: split
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Nesbitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-07 00:00:00.000000000 Z
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.10'
153
+ - !ruby/object:Gem::Dependency
154
+ name: fakeredis
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.5.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.5.0
153
167
  description:
154
168
  email:
155
169
  - andrewnez@gmail.com