feature_flag 0.0.1

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/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create ruby-1.9.3-p392@feature_flag
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in feature_flag.gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
7
+ gem 'rspec'
data/Gemfile.lock ADDED
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ feature_flag (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.4)
10
+ rake (10.0.4)
11
+ rspec (2.13.0)
12
+ rspec-core (~> 2.13.0)
13
+ rspec-expectations (~> 2.13.0)
14
+ rspec-mocks (~> 2.13.0)
15
+ rspec-core (2.13.1)
16
+ rspec-expectations (2.13.0)
17
+ diff-lcs (>= 1.1.3, < 2.0)
18
+ rspec-mocks (2.13.1)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ bundler (~> 1.3)
25
+ feature_flag!
26
+ rake
27
+ rspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tyler Mercier
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # FeatureFlag
2
+
3
+ Ruby gem for tying feature flags to environment variables
4
+
5
+ ## Build Status
6
+ [![Build Status](https://secure.travis-ci.org/tylermercier/feature_flag.png)](http://travis-ci.org/tylermercier/feature_flag)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'feature_flag'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install feature_flag
21
+
22
+ ## Usage
23
+
24
+ Doing trunk based development? Want to continuously release to production? Try feature_flag
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler"
2
+ require "bundler/gem_tasks"
3
+ Bundler.setup
4
+
5
+ require "rspec/core/rake_task"
6
+
7
+ RSpec::Core::RakeTask.new("spec") do |spec|
8
+ spec.pattern = "spec/**/*_spec.rb"
9
+ end
10
+
11
+ task :default => :spec
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'feature_flag/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "feature_flag"
8
+ spec.version = FeatureFlag::VERSION
9
+ spec.authors = ["Tyler Mercier"]
10
+ spec.email = ["tylermercier@gmail.com"]
11
+ spec.description = %q{Ruby gem for tying feature flags to environment variables}
12
+ spec.summary = %q{Ruby gem for tying feature flags to environment variables}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,8 @@
1
+ require "feature_flag/version"
2
+ require "feature_flag/lookup"
3
+
4
+ module FeatureFlag
5
+ def self.const_missing(name)
6
+ Lookup.check_flag name.to_s
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ class Lookup
2
+ def self.check_flag(key)
3
+ return false if ENV[key].nil? || ENV[key].empty?
4
+ enabled(ENV[key])
5
+ end
6
+
7
+ def self.enabled(value)
8
+ return true if value =~ (/(true|t|yes|y|enabled|1)$/i)
9
+ false
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module FeatureFlag
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe FeatureFlag do
4
+
5
+ context 'feature flag enabled' do
6
+ before :each do
7
+ ENV["FEATURE"] = "true"
8
+ end
9
+
10
+ it { FeatureFlag::FEATURE.should be_true }
11
+ end
12
+
13
+ context 'feature flag disabled' do
14
+ before :each do
15
+ ENV["FEATURE"] = "false"
16
+ end
17
+
18
+ it { FeatureFlag::FEATURE.should be_false }
19
+ end
20
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lookup do
4
+ context '#check_flag' do
5
+ it 'should return true when ENV variable enabled' do
6
+ ENV["FEATURE"] = "true"
7
+ Lookup.check_flag('FEATURE').should be_true
8
+ end
9
+
10
+ it 'should return false when no ENV variable found' do
11
+ Lookup.check_flag('xxMISINGxx').should be_false
12
+ end
13
+
14
+ it 'should return false when ENV variable empty' do
15
+ ENV["FEATURE"] = ""
16
+ Lookup.check_flag('FEATURE').should be_false
17
+ end
18
+
19
+ it 'should return false when ENV variable nil' do
20
+ ENV["FEATURE"] = nil
21
+ Lookup.check_flag('FEATURE').should be_false
22
+ end
23
+ end
24
+
25
+ context '#enabled' do
26
+ it 'should match true values' do
27
+ %w(true t yes y enabled 1).each do |value|
28
+ Lookup.enabled(value).should == true
29
+ end
30
+ end
31
+
32
+ it 'should match false values' do
33
+ %w(false f no n disabled 0).each do |value|
34
+ Lookup.enabled(value).should == false
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,2 @@
1
+ SPEC_ROOT = Pathname(__FILE__).dirname.expand_path
2
+ require SPEC_ROOT.parent + 'lib/feature_flag'
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: feature_flag
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tyler Mercier
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-05-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Ruby gem for tying feature flags to environment variables
47
+ email:
48
+ - tylermercier@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .rspec
54
+ - .rvmrc
55
+ - .travis.yml
56
+ - Gemfile
57
+ - Gemfile.lock
58
+ - LICENSE.txt
59
+ - README.md
60
+ - Rakefile
61
+ - feature_flag.gemspec
62
+ - lib/feature_flag.rb
63
+ - lib/feature_flag/lookup.rb
64
+ - lib/feature_flag/version.rb
65
+ - spec/feature_flag/feature_flag_spec.rb
66
+ - spec/feature_flag/lookup_spec.rb
67
+ - spec/spec_helper.rb
68
+ homepage: ''
69
+ licenses:
70
+ - MIT
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ segments:
82
+ - 0
83
+ hash: 66192937362483026
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ segments:
91
+ - 0
92
+ hash: 66192937362483026
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 1.8.25
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: Ruby gem for tying feature flags to environment variables
99
+ test_files:
100
+ - spec/feature_flag/feature_flag_spec.rb
101
+ - spec/feature_flag/lookup_spec.rb
102
+ - spec/spec_helper.rb