abtest 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/abtest.rb +2 -0
- data/lib/abtest/filters.rb +13 -0
- data/lib/abtest/processor.rb +5 -3
- data/lib/abtest/railtie.rb +3 -4
- data/lib/abtest/registry.rb +8 -3
- data/lib/abtest/version.rb +1 -1
- metadata +5 -4
data/lib/abtest.rb
CHANGED
data/lib/abtest/processor.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
1
3
|
module Abtest
|
2
4
|
class Processor
|
3
|
-
def self.process_tests
|
5
|
+
def self.process_tests controller
|
4
6
|
Abtest.abtest_config.registered_tests.each do |test_hash|
|
5
|
-
if (test_hash[:check])
|
6
|
-
prepend_view_path(test_hash[:prefix])
|
7
|
+
if (test_hash[:check].call(controller.request))
|
8
|
+
controller.prepend_view_path(test_hash[:prefix])
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
data/lib/abtest/railtie.rb
CHANGED
@@ -7,10 +7,9 @@ module Abtest
|
|
7
7
|
config.abtest.registered_tests = Set.new
|
8
8
|
end
|
9
9
|
|
10
|
-
initializer "abtest.set_filter"
|
11
|
-
|
12
|
-
include Abtest
|
13
|
-
append_before_filter Abtest::Processor.process_tests
|
10
|
+
initializer "abtest.set_filter" do
|
11
|
+
ActiveSupport.on_load(:action_controller) do
|
12
|
+
ActionController::Base.send(:include, Abtest::Filters)
|
14
13
|
end
|
15
14
|
end
|
16
15
|
end
|
data/lib/abtest/registry.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
+
require "rails"
|
2
|
+
|
1
3
|
module Abtest
|
2
4
|
# Register a test. This method takes the view prefix of the directory
|
3
5
|
# where your view overrides are located (most often the gem name) and a lambda
|
4
6
|
# that will be used to determine whether or not to enable your test. The provided
|
5
|
-
# lambda must return a truthy value for the test to be activated
|
6
|
-
def self.register_test
|
7
|
-
|
7
|
+
# lambda must return a truthy value for the test to be activated and accept a request object
|
8
|
+
def self.register_test test_engine, lamb
|
9
|
+
# Remove the default view path
|
10
|
+
view_path = "#{test_engine.root}/app/views"
|
11
|
+
ActionController::Base.view_paths = ActionController::Base.view_paths.reject {|path| path.to_path == view_path }
|
12
|
+
abtest_config.registered_tests.add({prefix: view_path, check: lamb})
|
8
13
|
end
|
9
14
|
|
10
15
|
def self.abtest_config
|
data/lib/abtest/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abtest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- Rakefile
|
59
59
|
- abtest.gemspec
|
60
60
|
- lib/abtest.rb
|
61
|
+
- lib/abtest/filters.rb
|
61
62
|
- lib/abtest/processor.rb
|
62
63
|
- lib/abtest/railtie.rb
|
63
64
|
- lib/abtest/registry.rb
|
@@ -77,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
78
|
version: '0'
|
78
79
|
segments:
|
79
80
|
- 0
|
80
|
-
hash:
|
81
|
+
hash: -3468350091403392005
|
81
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
83
|
none: false
|
83
84
|
requirements:
|
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
87
|
version: '0'
|
87
88
|
segments:
|
88
89
|
- 0
|
89
|
-
hash:
|
90
|
+
hash: -3468350091403392005
|
90
91
|
requirements: []
|
91
92
|
rubyforge_project:
|
92
93
|
rubygems_version: 1.8.25
|