feature 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.1 (2012-03-20)
2
+
3
+ * bugfix: occured when having empty feature set using yaml config (benjaminoakes)
4
+
1
5
  ## 0.4.0 (2011-11-28)
2
6
 
3
7
  * simplify repositories, they only have to respond to method active_features
data/README.md CHANGED
@@ -13,7 +13,9 @@ With this approach Feature is higly configurable and not bound to a specific kin
13
13
 
14
14
  gem install feature
15
15
 
16
- ## Example usage
16
+ ## Examples
17
+
18
+ ### Vanilla Ruby
17
19
 
18
20
  require 'feature'
19
21
 
@@ -28,3 +30,22 @@ With this approach Feature is higly configurable and not bound to a specific kin
28
30
  Feature.with(:be_nice) do
29
31
  puts "you can read this"
30
32
  end
33
+
34
+ ### Rails
35
+
36
+ # File: Gemfile
37
+ gem 'feature' # Or with version specifier, e.g. '~> 0.4.0'
38
+
39
+ # File: config/feature.yml
40
+ features:
41
+ an_active_feature: true
42
+ an_inactive_feature: false
43
+
44
+ # File: config/initializers/feature.rb
45
+ repo = Feature::Repository::YamlRepository.new("#{Rails.root}/config/feature.yml")
46
+ Feature.set_repository repo
47
+
48
+ # File: app/views/example/index.html.erb
49
+ <% if Feature.active?(:an_active_feature) %>
50
+ <%# Feature implementation goes here %>
51
+ <% end %>
@@ -40,12 +40,16 @@ module Feature
40
40
  raise ArgumentError, "content of #{@yaml_file_name} does not contain proper config"
41
41
  end
42
42
 
43
- invalid_value = data['features'].values.detect { |value| ![true, false].include?(value) }
44
- if invalid_value
45
- raise ArgumentError, "#{invalid_value} is not allowed value in config, use true/false"
46
- end
43
+ if data['features']
44
+ invalid_value = data['features'].values.detect { |value| ![true, false].include?(value) }
45
+ if invalid_value
46
+ raise ArgumentError, "#{invalid_value} is not allowed value in config, use true/false"
47
+ end
47
48
 
48
- data['features']
49
+ data['features']
50
+ else
51
+ {}
52
+ end
49
53
  end
50
54
  private :read_and_parse_file_data
51
55
  end
@@ -43,6 +43,21 @@ EOF
43
43
  @repo.active_features.should == [:feature_a_active]
44
44
  end
45
45
  end
46
+
47
+ # For example, when all your features are in production and working fine.
48
+ context "with no features" do
49
+ before(:each) do
50
+ fp = File.new(@filename, 'w')
51
+ fp.write <<"EOF";
52
+ features:
53
+ EOF
54
+ fp.close
55
+ end
56
+
57
+ it "should read active features new on each request" do
58
+ @repo.active_features.should == []
59
+ end
60
+ end
46
61
  end
47
62
 
48
63
  it "should raise exception on no file found" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feature
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 0
10
- version: 0.4.0
9
+ - 1
10
+ version: 0.4.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Markus Gerdes
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-28 00:00:00 +01:00
19
- default_executable:
18
+ date: 2012-03-20 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description:
@@ -28,19 +27,18 @@ extensions: []
28
27
  extra_rdoc_files: []
29
28
 
30
29
  files:
30
+ - lib/feature.rb
31
31
  - lib/feature/repository/simple_repository.rb
32
32
  - lib/feature/repository/yaml_repository.rb
33
33
  - lib/feature/repository.rb
34
- - lib/feature.rb
35
- - spec/feature/feature_spec.rb
36
34
  - spec/feature/simple_repository_spec.rb
37
35
  - spec/feature/yaml_repository_spec.rb
36
+ - spec/feature/feature_spec.rb
38
37
  - spec/spec_helper.rb
39
38
  - Rakefile
40
39
  - Gemfile
41
40
  - README.md
42
41
  - CHANGELOG.md
43
- has_rdoc: true
44
42
  homepage: http://github.com/mgsnova/feature
45
43
  licenses: []
46
44
 
@@ -70,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
68
  requirements: []
71
69
 
72
70
  rubyforge_project:
73
- rubygems_version: 1.6.2
71
+ rubygems_version: 1.8.15
74
72
  signing_key:
75
73
  specification_version: 3
76
74
  summary: Feature Toggle library for ruby