feature 0.3.0 → 0.4.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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.0 (2011-11-28)
2
+
3
+ * simplify repositories, they only have to respond to method active_features
4
+
1
5
  ## 0.3.0 (2011-11-23)
2
6
 
3
7
  * assume all features as inactive that are not active, also unknown ones
@@ -3,7 +3,7 @@ module Feature
3
3
  # SimpleRepository for active feature list
4
4
  # Simply add features to that should be active, no config or data sources required
5
5
  #
6
- class SimpleRepository < AbstractRepository
6
+ class SimpleRepository
7
7
  # Constructor
8
8
  #
9
9
  def initialize
@@ -7,7 +7,7 @@ module Feature
7
7
  # an_active_feature: true
8
8
  # an_inactive_feature: false
9
9
  #
10
- class YamlRepository < AbstractRepository
10
+ class YamlRepository
11
11
  require 'yaml'
12
12
 
13
13
  # Constructor
@@ -1,7 +1,6 @@
1
1
  module Feature
2
2
  # Module for holding feature repositories
3
3
  module Repository
4
- require 'feature/repository/abstract_repository'
5
4
  require 'feature/repository/simple_repository'
6
5
  require 'feature/repository/yaml_repository'
7
6
  end
data/lib/feature.rb CHANGED
@@ -13,12 +13,13 @@ module Feature
13
13
  @active_features = nil
14
14
 
15
15
  # Set the feature repository
16
+ # The given repository has to respond to method 'active_features' with an array of symbols
16
17
  #
17
- # @param [Feature::Repository::AbstractRepository] repository the repository to get the features from
18
+ # @param [Object] repository the repository to get the features from
18
19
  #
19
20
  def self.set_repository(repository)
20
- if !repository.is_a?(Feature::Repository::AbstractRepository)
21
- raise ArgumentError, "given argument is not a repository"
21
+ if !repository.respond_to?(:active_features)
22
+ raise ArgumentError, "given repository does not respond to active_features"
22
23
  end
23
24
 
24
25
  @repository = repository
@@ -38,7 +38,7 @@ describe Feature do
38
38
  it "should raise an exception when add repository with wrong class" do
39
39
  lambda do
40
40
  Feature.set_repository("not a repository")
41
- end.should raise_error(ArgumentError, "given argument is not a repository")
41
+ end.should raise_error(ArgumentError, "given repository does not respond to active_features")
42
42
  end
43
43
 
44
44
  it "should set a feature repository" 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: 19
5
- prerelease: false
4
+ hash: 15
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 3
8
+ - 4
9
9
  - 0
10
- version: 0.3.0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Markus Gerdes
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-23 00:00:00 +01:00
18
+ date: 2011-11-28 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -28,15 +28,13 @@ extensions: []
28
28
  extra_rdoc_files: []
29
29
 
30
30
  files:
31
- - lib/feature.rb
32
31
  - lib/feature/repository/simple_repository.rb
33
- - lib/feature/repository/abstract_repository.rb
34
32
  - lib/feature/repository/yaml_repository.rb
35
33
  - lib/feature/repository.rb
34
+ - lib/feature.rb
35
+ - spec/feature/feature_spec.rb
36
36
  - spec/feature/simple_repository_spec.rb
37
37
  - spec/feature/yaml_repository_spec.rb
38
- - spec/feature/abstract_repository_spec.rb
39
- - spec/feature/feature_spec.rb
40
38
  - spec/spec_helper.rb
41
39
  - Rakefile
42
40
  - Gemfile
@@ -72,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
70
  requirements: []
73
71
 
74
72
  rubyforge_project:
75
- rubygems_version: 1.3.7
73
+ rubygems_version: 1.6.2
76
74
  signing_key:
77
75
  specification_version: 3
78
76
  summary: Feature Toggle library for ruby
@@ -1,24 +0,0 @@
1
- module Feature
2
- module Repository
3
- # Abstract class for subclassing and building repository classes which
4
- # provide lists of active features
5
- #
6
- class AbstractRepository
7
- # Constructor
8
- #
9
- # Should be overridden in derived class to initialize repository with all data needed
10
- #
11
- def initialize
12
- raise "abstract class #{self.class.name}!"
13
- end
14
-
15
- # Returns list of active features
16
- #
17
- # @return [Array<Symbol>] list of active features
18
- #
19
- def active_features
20
- raise "#{__method__} has to be overridden in derived class"
21
- end
22
- end
23
- end
24
- end
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Feature::Repository::AbstractRepository do
4
- it "should raise error on creating a new instance" do
5
- lambda do
6
- Feature::Repository::AbstractRepository.new
7
- end.should raise_error("abstract class Feature::Repository::AbstractRepository!")
8
- end
9
- end