feature_toggle 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -0,0 +1,2 @@
1
+ 0.0.2 print warnings when feature not exists
2
+ 0.0.1 first version for toggling features
data/Rakefile CHANGED
@@ -0,0 +1,10 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.test_files = FileList['test/*test.rb']
7
+ t.verbose = true
8
+ end
9
+
10
+ task :default => :test
@@ -13,15 +13,13 @@ module FeatureToggle
13
13
 
14
14
  def activate(*feature_names)
15
15
  feature_names.each do |feature_name|
16
- validate!(feature_name)
17
- @deactivated_features.delete(feature_name)
16
+ @deactivated_features.delete(feature_name) if valid?(feature_name)
18
17
  end
19
18
  end
20
19
 
21
20
  def deactivate(*feature_names)
22
21
  feature_names.each do |feature_name|
23
- validate!(feature_name)
24
- @deactivated_features << feature_name
22
+ @deactivated_features << feature_name if valid?(feature_name)
25
23
  end
26
24
  end
27
25
 
@@ -35,9 +33,13 @@ module FeatureToggle
35
33
  end
36
34
 
37
35
  private
38
- def validate!(feature_name)
39
- raise UnknownFeatureError, "Unknown feature name: #{feature_name}" unless @features.has_key?(feature_name)
36
+
37
+ def valid?(feature_name)
38
+ @features.has_key?(feature_name).tap do |exists|
39
+ puts "Unknown feature: #{feature_name}" unless exists
40
+ end
40
41
  end
42
+
41
43
  def build_actions_feature_map(features)
42
44
  map = {}
43
45
  features.each do |feature, controllers|
@@ -50,4 +52,4 @@ module FeatureToggle
50
52
  map
51
53
  end
52
54
  end
53
- end
55
+ end
@@ -27,18 +27,10 @@ class FeatureToggleTest < Test::Unit::TestCase
27
27
  assert features.active?('user_profile')
28
28
  end
29
29
 
30
- def test_disabling_non_existent_features_should_raise_error
30
+ def test_disabling_non_existent_features_should_be_ignored
31
31
  features = load_features
32
- assert_raises FeatureToggle::UnknownFeatureError do
33
- features.deactivate("user")
34
- end
35
- end
36
-
37
- def test_activating_non_existent_features_should_raise_error
38
- features = load_features
39
- assert_raises FeatureToggle::UnknownFeatureError do
40
- features.activate("user")
41
- end
32
+ features.deactivate("user_profile_x")
33
+ assert features.active?('user_profile')
42
34
  end
43
35
 
44
36
  def test_feature_actions_should_be_active_when_feature_is_active
@@ -57,4 +49,4 @@ class FeatureToggleTest < Test::Unit::TestCase
57
49
  config = File.join(File.dirname(__FILE__), 'features.yml')
58
50
  FeatureToggle.load(config)
59
51
  end
60
- end
52
+ end
metadata CHANGED
@@ -1,32 +1,22 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: feature_toggle
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Mingle SaaS team
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-07-31 00:00:00 Z
12
+ date: 2012-09-15 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description:
22
15
  email: mingle.saas@thoughtworks.com
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
18
  extra_rdoc_files: []
28
-
29
- files:
19
+ files:
30
20
  - lib/feature_toggle/features.rb
31
21
  - lib/feature_toggle.rb
32
22
  - test/feature_toggle_test.rb
@@ -36,36 +26,26 @@ files:
36
26
  - CHANGELOG.md
37
27
  homepage: https://github.com/ThoughtWorksStudios/feature_toggle
38
28
  licenses: []
39
-
40
29
  post_install_message:
41
30
  rdoc_options: []
42
-
43
- require_paths:
31
+ require_paths:
44
32
  - lib
45
- required_ruby_version: !ruby/object:Gem::Requirement
33
+ required_ruby_version: !ruby/object:Gem::Requirement
46
34
  none: false
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- hash: 3
51
- segments:
52
- - 0
53
- version: "0"
54
- required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
40
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
63
45
  requirements: []
64
-
65
46
  rubyforge_project:
66
47
  rubygems_version: 1.8.24
67
48
  signing_key:
68
49
  specification_version: 3
69
50
  summary: Feature Toggle library for ruby
70
51
  test_files: []
71
-