arturo 1.5.0 → 1.5.1
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.
- data/app/models/arturo/feature.rb +12 -3
- data/lib/arturo/feature_caching.rb +1 -1
- data/lib/arturo/test_support.rb +2 -3
- metadata +2 -2
@@ -10,7 +10,7 @@ module Arturo
|
|
10
10
|
Arturo::Feature::SYMBOL_REGEX = /^[a-zA-z][a-zA-Z0-9_]*$/
|
11
11
|
DEFAULT_ATTRIBUTES = { :deployment_percentage => 0 }.with_indifferent_access
|
12
12
|
|
13
|
-
attr_accessible :symbol, :deployment_percentage if
|
13
|
+
attr_accessible :symbol, :deployment_percentage if ActiveRecord::VERSION::MAJOR < 4
|
14
14
|
attr_readonly :symbol
|
15
15
|
|
16
16
|
validates_presence_of :symbol, :deployment_percentage
|
@@ -23,10 +23,19 @@ module Arturo
|
|
23
23
|
|
24
24
|
# Looks up a feature by symbol. Also accepts a Feature as input.
|
25
25
|
# @param [Symbol, Arturo::Feature] feature_or_name a Feature or the Symbol of a Feature
|
26
|
-
# @return [Arturo::Feature, nil] the Feature if found, else
|
26
|
+
# @return [Arturo::Feature, nil] the Feature if found, else Arturo::NoSuchFeature
|
27
27
|
def self.to_feature(feature_or_symbol)
|
28
28
|
return feature_or_symbol if feature_or_symbol.kind_of?(self)
|
29
|
-
|
29
|
+
symbol = feature_or_symbol.to_sym
|
30
|
+
self.where(:symbol => symbol).first || Arturo::NoSuchFeature.new(symbol)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Looks up a feature by symbol. Also accepts a Feature as input.
|
34
|
+
# @param [Symbol, Arturo::Feature] feature_or_name a Feature or the Symbol of a Feature
|
35
|
+
# @return [Arturo::Feature, nil] the Feature if found, else nil
|
36
|
+
def self.find_feature(feature_or_symbol)
|
37
|
+
feature = to_feature(feature_or_symbol)
|
38
|
+
feature.is_a?(Arturo::NoSuchFeature) ? nil : feature
|
30
39
|
end
|
31
40
|
|
32
41
|
# Create a new Feature
|
@@ -42,7 +42,7 @@ module Arturo
|
|
42
42
|
cached_feature
|
43
43
|
else
|
44
44
|
symbol = feature_or_symbol.to_sym
|
45
|
-
feature = to_feature_without_caching(symbol)
|
45
|
+
feature = to_feature_without_caching(symbol)
|
46
46
|
feature_cache.write(symbol, feature, :expires_in => cache_ttl)
|
47
47
|
feature
|
48
48
|
end
|
data/lib/arturo/test_support.rb
CHANGED
@@ -7,8 +7,7 @@ Arturo.instance_eval do
|
|
7
7
|
#
|
8
8
|
# @param [Symbol, String] name the feature name
|
9
9
|
def enable_feature!(name)
|
10
|
-
feature = Arturo::Feature.
|
11
|
-
if feature
|
10
|
+
if feature = Arturo::Feature.find_feature(name)
|
12
11
|
feature.update_attributes(:deployment_percentage => 100)
|
13
12
|
else
|
14
13
|
Arturo::Feature.create!(:symbol => name, :deployment_percentage => 100)
|
@@ -22,7 +21,7 @@ Arturo.instance_eval do
|
|
22
21
|
#
|
23
22
|
# @param [Symbol, String] name the feature name
|
24
23
|
def disable_feature!(name)
|
25
|
-
if
|
24
|
+
if feature = Arturo::Feature.find_feature(name)
|
26
25
|
feature.update_attributes(:deployment_percentage => 0)
|
27
26
|
end
|
28
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arturo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
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: 2013-04-
|
12
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|