feature_flagger 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
 - data/MIT-LICENSE +20 -0
 - data/README.md +27 -16
 - data/feature_flagger.gemspec +3 -2
 - data/lib/feature_flagger/model.rb +27 -15
 - data/lib/feature_flagger/version.rb +1 -1
 - metadata +7 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 62073fceeca45388c4bd40ce2a3829766ba0f4d8
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7b4b54a2c3167009654572bae7b5f6bac32d2430
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: b0107beb5008bf298cb25bff915a8aa077ca119bca202985509062276f06e2d4a8632552c37f8e06b0da72f2bbd63a3c7c4c33578fbe9e2ad474fbe5fd3e78f3
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 392188e411e2017fd906df2eef539af7a52cc82229bddba4280373a548dc8a84cb32263a2072b43cef2849d603a310f901c12abe39eac6313b7cfcaa914c57fb
         
     | 
    
        data/MIT-LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright 2011-2016 Resultados Digitais. http://resultadosdigitais.com.br
         
     | 
| 
      
 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.md
    CHANGED
    
    | 
         @@ -18,11 +18,17 @@ Or install it yourself as: 
     | 
|
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                $ gem install feature_flagger
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
            ## Usage
         
     | 
| 
       22 
21 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
            ## Configuration
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            1. Configure redis by adding `config/initializers/feature_flagger.rb`:
         
     | 
| 
      
 25 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 26 
     | 
    
         
            +
            FeatureFlagger.configure do |config|
         
     | 
| 
      
 27 
     | 
    
         
            +
              config.redis = $redis
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
      
 29 
     | 
    
         
            +
            ```
         
     | 
| 
       24 
30 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 31 
     | 
    
         
            +
            2. Create a `rollout.yml` in _config_ path and declare a rollout:
         
     | 
| 
       26 
32 
     | 
    
         
             
            ```yml
         
     | 
| 
       27 
33 
     | 
    
         
             
            account: # model name
         
     | 
| 
       28 
34 
     | 
    
         
             
              email_marketing: # namespace (optional)
         
     | 
| 
         @@ -31,7 +37,7 @@ account: # model name 
     | 
|
| 
       31 
37 
     | 
    
         
             
                    @dispatch team uses this rollout to introduce a new email flow for certains users. Read more at [link]
         
     | 
| 
       32 
38 
     | 
    
         
             
            ```
         
     | 
| 
       33 
39 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
      
 40 
     | 
    
         
            +
            3. Adds rollout funcionality to your model:
         
     | 
| 
       35 
41 
     | 
    
         
             
            ```ruby
         
     | 
| 
       36 
42 
     | 
    
         
             
            class Account < ActiveRecord::Base
         
     | 
| 
       37 
43 
     | 
    
         
             
              include FeatureFlagger::Model
         
     | 
| 
         @@ -39,22 +45,27 @@ class Account < ActiveRecord::Base 
     | 
|
| 
       39 
45 
     | 
    
         
             
            end
         
     | 
| 
       40 
46 
     | 
    
         
             
            ```
         
     | 
| 
       41 
47 
     | 
    
         | 
| 
      
 48 
     | 
    
         
            +
            ## Usage
         
     | 
| 
       42 
49 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
            3. Check;
         
     | 
| 
       44 
50 
     | 
    
         
             
            ```ruby
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                  # render something else
         
     | 
| 
       51 
     | 
    
         
            -
                end
         
     | 
| 
       52 
     | 
    
         
            -
              end
         
     | 
| 
       53 
     | 
    
         
            -
            end
         
     | 
| 
       54 
     | 
    
         
            -
            ```
         
     | 
| 
      
 51 
     | 
    
         
            +
            account = Account.first
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            # Release feature for account
         
     | 
| 
      
 54 
     | 
    
         
            +
            account.release!([:email_marketing, :new_email_flow])
         
     | 
| 
      
 55 
     | 
    
         
            +
            #=> true
         
     | 
| 
       55 
56 
     | 
    
         | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
      
 57 
     | 
    
         
            +
            # Check feature for a given account
         
     | 
| 
      
 58 
     | 
    
         
            +
            account.rollout?([:email_marketing, :new_email_flow])
         
     | 
| 
      
 59 
     | 
    
         
            +
            #=> true
         
     | 
| 
       57 
60 
     | 
    
         | 
| 
      
 61 
     | 
    
         
            +
            # Remove feature for given account
         
     | 
| 
      
 62 
     | 
    
         
            +
            account.unrelease!([:email_marketing, :new_email_flow])
         
     | 
| 
      
 63 
     | 
    
         
            +
            #=> true
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            # If you try to check an existent rollout key it will raise an error.
         
     | 
| 
      
 66 
     | 
    
         
            +
            account.rollout?([:email_marketing, :new_email_flo])
         
     | 
| 
      
 67 
     | 
    
         
            +
            FeatureFlagger::KeyNotFoundError: ["account", "email_marketing", "new_email_flo"]
         
     | 
| 
      
 68 
     | 
    
         
            +
            ```
         
     | 
| 
       58 
69 
     | 
    
         | 
| 
       59 
70 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       60 
71 
     | 
    
         | 
    
        data/feature_flagger.gemspec
    CHANGED
    
    | 
         @@ -8,9 +8,10 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       8 
8 
     | 
    
         
             
              spec.version       = FeatureFlagger::VERSION
         
     | 
| 
       9 
9 
     | 
    
         
             
              spec.authors       = ["Nando Sousa"]
         
     | 
| 
       10 
10 
     | 
    
         
             
              spec.email         = ["nandosousafr@gmail.com"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              spec.licenses      = ['MIT']
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
              spec.summary       = %q{ 
     | 
| 
       13 
     | 
    
         
            -
              spec.description   = %q{ 
     | 
| 
      
 13 
     | 
    
         
            +
              spec.summary       = %q{Partial release your features.}
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.description   = %q{Management tool to make it easier rollouting features to customers.}
         
     | 
| 
       14 
15 
     | 
    
         
             
              spec.homepage      = "http://github.com/ResultadosDigitais/feature_flagger"
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
       16 
17 
     | 
    
         
             
              spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
         
     | 
| 
         @@ -8,31 +8,43 @@ module FeatureFlagger 
     | 
|
| 
       8 
8 
     | 
    
         
             
              # Account.first.rollout?([:email_marketing, :new_awesome_feature])
         
     | 
| 
       9 
9 
     | 
    
         
             
              # #=> true
         
     | 
| 
       10 
10 
     | 
    
         
             
              module Model
         
     | 
| 
      
 11 
     | 
    
         
            +
                def self.included(base)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  base.extend ClassMethods
         
     | 
| 
      
 13 
     | 
    
         
            +
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
       11 
15 
     | 
    
         
             
                def rollout?(feature_key)
         
     | 
| 
       12 
     | 
    
         
            -
                   
     | 
| 
       13 
     | 
    
         
            -
                   
     | 
| 
      
 16 
     | 
    
         
            +
                  resource_name = self.class.rollout_resource_name
         
     | 
| 
      
 17 
     | 
    
         
            +
                  Feature.new(feature_key, resource_name).fetch!
         
     | 
| 
      
 18 
     | 
    
         
            +
                  Control.rollout?(feature_key, id, resource_name)
         
     | 
| 
       14 
19 
     | 
    
         
             
                end
         
     | 
| 
       15 
20 
     | 
    
         | 
| 
       16 
21 
     | 
    
         
             
                def release!(feature_key)
         
     | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
       18 
     | 
    
         
            -
                   
     | 
| 
      
 22 
     | 
    
         
            +
                  resource_name = self.class.rollout_resource_name
         
     | 
| 
      
 23 
     | 
    
         
            +
                  Feature.new(feature_key, resource_name).fetch!
         
     | 
| 
      
 24 
     | 
    
         
            +
                  Control.release!(feature_key, id, resource_name)
         
     | 
| 
       19 
25 
     | 
    
         
             
                end
         
     | 
| 
       20 
26 
     | 
    
         | 
| 
       21 
27 
     | 
    
         
             
                def unrelease!(feature_key)
         
     | 
| 
       22 
     | 
    
         
            -
                   
     | 
| 
       23 
     | 
    
         
            -
                   
     | 
| 
      
 28 
     | 
    
         
            +
                  resource_name = self.class.rollout_resource_name
         
     | 
| 
      
 29 
     | 
    
         
            +
                  Feature.new(feature_key, resource_name).fetch!
         
     | 
| 
      
 30 
     | 
    
         
            +
                  Control.unrelease!(feature_key, id, resource_name)
         
     | 
| 
       24 
31 
     | 
    
         
             
                end
         
     | 
| 
       25 
32 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                 
     | 
| 
      
 33 
     | 
    
         
            +
                module ClassMethods
         
     | 
| 
      
 34 
     | 
    
         
            +
                  def all_released_ids_for(feature_key)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    Feature.new(feature_key, rollout_resource_name).fetch!
         
     | 
| 
      
 36 
     | 
    
         
            +
                    Control.resource_ids(feature_key, rollout_resource_name)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  end
         
     | 
| 
       27 
38 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 39 
     | 
    
         
            +
                  def rollout_resource_name
         
     | 
| 
      
 40 
     | 
    
         
            +
                    klass_name = self.to_s
         
     | 
| 
      
 41 
     | 
    
         
            +
                    klass_name.gsub!(/::/, '_')
         
     | 
| 
      
 42 
     | 
    
         
            +
                    klass_name.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
         
     | 
| 
      
 43 
     | 
    
         
            +
                    klass_name.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
         
     | 
| 
      
 44 
     | 
    
         
            +
                    klass_name.tr!("-", "_")
         
     | 
| 
      
 45 
     | 
    
         
            +
                    klass_name.downcase!
         
     | 
| 
      
 46 
     | 
    
         
            +
                    klass_name
         
     | 
| 
      
 47 
     | 
    
         
            +
                  end
         
     | 
| 
       36 
48 
     | 
    
         
             
                end
         
     | 
| 
       37 
49 
     | 
    
         
             
              end
         
     | 
| 
       38 
50 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: feature_flagger
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Nando Sousa
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-08- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-08-28 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: redis-namespace
         
     | 
| 
         @@ -66,7 +66,7 @@ dependencies: 
     | 
|
| 
       66 
66 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       67 
67 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       68 
68 
     | 
    
         
             
                    version: '3.0'
         
     | 
| 
       69 
     | 
    
         
            -
            description:  
     | 
| 
      
 69 
     | 
    
         
            +
            description: Management tool to make it easier rollouting features to customers.
         
     | 
| 
       70 
70 
     | 
    
         
             
            email:
         
     | 
| 
       71 
71 
     | 
    
         
             
            - nandosousafr@gmail.com
         
     | 
| 
       72 
72 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -77,6 +77,7 @@ files: 
     | 
|
| 
       77 
77 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
       78 
78 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       79 
79 
     | 
    
         
             
            - Gemfile
         
     | 
| 
      
 80 
     | 
    
         
            +
            - MIT-LICENSE
         
     | 
| 
       80 
81 
     | 
    
         
             
            - README.md
         
     | 
| 
       81 
82 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       82 
83 
     | 
    
         
             
            - bin/console
         
     | 
| 
         @@ -88,7 +89,8 @@ files: 
     | 
|
| 
       88 
89 
     | 
    
         
             
            - lib/feature_flagger/model.rb
         
     | 
| 
       89 
90 
     | 
    
         
             
            - lib/feature_flagger/version.rb
         
     | 
| 
       90 
91 
     | 
    
         
             
            homepage: http://github.com/ResultadosDigitais/feature_flagger
         
     | 
| 
       91 
     | 
    
         
            -
            licenses: 
     | 
| 
      
 92 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 93 
     | 
    
         
            +
            - MIT
         
     | 
| 
       92 
94 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       93 
95 
     | 
    
         
             
            post_install_message: 
         
     | 
| 
       94 
96 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
         @@ -109,6 +111,6 @@ rubyforge_project: 
     | 
|
| 
       109 
111 
     | 
    
         
             
            rubygems_version: 2.4.3
         
     | 
| 
       110 
112 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       111 
113 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       112 
     | 
    
         
            -
            summary:  
     | 
| 
      
 114 
     | 
    
         
            +
            summary: Partial release your features.
         
     | 
| 
       113 
115 
     | 
    
         
             
            test_files: []
         
     | 
| 
       114 
116 
     | 
    
         
             
            has_rdoc: 
         
     |