foggle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6ff58aa1e79057702fc9c3959c75b494bf1aa220
4
+ data.tar.gz: d8506ec6e1701e56610317ecac607896dd8f1807
5
+ SHA512:
6
+ metadata.gz: 72b536a785851d1f6616623607827d82bafe3a13289df29a739ea33539b04c840f199cd093b2352e22da39475aa05e63998cd4921fb8e5b11b4f0a29a686b338
7
+ data.tar.gz: 482886adf9ff3f9e37365f23de571c72e0b4b34ad50a5c20c4179f9dfdf391a89ab886d1415fb39bdd37a8ed0e5f2eb792646d4c4383b98456dafe03bdea71e1
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ Style/StringLiterals:
2
+ Description: Checks if uses of quotes match the configured preference.
3
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
4
+ Enabled: true
5
+ EnforcedStyle: double_quotes
6
+ SupportedStyles:
7
+ - single_quotes
8
+ - double_quotes
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.0
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at macklin@detroitlabs.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Macklin Underdown
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # Foggle
2
+
3
+ [![Build Status](https://travis-ci.org/macklinu/foggle.svg?branch=master)](https://travis-ci.org/macklinu/foggle)
4
+ [![Codecov](https://img.shields.io/codecov/c/github/macklinu/foggle.svg)](https://codecov.io/github/macklinu/foggle?branch=master)
5
+ [![Sponsor](https://img.shields.io/badge/Sponsor-Detroit%20Labs-000000.svg)](http://www.detroitlabs.com)
6
+
7
+ > Environment-based feature toggles for Rails
8
+
9
+ ## Get it.
10
+
11
+ Add this line to your application's `Gemfile`:
12
+
13
+ ```ruby
14
+ gem "foggle"
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install foggle
24
+
25
+ ## Do it.
26
+
27
+ Add a feature toggle to the environment. The naming convention is `FEATURE_{{NAME}}`, where `{{NAME}}` is the feature name you're working on.
28
+
29
+ Let's say you're working on __cool stuff__. :sunglasses:
30
+
31
+ ```
32
+ # add to the environment
33
+ FEATURE_COOL_STUFF=true
34
+ ```
35
+
36
+ In your views and controllers, you have access to the method that rules them all: `enabled?`.
37
+
38
+ ```erb
39
+ <% if enabled? :cool_stuff %>
40
+ <%= render "cool_stuff" %>
41
+ <% end %>
42
+ ```
43
+
44
+ This method just reads in the environment variable you've set. Returns `true` or `false`.
45
+
46
+ There are a couple ways to use `foggle`, depending on your preference.
47
+
48
+ `feature?` is an alias for `enabled?`.
49
+
50
+ ```ruby
51
+ enabled? :cool_stuff
52
+ feature? :cool_stuff
53
+ ```
54
+
55
+ These methods also take strings.
56
+
57
+ ```ruby
58
+ enabled? "cool_stuff"
59
+ enabled? "COOL_STUFF"
60
+ ```
61
+
62
+ Passing in a Symbol version of your feature name is recommended, only because it looks cool and Ruby-esque. Do you.
63
+
64
+ ## Why?
65
+
66
+ The team at [Current](https://www.hirecurrent.com) wanted a simple feature toggle system without having to integrate a larger feature toggle system into the codebase. Since we are already deploying to Heroku and could quickly modify environment variables across our environments, we thought we'd try this out.
67
+
68
+ ## Cool.
69
+
70
+ Totes.
71
+
72
+ ## Hack it.
73
+
74
+ ### Editing
75
+
76
+ ```sh
77
+ # install dependencies
78
+ $ bin/setup
79
+
80
+ # run Rubocop and tests
81
+ $ bundle exec rake spec
82
+ ```
83
+
84
+ ### Installation
85
+
86
+ Install Foggle locally
87
+
88
+ ```sh
89
+ $ bundle exec rake install
90
+ ```
91
+
92
+ Deploy Foggle
93
+
94
+ ```sh
95
+ # bump `foggle/version`
96
+ $ bundle exec rake release
97
+ ```
98
+
99
+ ## Make it.
100
+
101
+ Bug reports? Ideas? [Bring 'em](https://github.com/macklinu/foggle/issues). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
102
+
103
+ ## License
104
+
105
+ [MIT](http://opensource.org/licenses/MIT)
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "rubocop/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ RuboCop::RakeTask.new
8
+
9
+ task default: [:rubocop, :spec]
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "foggle"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/foggle.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "foggle/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "foggle"
8
+ spec.version = Foggle::VERSION
9
+ spec.authors = ["Macklin Underdown"]
10
+ spec.email = ["macklinu@gmail.com"]
11
+
12
+ spec.summary = "Environment-based feature toggle Ruby gem"
13
+ spec.homepage = "https://github.com/macklinu/foggle"
14
+ spec.license = "MIT"
15
+
16
+ # rubocop:disable Metrics/LineLength
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ # rubcop:enable Metrics/LineLength
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.11"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "rubocop", "~> 0.38"
27
+ spec.add_development_dependency "simplecov", "~> 0.11"
28
+ spec.add_development_dependency "codecov"
29
+ spec.add_development_dependency "climate_control"
30
+ spec.add_development_dependency "yard"
31
+ end
data/lib/foggle.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "foggle/version"
2
+ require "foggle/toggle"
3
+
4
+ # Environment-based feature toggles in Rails
5
+ module Foggle
6
+ end
7
+
8
+ require "foggle/railtie" if defined?(Rails::Railtie)
@@ -0,0 +1,15 @@
1
+ require "foggle/toggle"
2
+
3
+ module Foggle
4
+ # @!visibility private
5
+ class Railtie < Rails::Railtie
6
+ initializer "foggle" do
7
+ ActiveSupport.on_load :action_controller do
8
+ ActionController::Base.send :include, Foggle::Toggle
9
+ end
10
+ ActiveSupport.on_load :action_view do
11
+ ActionView::Base.send :include, Foggle::Toggle
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,46 @@
1
+ module Foggle
2
+ # Namespace for the feature toggle implementation.
3
+ module Toggle
4
+ # Checks if a feature is enabled.
5
+ #
6
+ # @example using a Symbol as a parameter
7
+ # # export FEATURE_COOL_STUFF=true
8
+ # enabled? :cool_stuff
9
+ # # => true
10
+ #
11
+ # # export FEATURE_COOL_STUFF=false
12
+ # enabled? :cool_stuff
13
+ # # => false
14
+ #
15
+ # @example using a String as a parameter
16
+ # # export FEATURE_COOL_STUFF=true
17
+ # enabled? "cool_stuff"
18
+ # # => true
19
+ #
20
+ # # export FEATURE_COOL_STUFF=false
21
+ # enabled? "cool_stuff"
22
+ # # => false
23
+ #
24
+ # # export FEATURE_COOL_STUFF=true
25
+ # enabled? "COOL_STUFF"
26
+ # # => true
27
+ #
28
+ # @example using the +feature?+ alias method
29
+ # # export FEATURE_COOL_STUFF=true
30
+ # feature? :cool_stuff
31
+ # # => true
32
+ #
33
+ # # export FEATURE_COOL_STUFF=false
34
+ # feature? :cool_stuff
35
+ # # => false
36
+ #
37
+ # @param [Symbol, String] feature the snake_case +NAME+ of a feature used
38
+ # in a +FEATURE_NAME+ environment variable.
39
+ # @return [Boolean] if a feature is enabled.
40
+ def enabled?(feature)
41
+ feature_name = "FEATURE_#{feature.to_s.upcase}"
42
+ "true" == ENV.fetch(feature_name) { "false" }
43
+ end
44
+ alias feature? enabled?
45
+ end
46
+ end
@@ -0,0 +1,4 @@
1
+ module Foggle
2
+ # The current version of Foggle.
3
+ VERSION = "0.1.0".freeze
4
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foggle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Macklin Underdown
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.38'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.38'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.11'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.11'
83
+ - !ruby/object:Gem::Dependency
84
+ name: codecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: climate_control
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description:
126
+ email:
127
+ - macklinu@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".rubocop.yml"
135
+ - ".ruby-version"
136
+ - ".travis.yml"
137
+ - CODE_OF_CONDUCT.md
138
+ - Gemfile
139
+ - LICENSE.txt
140
+ - README.md
141
+ - Rakefile
142
+ - bin/console
143
+ - bin/setup
144
+ - foggle.gemspec
145
+ - lib/foggle.rb
146
+ - lib/foggle/railtie.rb
147
+ - lib/foggle/toggle.rb
148
+ - lib/foggle/version.rb
149
+ homepage: https://github.com/macklinu/foggle
150
+ licenses:
151
+ - MIT
152
+ metadata: {}
153
+ post_install_message:
154
+ rdoc_options: []
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 2.5.1
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: Environment-based feature toggle Ruby gem
173
+ test_files: []
174
+ has_rdoc: