rigor 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Paul Rosania
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ = Rigor
2
+
3
+ A rigorous A/B testing framework.
4
+
5
+ <b>Note: Rigor is prerelease code. The API is subject to change. You have been warned!</b>
6
+
7
+ == Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'rigor'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rigor
20
+
21
+ == Usage
22
+
23
+ == Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require "rigor/version"
2
+ require "rigor/treatment"
3
+ require "rigor/test"
4
+
5
+ # Frameworks
6
+ require "rigor/rails" if defined?(Rails::Railtie)
@@ -0,0 +1,31 @@
1
+ module Rigor
2
+ class Railtie < ::Rails::Railtie
3
+ initializer "rigor.load" do
4
+ Rigor::Rails.load!
5
+ end
6
+ end
7
+
8
+ module Rails
9
+ def self.load!
10
+ end
11
+
12
+ module Helpers
13
+ def treatment(test_name, &block)
14
+ test = Rigor::Test.find_by_name(test_name)
15
+ treatment = test.random_treatment
16
+
17
+ if block_given?
18
+ capture(treatment, &block)
19
+ else
20
+ treatment
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ if defined?(ActionController::Base)
28
+ ActionController::Base.class_eval do
29
+ helper Rigor::Rails::Helpers
30
+ end
31
+ end
@@ -0,0 +1,26 @@
1
+ module Rigor
2
+ class Test
3
+ def self.find_by_name(name)
4
+ Test.new
5
+ end
6
+
7
+ def treatments
8
+ [Treatment.new(:control), Treatment.new(:test)]
9
+ end
10
+
11
+ def random_treatment
12
+ treatment_max = 0
13
+ assignment = rand(cumulative_weights)
14
+ treatments.each do |treatment|
15
+ treatment_max += treatment.weight
16
+ return treatment if assignment < treatment_max
17
+ end
18
+ end
19
+
20
+ protected
21
+
22
+ def cumulative_weights
23
+ treatments.map(&:weight).sum
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ module Rigor
2
+ class Treatment
3
+ def initialize(name, weight = 1)
4
+ @name = name
5
+ @weight = weight
6
+ end
7
+
8
+ attr_reader :name
9
+ attr_reader :weight
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Rigor
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rigor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Paul Rosania
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rack
16
+ requirement: &70241388456780 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '1.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70241388456780
25
+ - !ruby/object:Gem::Dependency
26
+ name: redis
27
+ requirement: &70241388456160 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '2.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70241388456160
36
+ - !ruby/object:Gem::Dependency
37
+ name: rails
38
+ requirement: &70241388454980 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '3.2'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70241388454980
47
+ - !ruby/object:Gem::Dependency
48
+ name: sqlite3
49
+ requirement: &70241388453820 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70241388453820
58
+ description: ''
59
+ email: paul.rosania@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - CHANGELOG.md
65
+ - README.rdoc
66
+ - MIT-LICENSE
67
+ - lib/rigor/rails.rb
68
+ - lib/rigor/test.rb
69
+ - lib/rigor/treatment.rb
70
+ - lib/rigor/version.rb
71
+ - lib/rigor.rb
72
+ homepage: http://github.com/paulrosania/rigor
73
+ licenses:
74
+ - MIT
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: 1.9.2
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 1.8.11
94
+ signing_key:
95
+ specification_version: 3
96
+ summary: A rigorous A/B testing framework.
97
+ test_files: []