banana_split 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ module BananaSplit
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,26 +1,26 @@
1
1
  module BananaSplit
2
2
  module ViewHelpers
3
3
 
4
- def ab_test(test_name, designs)
4
+ def ab_test(test_name, variations)
5
5
  test = AbTest.find_or_create_by_name(:name => test_name.to_s)
6
6
 
7
7
  test_run = AbTestRun.find_by_session_id_and_ab_test_id(session_id, test.id)
8
8
 
9
- design = if test_run
10
- test_run.ab_test_design
9
+ variation = if test_run
10
+ test_run.ab_test_variation
11
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)
12
+ variation_name = variations.keys.sample
13
+ AbTestVariation.find_or_create_by_ab_test_id_and_name(:ab_test_id => test.id, :name => variation_name)
14
14
  end
15
15
 
16
- design_render_options = designs[design.name.to_sym]
16
+ variation_render_options = variations[variation.name.to_sym]
17
17
 
18
18
  test.runs.create({
19
- :ab_test_design_id => design.id,
19
+ :ab_test_variation_id => variation.id,
20
20
  :session_id => session_id
21
21
  }) unless test_run
22
22
 
23
- design_render_options ? render(design_render_options) : nil
23
+ variation_render_options ? render(variation_render_options) : nil
24
24
  end
25
25
  end
26
26
  end
@@ -8,7 +8,7 @@ module BananaSplit
8
8
 
9
9
  def create_models
10
10
  copy_file "models/ab_test.rb", "app/models/ab_test.rb"
11
- copy_file "models/ab_test_design.rb", "app/models/ab_test_design.rb"
11
+ copy_file "models/ab_test_variation.rb", "app/models/ab_test_variation.rb"
12
12
  copy_file "models/ab_test_run.rb", "app/models/ab_test_run.rb"
13
13
  end
14
14
 
@@ -4,7 +4,7 @@ class CreateBananaSplitTables < ActiveRecord::Migration
4
4
  t.string :name
5
5
  end
6
6
 
7
- create_table(:ab_test_designs) do |t|
7
+ create_table(:ab_test_variations) do |t|
8
8
  t.references :ab_test
9
9
  t.string :name
10
10
  end
@@ -12,14 +12,14 @@ class CreateBananaSplitTables < ActiveRecord::Migration
12
12
  create_table(:ab_test_runs) do |t|
13
13
  t.string :session_id
14
14
  t.references :ab_test
15
- t.references :ab_test_design
15
+ t.references :ab_test_variation
16
16
  t.integer :value, :null => false, :default => 0
17
17
  end
18
18
  end
19
19
 
20
20
  def self.down
21
21
  drop_table :ab_tests
22
- drop_table :ab_test_designs
22
+ drop_table :ab_test_variations
23
23
  drop_table :ab_test_runs
24
24
  end
25
25
  end
@@ -1,4 +1,4 @@
1
1
  class AbTest < ActiveRecord::Base
2
- has_many :designs, :class_name => 'AbTestDesign', :dependent => :destroy
2
+ has_many :variations, :class_name => 'AbTestVariation', :dependent => :destroy
3
3
  has_many :runs, :class_name => 'AbTestRun', :dependent => :destroy
4
4
  end
@@ -1,4 +1,4 @@
1
1
  class AbTestRun < ActiveRecord::Base
2
2
  belongs_to :ab_test
3
- belongs_to :ab_test_design
3
+ belongs_to :ab_test_variation
4
4
  end
@@ -0,0 +1,3 @@
1
+ class AbTestVariation < ActiveRecord::Base
2
+ belongs_to :ab_test
3
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: banana_split
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dennis Plougman Buus
@@ -41,8 +41,8 @@ files:
41
41
  - lib/generators/banana_split_generator.rb
42
42
  - lib/generators/templates/migrations/migration.rb
43
43
  - lib/generators/templates/models/ab_test.rb
44
- - lib/generators/templates/models/ab_test_design.rb
45
44
  - lib/generators/templates/models/ab_test_run.rb
45
+ - lib/generators/templates/models/ab_test_variation.rb
46
46
  - README.rdoc
47
47
  - LICENSE
48
48
  has_rdoc: true
@@ -1,3 +0,0 @@
1
- class AbTestDesign < ActiveRecord::Base
2
- belongs_to :ab_test
3
- end