feature-toggles 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NDA4YmFlNjI5ODllNWViMGM4MmNkZTE2YmJhZTkwNDMxNDMzZDUzYg==
5
+ data.tar.gz: !binary |-
6
+ M2U1Njc0MzZkNGE0ZWQ0MzliZTJhNmYwYjAyMzU3NjMyN2MzYmQzYw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NzU4MDEwYWZiZmIwZGFhNWMyZDhlY2ZhY2M1MDdhZjgzOThkNmM4ZDI4N2U3
10
+ OTllNDEwMzJlNjk2YzlmZGNjNDlkNmI2MjliNDk5ZjBjZWE2ZmY1MmY4NDU2
11
+ MjlhOWZiYjcyYzkxMDNkMDc3NmJkNWM1ZTg4YjU2ZTQ1OTNkY2I=
12
+ data.tar.gz: !binary |-
13
+ ZjJjN2U5MTRkODg5ZjYwNzY5NDY4ZjQ1MWYxMjI0YTdjYjNhNzBkZjY1OTRi
14
+ MGE2YzI1ZTc5YWNlNTE4MzExOWE4YWE2MjVhYTJlNjkzNWFlNTY5MGIyYzk5
15
+ MzU2MGNlZTE5MjYwZGQ5ZDA5MDRjOTVjNzJmNDE1OGI5MmVjMGY=
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,27 @@
1
+ = FeatureToggles
2
+
3
+ Toggle a feature on or off in an environment.
4
+
5
+ This gem is made to be used in Rails projects.
6
+
7
+ 1. In your config folder place a file named "feature_toggles.yml"
8
+ 2. Set features for various environments like so:
9
+ development:
10
+ my_cool_feature:
11
+ enabled: true
12
+
13
+ another_feature:
14
+ enabled: true
15
+ test:
16
+ my_cool_feature:
17
+ enabled: false
18
+
19
+ another_feature:
20
+ enabled: true
21
+ 3. require 'feature_toggles' #in application.rb
22
+ 4. Test if a feature is enabled like the following:
23
+ if FeatureToggles::Feature.is_enabled?(:my_cool_feature)
24
+ render 'my_new_feature' and return
25
+ end
26
+
27
+ And don't forget to delete your toggles if they're no longer needed ;)
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'FeatureToggles'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -0,0 +1,5 @@
1
+ require 'feature-toggles/loader'
2
+ require 'feature-toggles/feature'
3
+
4
+ module FeatureToggles
5
+ end
@@ -0,0 +1,17 @@
1
+ class FeatureToggles::Feature
2
+
3
+ def self.is_enabled?(feature_name)
4
+ feature_toggle_data[feature_name][:enabled]
5
+ end
6
+
7
+ private
8
+ def self.default_feature_toggles_file_name
9
+ 'feature_toggles.yml'
10
+ end
11
+
12
+ def self.feature_toggle_data
13
+ @loader ||= FeatureToggles::Loader.new(Rails.env)
14
+ @feature_toggle_data ||= @loader.load(default_feature_toggles_file_name)
15
+ end
16
+
17
+ end
@@ -0,0 +1,15 @@
1
+ class FeatureToggles::Loader
2
+
3
+ def initialize(env)
4
+ @env = env
5
+ end
6
+
7
+ def load(file_name)
8
+ @feature_toggle_data ||= begin
9
+ file_path = Rails.root.join("config", file_name)
10
+ toggle_settings = HashWithIndifferentAccess.new(YAML::load(File.open(file_path)))
11
+ toggle_settings[@env]
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,3 @@
1
+ module FeatureToggles
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :feature_toggles do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: feature-toggles
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Louis Sayers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-nav
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Turn features on or off in various rails environments
84
+ email:
85
+ - lssayers@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - lib/feature-toggles/feature.rb
91
+ - lib/feature-toggles/loader.rb
92
+ - lib/feature-toggles/version.rb
93
+ - lib/feature-toggles.rb
94
+ - lib/tasks/feature_toggles_tasks.rake
95
+ - MIT-LICENSE
96
+ - Rakefile
97
+ - README.rdoc
98
+ homepage: https://github.com/forward-labs/feature-toggles
99
+ licenses:
100
+ - MIT
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project:
118
+ rubygems_version: 2.0.7
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Feature Toggles for Rails
122
+ test_files: []