banana_split 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,21 +1,25 @@
|
|
1
1
|
module BananaSplit
|
2
2
|
module Controller
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
helper_method :session_id
|
7
7
|
end
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
|
11
|
+
def ab_goal(test_name, value = 1)
|
12
|
+
test = AbTest.find_by_name(test_name)
|
13
|
+
test_run = AbTestRun.find_by_session_id_and_ab_test_id(session_id, test.id)
|
14
|
+
if test_run && test_run.value == 0
|
15
|
+
test_run.update_attribute(:value, value)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def session_id
|
20
|
+
request.session_options[:id]
|
13
21
|
end
|
14
22
|
end
|
15
|
-
|
16
|
-
def current_user_id
|
17
|
-
current_user.id
|
18
|
-
end
|
19
|
-
|
23
|
+
|
20
24
|
end
|
21
25
|
end
|
data/lib/banana_split/version.rb
CHANGED
@@ -1,20 +1,26 @@
|
|
1
1
|
module BananaSplit
|
2
2
|
module ViewHelpers
|
3
|
-
|
3
|
+
|
4
4
|
def ab_test(test_name, designs)
|
5
5
|
test = AbTest.find_or_create_by_name(:name => test_name.to_s)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
design =
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
:
|
14
|
-
|
15
|
-
|
6
|
+
|
7
|
+
test_run = AbTestRun.find_by_session_id_and_ab_test_id(session_id, test.id)
|
8
|
+
|
9
|
+
design = if test_run
|
10
|
+
test_run.ab_test_design
|
11
|
+
else
|
12
|
+
design_name = designs.keys.sample
|
13
|
+
AbTestDesign.find_or_create_by_ab_test_id_and_name(:ab_test_id => test.id, :name => design_name)
|
14
|
+
end
|
15
|
+
|
16
|
+
design_render_options = designs[design.name.to_sym]
|
17
|
+
|
18
|
+
test.runs.create({
|
19
|
+
:ab_test_design_id => design.id,
|
20
|
+
:session_id => session_id
|
21
|
+
}) unless test_run
|
22
|
+
|
16
23
|
design_render_options ? render(design_render_options) : nil
|
17
24
|
end
|
18
|
-
|
19
25
|
end
|
20
26
|
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: banana_split
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 0.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Dennis Plougman Buus
|
@@ -15,10 +11,20 @@ autorequire:
|
|
15
11
|
bindir: bin
|
16
12
|
cert_chain: []
|
17
13
|
|
18
|
-
date:
|
14
|
+
date: 2011-02-25 00:00:00 +01:00
|
19
15
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: rails
|
19
|
+
prerelease: false
|
20
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
none: false
|
22
|
+
requirements:
|
23
|
+
- - ~>
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: "3.0"
|
26
|
+
type: :runtime
|
27
|
+
version_requirements: *id001
|
22
28
|
description: Description not written yet.
|
23
29
|
email: rasmusrnielsen@gmail.com
|
24
30
|
executables: []
|
@@ -53,21 +59,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
59
|
requirements:
|
54
60
|
- - ">="
|
55
61
|
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
57
|
-
- 0
|
58
62
|
version: "0"
|
59
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
64
|
none: false
|
61
65
|
requirements:
|
62
66
|
- - ">="
|
63
67
|
- !ruby/object:Gem::Version
|
64
|
-
segments:
|
65
|
-
- 0
|
66
68
|
version: "0"
|
67
69
|
requirements: []
|
68
70
|
|
69
71
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.5.0
|
71
73
|
signing_key:
|
72
74
|
specification_version: 3
|
73
75
|
summary: AB testing for Rails
|