experiment_light 0.1.0 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2a9dd106ddd9ad492edc39ae8cbdf46d5feec78
4
- data.tar.gz: 339337336df9e307094cf0f1283f1f6a662a285d
3
+ metadata.gz: 2e46f730bc84ca401359ce193ffb06b539b013de
4
+ data.tar.gz: 62f675859403c020698c4db0db056a0c211a8b07
5
5
  SHA512:
6
- metadata.gz: 1f9ab1e2562b9b6095f65cd76f67c23df965b7795360f46017bf688a7680e38337c1a7b359b6a7a8da91f117600cae3e08aa818185af423d8874fff67cc9c962
7
- data.tar.gz: 1345ebff04f930025158e9f093104bb85ef86badddb027617e5bc92eee5e50189ebd615b959a6cd7592e110ecb3c76173fe911e154e3266327fe382d8b97a8dd
6
+ metadata.gz: e1a1395399d93afffd9aa79b92c31941132b686c9abac3cb71461a63206c9929b3b9beb74afd59aa1ed8fb9e2b32cfb814f9bbece8908692a429938a1e08257b
7
+ data.tar.gz: 747ef726a4ce0dfe7c210f8e23c6d796ecfc3a67da425ee88522598f9623da6a304187e9914a6401eda8481f2c88109c0c8a169499c9688b0d8b9e94e4f31557
data/README.md CHANGED
@@ -36,13 +36,45 @@ A yaml file named `experiment.yml` will be added into `config/` after running in
36
36
  test: true
37
37
  production: false
38
38
 
39
- Now you can use it in your views like this:
39
+ Now you can use it in models like this:
40
40
 
41
- <% if ExperimentLight::Experiment.on?(:foo) %>
41
+ class TestModel < ActiveRecord::Base
42
+ ...
43
+
44
+ if experiment_on?(:foo)
45
+ def foo_method
46
+ ...
47
+ end
48
+ end
49
+
50
+ ...
51
+ end
52
+
53
+ In controllers like this:
54
+
55
+ class TestController < ApplicationController
56
+ ...
57
+
58
+ def index
59
+ ...
60
+
61
+ if experiment_on?(:foo)
62
+ redirect_to :back
63
+ end
64
+
65
+ ...
66
+ end
67
+
68
+ ...
69
+ end
70
+
71
+ And in views like this:
72
+
73
+ <% if experiment_on?(:foo) %>
42
74
  <p>Experiment foo is on</p>
43
75
  <% end %>
44
76
 
45
- <% if ExperimentLight::Experiment.off?(:bar) %>
77
+ <% if experiment_off?(:bar) %>
46
78
  <p>Experiment bar is off</p>
47
79
  <% end %>
48
80
 
@@ -3,3 +3,5 @@ end
3
3
 
4
4
  require 'experiment_light/experiment'
5
5
  require 'experiment_light/version'
6
+ require 'experiment_light/action_controller/base'
7
+ require 'experiment_light/active_record/base'
@@ -0,0 +1,16 @@
1
+ require 'action_controller'
2
+
3
+ module ExperimentLight
4
+ class ActionController::Base
5
+
6
+ def experiment_on?(experiment_name)
7
+ ExperimentLight::Experiment.on?(experiment_name)
8
+ end
9
+
10
+ def experiment_off?(experiment_name)
11
+ !experiment_on?(experiment_name)
12
+ end
13
+
14
+ helper_method :experiment_on?, :experiment_off?
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ require 'active_record'
2
+
3
+ module ExperimentLight
4
+ class ActiveRecord::Base
5
+
6
+ class << self
7
+ def experiment_on?(experiment_name)
8
+ ExperimentLight::Experiment.on?(experiment_name)
9
+ end
10
+
11
+ def experiment_off?(experiment_name)
12
+ !experiment_on?(experiment_name)
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -1,3 +1,3 @@
1
1
  module ExperimentLight
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: experiment_light
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sen-Zhang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-01 00:00:00.000000000 Z
11
+ date: 2015-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,8 @@ files:
52
52
  - Rakefile
53
53
  - experiment_light.gemspec
54
54
  - lib/experiment_light.rb
55
+ - lib/experiment_light/action_controller/base.rb
56
+ - lib/experiment_light/active_record/base.rb
55
57
  - lib/experiment_light/experiment.rb
56
58
  - lib/experiment_light/version.rb
57
59
  - lib/generators/experiment_light/install_generator.rb