-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add non-TravisCI changes to support multiple Rails versions
- Loading branch information
Showing
10 changed files
with
518 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
appraise "rails-3" do | ||
gem "rails", "3.2.22" | ||
end | ||
|
||
appraise "rails-4" do | ||
gem "rails", "4.2.4" | ||
end | ||
|
||
appraise "rails-5" do | ||
gem 'rails', github: 'rails/rails' | ||
gem 'rack', github: 'rack/rack' | ||
gem 'arel', github: 'rails/arel' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
= Setler | ||
|
||
Setler is a Gem that lets one easily implement the "Feature Flags" pattern, or add settings to individual models. This is a cleanroom implementation of what the 'rails-settings' gem does. It's been forked all over the place, and my favorite version of it doesn't have any tests and doesn't work with settings associated with models. | ||
|
||
{<img src="https://travis-ci.org/ckdake/setler.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/ckdake/setler] | ||
{<img src="https://badge.fury.io/rb/setler.svg" alt="Gem Version" />}[http://badge.fury.io/rb/setler] | ||
|
||
== Setup | ||
|
||
Install the gem by adding this to your Gemfile: | ||
|
||
gem "setler" | ||
|
||
Generate the model: | ||
|
||
rails g setler <model_name> | ||
|
||
Run the migration: | ||
|
||
rake db:migrate | ||
|
||
If you are using the `protected_attributes` gem you must add `attr_protected` to the top of you setler model. | ||
|
||
== Usage | ||
|
||
Create/Update settings: | ||
|
||
# Method calls and []= are synonymous | ||
Featureflags.bacon_dispenser_enabled = true | ||
Settings[:allowed_meats] = ['bacon', 'crunchy bacon'] | ||
|
||
Read settings: | ||
|
||
Featureflags.bacon_dispenser_enabled # true | ||
Settings[:allowed_meats].include?('bacon') # true | ||
|
||
Destroy them: | ||
|
||
Featureflags.destroy :bacon_dispenser_enabled | ||
Settings.destroy :allowed_meats | ||
|
||
List all settings: | ||
|
||
Featureflags.all_settings | ||
Settings.all_settings | ||
|
||
Set defaults in an initializer with something like: | ||
|
||
Featureflags.defaults[:bacon_dispenser_enabled] = false | ||
Settings.defaults[:allowed_meats] = ['itsnotbacon'] | ||
|
||
To revert to the default after changing a setting, destroy it. | ||
Note: Updating the setting to nil or false no longer makes it the default setting (> 0.0.6), but changes the setting to nil or false. | ||
|
||
Add them to any ActiveRecord object: | ||
|
||
class User < ActiveRecord::Base | ||
has_setler :settings | ||
end | ||
|
||
Then you get: | ||
|
||
user = User.first | ||
user.settings.favorite_meat = :bacon | ||
user.settings.favorite_meat # :bacon | ||
user.settings.all # { "favorite_meat" => :bacon } | ||
|
||
TODO: And look em up: | ||
|
||
User.with_settings_for('favorite_meat') # => scope of users with the favorite_meat setting | ||
|
||
== Gem Development | ||
|
||
Getting started is pretty straightforward: | ||
|
||
1. Check out the code: `git clone git://github.com/ckdake/setler.git` | ||
2. Bundle install: `bundle install` | ||
3. Run: `appraisal install` to generate the appraisal's gemfiles. | ||
4. Run the tests for all supported releases in Appraisals file and make sure they all pass and code coverage is still the same: `appraisal rake test` | ||
|
||
If you'd like to contribute code, make your changes and submit a pull request that includes appropriate tests | ||
|
||
For building the gem: `rake build` and to release a gem to github and Rubygems: `rake release` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "rails", "3.2.22" | ||
|
||
gemspec :path => "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
PATH | ||
remote: ../ | ||
specs: | ||
setler (0.0.13) | ||
activerecord (>= 3.0.0) | ||
rails (>= 3.0.0) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actionmailer (3.2.22) | ||
actionpack (= 3.2.22) | ||
mail (~> 2.5.4) | ||
actionpack (3.2.22) | ||
activemodel (= 3.2.22) | ||
activesupport (= 3.2.22) | ||
builder (~> 3.0.0) | ||
erubis (~> 2.7.0) | ||
journey (~> 1.0.4) | ||
rack (~> 1.4.5) | ||
rack-cache (~> 1.2) | ||
rack-test (~> 0.6.1) | ||
sprockets (~> 2.2.1) | ||
activemodel (3.2.22) | ||
activesupport (= 3.2.22) | ||
builder (~> 3.0.0) | ||
activerecord (3.2.22) | ||
activemodel (= 3.2.22) | ||
activesupport (= 3.2.22) | ||
arel (~> 3.0.2) | ||
tzinfo (~> 0.3.29) | ||
activeresource (3.2.22) | ||
activemodel (= 3.2.22) | ||
activesupport (= 3.2.22) | ||
activesupport (3.2.22) | ||
i18n (~> 0.6, >= 0.6.4) | ||
multi_json (~> 1.0) | ||
appraisal (2.1.0) | ||
bundler | ||
rake | ||
thor (>= 0.14.0) | ||
arel (3.0.3) | ||
builder (3.0.4) | ||
docile (1.1.5) | ||
erubis (2.7.0) | ||
hike (1.2.3) | ||
i18n (0.7.0) | ||
journey (1.0.4) | ||
json (1.8.3) | ||
mail (2.5.4) | ||
mime-types (~> 1.16) | ||
treetop (~> 1.4.8) | ||
mime-types (1.25.1) | ||
minitest (5.8.1) | ||
multi_json (1.11.2) | ||
polyglot (0.3.5) | ||
rack (1.4.7) | ||
rack-cache (1.5.0) | ||
rack (>= 0.4) | ||
rack-ssl (1.3.4) | ||
rack | ||
rack-test (0.6.3) | ||
rack (>= 1.0) | ||
rails (3.2.22) | ||
actionmailer (= 3.2.22) | ||
actionpack (= 3.2.22) | ||
activerecord (= 3.2.22) | ||
activeresource (= 3.2.22) | ||
activesupport (= 3.2.22) | ||
bundler (~> 1.0) | ||
railties (= 3.2.22) | ||
railties (3.2.22) | ||
actionpack (= 3.2.22) | ||
activesupport (= 3.2.22) | ||
rack-ssl (~> 1.3.2) | ||
rake (>= 0.8.7) | ||
rdoc (~> 3.4) | ||
thor (>= 0.14.6, < 2.0) | ||
rake (10.4.2) | ||
rdoc (3.12.2) | ||
json (~> 1.4) | ||
simplecov (0.10.0) | ||
docile (~> 1.1.0) | ||
json (~> 1.8) | ||
simplecov-html (~> 0.10.0) | ||
simplecov-html (0.10.0) | ||
sprockets (2.2.3) | ||
hike (~> 1.2) | ||
multi_json (~> 1.0) | ||
rack (~> 1.0) | ||
tilt (~> 1.1, != 1.3.0) | ||
sqlite3 (1.3.11) | ||
thor (0.19.1) | ||
tilt (1.4.1) | ||
treetop (1.4.15) | ||
polyglot | ||
polyglot (>= 0.3.1) | ||
tzinfo (0.3.45) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
appraisal | ||
minitest | ||
rails (= 3.2.22) | ||
rake | ||
setler! | ||
simplecov | ||
sqlite3 | ||
|
||
BUNDLED WITH | ||
1.10.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "rails", "4.2.4" | ||
|
||
gemspec :path => "../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
PATH | ||
remote: ../ | ||
specs: | ||
setler (0.0.13) | ||
activerecord (>= 3.0.0) | ||
rails (>= 3.0.0) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actionmailer (4.2.4) | ||
actionpack (= 4.2.4) | ||
actionview (= 4.2.4) | ||
activejob (= 4.2.4) | ||
mail (~> 2.5, >= 2.5.4) | ||
rails-dom-testing (~> 1.0, >= 1.0.5) | ||
actionpack (4.2.4) | ||
actionview (= 4.2.4) | ||
activesupport (= 4.2.4) | ||
rack (~> 1.6) | ||
rack-test (~> 0.6.2) | ||
rails-dom-testing (~> 1.0, >= 1.0.5) | ||
rails-html-sanitizer (~> 1.0, >= 1.0.2) | ||
actionview (4.2.4) | ||
activesupport (= 4.2.4) | ||
builder (~> 3.1) | ||
erubis (~> 2.7.0) | ||
rails-dom-testing (~> 1.0, >= 1.0.5) | ||
rails-html-sanitizer (~> 1.0, >= 1.0.2) | ||
activejob (4.2.4) | ||
activesupport (= 4.2.4) | ||
globalid (>= 0.3.0) | ||
activemodel (4.2.4) | ||
activesupport (= 4.2.4) | ||
builder (~> 3.1) | ||
activerecord (4.2.4) | ||
activemodel (= 4.2.4) | ||
activesupport (= 4.2.4) | ||
arel (~> 6.0) | ||
activesupport (4.2.4) | ||
i18n (~> 0.7) | ||
json (~> 1.7, >= 1.7.7) | ||
minitest (~> 5.1) | ||
thread_safe (~> 0.3, >= 0.3.4) | ||
tzinfo (~> 1.1) | ||
appraisal (2.1.0) | ||
bundler | ||
rake | ||
thor (>= 0.14.0) | ||
arel (6.0.3) | ||
builder (3.2.2) | ||
docile (1.1.5) | ||
erubis (2.7.0) | ||
globalid (0.3.6) | ||
activesupport (>= 4.1.0) | ||
i18n (0.7.0) | ||
json (1.8.3) | ||
loofah (2.0.3) | ||
nokogiri (>= 1.5.9) | ||
mail (2.6.3) | ||
mime-types (>= 1.16, < 3) | ||
mime-types (2.6.2) | ||
mini_portile (0.6.2) | ||
minitest (5.8.1) | ||
nokogiri (1.6.6.2) | ||
mini_portile (~> 0.6.0) | ||
rack (1.6.4) | ||
rack-test (0.6.3) | ||
rack (>= 1.0) | ||
rails (4.2.4) | ||
actionmailer (= 4.2.4) | ||
actionpack (= 4.2.4) | ||
actionview (= 4.2.4) | ||
activejob (= 4.2.4) | ||
activemodel (= 4.2.4) | ||
activerecord (= 4.2.4) | ||
activesupport (= 4.2.4) | ||
bundler (>= 1.3.0, < 2.0) | ||
railties (= 4.2.4) | ||
sprockets-rails | ||
rails-deprecated_sanitizer (1.0.3) | ||
activesupport (>= 4.2.0.alpha) | ||
rails-dom-testing (1.0.7) | ||
activesupport (>= 4.2.0.beta, < 5.0) | ||
nokogiri (~> 1.6.0) | ||
rails-deprecated_sanitizer (>= 1.0.1) | ||
rails-html-sanitizer (1.0.2) | ||
loofah (~> 2.0) | ||
railties (4.2.4) | ||
actionpack (= 4.2.4) | ||
activesupport (= 4.2.4) | ||
rake (>= 0.8.7) | ||
thor (>= 0.18.1, < 2.0) | ||
rake (10.4.2) | ||
simplecov (0.10.0) | ||
docile (~> 1.1.0) | ||
json (~> 1.8) | ||
simplecov-html (~> 0.10.0) | ||
simplecov-html (0.10.0) | ||
sprockets (3.4.0) | ||
rack (> 1, < 3) | ||
sprockets-rails (2.3.3) | ||
actionpack (>= 3.0) | ||
activesupport (>= 3.0) | ||
sprockets (>= 2.8, < 4.0) | ||
sqlite3 (1.3.11) | ||
thor (0.19.1) | ||
thread_safe (0.3.5) | ||
tzinfo (1.2.2) | ||
thread_safe (~> 0.1) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
appraisal | ||
minitest | ||
rails (= 4.2.4) | ||
rake | ||
setler! | ||
simplecov | ||
sqlite3 | ||
|
||
BUNDLED WITH | ||
1.10.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This file was generated by Appraisal | ||
|
||
source "https://rubygems.org" | ||
|
||
gem "rails", :github => "rails/rails" | ||
gem "rack", :github => "rack/rack" | ||
gem "arel", :github => "rails/arel" | ||
|
||
gemspec :path => "../" |
Oops, something went wrong.