feature 0.4.1 → 0.5.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,9 @@
1
+ ## 0.5.0 (2012-09-29)
2
+
3
+ * added erb support for yaml feature config (dscataglini)
4
+ * fixed travis integration
5
+ * added code climate link
6
+
1
7
  ## 0.4.1 (2012-03-20)
2
8
 
3
9
  * bugfix: occured when having empty feature set using yaml config (benjaminoakes)
data/README.md CHANGED
@@ -8,6 +8,7 @@ With this approach Feature is higly configurable and not bound to a specific kin
8
8
  ## CI status
9
9
 
10
10
  [![Travis-CI Build Status](https://secure.travis-ci.org/mgsnova/feature.png)](https://secure.travis-ci.org/mgsnova/feature)
11
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/mgsnova/feature)
11
12
 
12
13
  ## Installation
13
14
 
@@ -8,6 +8,7 @@ module Feature
8
8
  # an_inactive_feature: false
9
9
  #
10
10
  class YamlRepository
11
+ require 'erb'
11
12
  require 'yaml'
12
13
 
13
14
  # Constructor
@@ -34,7 +35,8 @@ module Feature
34
35
  #
35
36
  def read_and_parse_file_data
36
37
  raw_data = File.read(@yaml_file_name)
37
- data = YAML.load(raw_data)
38
+ evaluated_data = ERB.new(raw_data).result
39
+ data = YAML.load(evaluated_data)
38
40
 
39
41
  if !data.is_a?(Hash) or !data.has_key?('features')
40
42
  raise ArgumentError, "content of #{@yaml_file_name} does not contain proper config"
@@ -58,6 +58,29 @@ EOF
58
58
  @repo.active_features.should == []
59
59
  end
60
60
  end
61
+
62
+ # Sometimes needed when loading features from ENV variables or are time
63
+ # based rules Ex: Date.today > Date.strptime('1/2/2012', '%d/%m/%Y')
64
+ context "a config file with embedded erb" do
65
+ before(:each) do
66
+ @filename = Tempfile.new(['feature_config', '.yaml']).path
67
+ fp = File.new(@filename, 'w')
68
+ fp.write <<"EOF";
69
+ features:
70
+ feature_a_active: <%= 'true' == 'true' %>
71
+ feature_b_active: true
72
+ feature_c_inactive: <%= false %>
73
+ feature_d_inactive: <%= 1 < 0 %>
74
+ EOF
75
+ fp.close
76
+
77
+ @repo = YamlRepository.new(@filename)
78
+ end
79
+
80
+ it "should read active features from the config file" do
81
+ @repo.active_features.should == [:feature_a_active, :feature_b_active]
82
+ end
83
+ end
61
84
  end
62
85
 
63
86
  it "should raise exception on no file found" do
metadata CHANGED
@@ -1,39 +1,29 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: feature
3
- version: !ruby/object:Gem::Version
4
- hash: 13
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 4
9
- - 1
10
- version: 0.4.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Markus Gerdes
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-03-20 00:00:00 Z
12
+ date: 2012-09-29 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
14
  description:
22
15
  email: github@mgsnova.de
23
16
  executables: []
24
-
25
17
  extensions: []
26
-
27
18
  extra_rdoc_files: []
28
-
29
- files:
30
- - lib/feature.rb
19
+ files:
31
20
  - lib/feature/repository/simple_repository.rb
32
21
  - lib/feature/repository/yaml_repository.rb
33
22
  - lib/feature/repository.rb
23
+ - lib/feature.rb
24
+ - spec/feature/feature_spec.rb
34
25
  - spec/feature/simple_repository_spec.rb
35
26
  - spec/feature/yaml_repository_spec.rb
36
- - spec/feature/feature_spec.rb
37
27
  - spec/spec_helper.rb
38
28
  - Rakefile
39
29
  - Gemfile
@@ -41,36 +31,26 @@ files:
41
31
  - CHANGELOG.md
42
32
  homepage: http://github.com/mgsnova/feature
43
33
  licenses: []
44
-
45
34
  post_install_message:
46
35
  rdoc_options: []
47
-
48
- require_paths:
36
+ require_paths:
49
37
  - lib
50
- required_ruby_version: !ruby/object:Gem::Requirement
38
+ required_ruby_version: !ruby/object:Gem::Requirement
51
39
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- hash: 3
56
- segments:
57
- - 0
58
- version: "0"
59
- required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
45
  none: false
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- hash: 3
65
- segments:
66
- - 0
67
- version: "0"
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
68
50
  requirements: []
69
-
70
51
  rubyforge_project:
71
- rubygems_version: 1.8.15
52
+ rubygems_version: 1.8.24
72
53
  signing_key:
73
54
  specification_version: 3
74
55
  summary: Feature Toggle library for ruby
75
56
  test_files: []
76
-