arturo 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -12
- data/app/controllers/arturo/features_controller.rb +1 -9
- data/app/models/arturo/feature.rb +2 -3
- data/lib/arturo/test_support.rb +30 -0
- metadata +4 -3
data/README.md
CHANGED
@@ -74,19 +74,11 @@ feature and deploy it to all users.
|
|
74
74
|
|
75
75
|
$ gem install arturo --version="~> 1.0"
|
76
76
|
|
77
|
-
|
78
|
-
Arturo with Rails 2. Arturo does not yet have Rails 2 support.
|
77
|
+
### In Rails 2.3
|
79
78
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
:tag => 'rails_2_3'
|
84
|
-
|
85
|
-
### In Rails 2, without Bundler
|
86
|
-
|
87
|
-
Put the `rails_2_3` branch of `git://github.com/jamesarosen/arturo.git` into
|
88
|
-
your `vendor/plugins/` directory. You can use Git submodules or a simple
|
89
|
-
checkout.
|
79
|
+
For Rails 2.3 support, see the
|
80
|
+
[`rails_2_3` branch](http://github.com/jamesarosen/arturo/tree/rails_2_3)
|
81
|
+
of Arturo.
|
90
82
|
|
91
83
|
## Configuration
|
92
84
|
|
@@ -103,6 +95,8 @@ checkout.
|
|
103
95
|
|
104
96
|
$ rake db:migrate
|
105
97
|
|
98
|
+
#### Edit the generated migration as necessary
|
99
|
+
|
106
100
|
#### Edit the configuration
|
107
101
|
|
108
102
|
##### Initializer
|
@@ -5,18 +5,10 @@ require 'action_controller'
|
|
5
5
|
# to clean it up a bit?
|
6
6
|
module Arturo
|
7
7
|
|
8
|
-
begin
|
9
|
-
require 'application_controller'
|
10
|
-
rescue LoadError
|
11
|
-
# do nothing
|
12
|
-
end
|
13
|
-
|
14
|
-
base = Object.const_defined?(:ApplicationController) ? ApplicationController : ActionController::Base
|
15
|
-
|
16
8
|
# Handles all Feature actions. Clients of the Arturo engine
|
17
9
|
# should redefine Arturo::FeaturesController#permitted? to
|
18
10
|
# return true only for users who are permitted to manage features.
|
19
|
-
class FeaturesController <
|
11
|
+
class FeaturesController < ApplicationController
|
20
12
|
include Arturo::FeatureManagement
|
21
13
|
|
22
14
|
unloadable
|
@@ -8,7 +8,7 @@ module Arturo
|
|
8
8
|
include Arturo::SpecialHandling
|
9
9
|
|
10
10
|
Arturo::Feature::SYMBOL_REGEX = /^[a-zA-z][a-zA-Z0-9_]*$/
|
11
|
-
DEFAULT_ATTRIBUTES = { :deployment_percentage => 0 }
|
11
|
+
DEFAULT_ATTRIBUTES = { :deployment_percentage => 0 }.with_indifferent_access
|
12
12
|
|
13
13
|
attr_readonly :symbol
|
14
14
|
|
@@ -69,8 +69,7 @@ module Arturo
|
|
69
69
|
threshold = self.deployment_percentage || 0
|
70
70
|
return false if threshold == 0
|
71
71
|
return true if threshold == 100
|
72
|
-
(((feature_recipient.id + 17) * 13) % 100) < threshold
|
73
|
-
|
72
|
+
(((feature_recipient.id + (self.id || 1) + 17) * 13) % 100) < threshold
|
74
73
|
end
|
75
74
|
end
|
76
75
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Arturo.class_eval do
|
2
|
+
|
3
|
+
# Enable a feature; create it if necessary.
|
4
|
+
# For use in testing. Not auto-required on load. To load,
|
5
|
+
#
|
6
|
+
# require 'arturo/test_support'
|
7
|
+
#
|
8
|
+
# @param [Symbol, String] name the feature name
|
9
|
+
def enable_feature!(name)
|
10
|
+
feature = Arturo::Feature.find_by_symbol(name)
|
11
|
+
if feature
|
12
|
+
feature.update_attributes(:deployment_percentage => 100)
|
13
|
+
else
|
14
|
+
Arturo::Feature.create(:symbol => name, :deployment_percentage => 100)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Disable a feature if it exists.
|
19
|
+
# For use in testing. Not auto-required on load. To load,
|
20
|
+
#
|
21
|
+
# require 'arturo/test_support'
|
22
|
+
#
|
23
|
+
# @param [Symbol, String] name the feature name
|
24
|
+
def disable_feature!(name)
|
25
|
+
if (feature = Arturo::Feature.find_by_symbol(name))
|
26
|
+
feature.update_attributes(:deployment_percentage => 0)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 2
|
9
|
+
version: 1.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- James A. Rosen
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-04 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/arturo/feature_factories.rb
|
115
115
|
- lib/arturo/feature_management.rb
|
116
116
|
- lib/arturo/special_handling.rb
|
117
|
+
- lib/arturo/test_support.rb
|
117
118
|
- lib/arturo.rb
|
118
119
|
- lib/generators/arturo/assets_generator.rb
|
119
120
|
- lib/generators/arturo/initializer_generator.rb
|