sixpack-client 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +14 -6
- data/lib/sixpack/version.rb +1 -1
- data/lib/sixpack.rb +8 -2
- data/spec/lib/sixpack_spec.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Njk3MGE1YTljNWIyZjA1MTNiYzY4ZjM0YjY2ODQ3NDU3NzVmNjhkMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmM2ZDcxZmY2MmNjOWEzNjZkZjVhMDU0YzFhNjM1Y2YzZTNjNGRlMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWVjNjJjODkzN2UyMjQ4M2I2ODg5Y2M1MzBmN2M5MzExZDAzODIzODhmOGFj
|
10
|
+
ZTBlOTViNjFkNGFhMzU4OTFlM2EzMTNlNDU2OTgyYmU5ZDQyYmM1M2FhN2Rh
|
11
|
+
ZTE5M2ZmMWE5MGJhMDQ0NDQ3Y2NjZTM5MjU2YTM2ZTRlYzk1NDM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTg0YWEwYzEwNmM3NmE5YjZlZDE3M2I2NmE2YjlhYWJkMmEzMmZkNGY4YWY3
|
14
|
+
YmQyNGRhOGM3MjQzMDdlNzM2NTQ3MjdmNDFiYWJkZGIxOTRiYTJiNmFkMWNj
|
15
|
+
ZWQxNWI4ODE2YjQ3OWJmMDQyNjExNDVmYzU3Y2RmY2RkZGI4ZGI=
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Sixpack
|
2
2
|
|
3
|
-
Ruby client library for
|
3
|
+
Ruby client library for SeatGeek's Sixpack ab testing framework.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -26,7 +26,10 @@ require 'sixpack'
|
|
26
26
|
session = Sixpack::Session.new
|
27
27
|
|
28
28
|
# Participate in a test (creates the test if necessary)
|
29
|
-
session.participate("new-test", ["alternative-1", "alternative-2"])
|
29
|
+
resp = session.participate("new-test", ["alternative-1", "alternative-2"])
|
30
|
+
if resp["alternative"]["name"] == "alternative-1"
|
31
|
+
css_style = "blue"
|
32
|
+
end
|
30
33
|
|
31
34
|
# Convert
|
32
35
|
session.convert("new-test")
|
@@ -48,12 +51,17 @@ session = Sixpack::Session.new client_id
|
|
48
51
|
session.convert("new-test")
|
49
52
|
```
|
50
53
|
|
51
|
-
Sessions can take an optional `options`
|
54
|
+
Sessions can take an optional `options` hash that takes `:base_url`, and a params hash that takes `:ip_address`, and `:user_agent` a keys. If you would like to instantiate a session with a known client id, you can do that here. IP address and user agent can be passed to assist in bot detection.
|
52
55
|
|
53
|
-
options = {
|
54
|
-
|
56
|
+
options = {
|
57
|
+
:host => 'http://mysixpacklocation.com',
|
58
|
+
}
|
59
|
+
params = {
|
60
|
+
:ip_address => '1.2.3.4'
|
61
|
+
}
|
62
|
+
session = Session(client_id="123", options=options, params=params)
|
55
63
|
|
56
|
-
If Sixpack is unreachable or other errors occur, sixpack-
|
64
|
+
If Sixpack is unreachable or other errors occur, sixpack-rb will provide the control alternative object.
|
57
65
|
|
58
66
|
|
59
67
|
## Contributing
|
data/lib/sixpack/version.rb
CHANGED
data/lib/sixpack.rb
CHANGED
@@ -39,7 +39,7 @@ module Sixpack
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def participate(experiment_name, alternatives, force=nil)
|
42
|
+
def participate(experiment_name, alternatives, force=nil, traffic_fraction=1)
|
43
43
|
if !(experiment_name =~ /^[a-z0-9][a-z0-9\-_ ]*$/)
|
44
44
|
raise ArgumentError, "Bad experiment_name"
|
45
45
|
end
|
@@ -48,6 +48,10 @@ module Sixpack
|
|
48
48
|
raise ArgumentError, "Must specify at least 2 alternatives"
|
49
49
|
end
|
50
50
|
|
51
|
+
if traffic_fraction.to_f < 0 || traffic_fraction > 1
|
52
|
+
raise ArgumentError, "Invalid Traffic Fraction"
|
53
|
+
end
|
54
|
+
|
51
55
|
alternatives.each { |alt|
|
52
56
|
if !(alt =~ /^[a-z0-9][a-z0-9\-_ ]*$/)
|
53
57
|
raise ArgumentError, "Bad alternative name: #{alt}"
|
@@ -57,8 +61,10 @@ module Sixpack
|
|
57
61
|
params = {
|
58
62
|
:client_id => @client_id,
|
59
63
|
:experiment => experiment_name,
|
60
|
-
:alternatives => alternatives
|
64
|
+
:alternatives => alternatives,
|
65
|
+
:traffic_fraction => traffic_fraction
|
61
66
|
}
|
67
|
+
|
62
68
|
if !force.nil? && alternatives.include?(force)
|
63
69
|
return {"status" => "ok", "alternative" => {"name" => force}, "experiment" => {"version" => 0, "name" => experiment_name}, "client_id" => @client_id}
|
64
70
|
end
|
data/spec/lib/sixpack_spec.rb
CHANGED
@@ -67,6 +67,13 @@ describe Sixpack do
|
|
67
67
|
}.to raise_error
|
68
68
|
end
|
69
69
|
|
70
|
+
it "should not allow bad traffic tractions" do
|
71
|
+
expect {
|
72
|
+
sess = Sixpack::Session.new
|
73
|
+
sess.participate('testing', ['trolled', 'not-trolled'], nil, 2)
|
74
|
+
}.to raise_error
|
75
|
+
end
|
76
|
+
|
70
77
|
it "should not allow bad alternatives names" do
|
71
78
|
expect {
|
72
79
|
sess = Sixpack::Session.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sixpack-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SeatGeek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|