feature_flagger 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74316fc70e25aa5098d8e500a59b1a983dabff2d
4
- data.tar.gz: 98f838a09eb04c89b5f5f36b4b3a84859de36b14
3
+ metadata.gz: 62073fceeca45388c4bd40ce2a3829766ba0f4d8
4
+ data.tar.gz: 7b4b54a2c3167009654572bae7b5f6bac32d2430
5
5
  SHA512:
6
- metadata.gz: f9b56d90d8bda18e090fb81b84387aef0c9bc053e09c758b2cbe3ebc38103b2a7208049c5bb822dfe036750ffde5ed4736341956234b8bb0bc4f083f342622e2
7
- data.tar.gz: a00d2a9aac2e8ab2082f7ec6950a73f0d1653a9497ea0ee7b69adf15e8f0ee8311d82c0dd0e2fbcefc1437cf4618de0325432fb4e6f7a23db49b6567e8d4ae87
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
- ### Rails
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
- 1. Create a `rollout.yml` in _config_ path and declare a rollout:
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
- 2. Adds rollout funcionality to your model:
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
- class DashboardController < ApplicationController
46
- def index
47
- if current_user.account.rollout?([:email_marketing, :new_email_flow])
48
- # render something
49
- else
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
- P.S: If you try to check a inexistent rollout key will raise an error.
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
 
@@ -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{Write a short summary, because Rubygems requires one.}
13
- spec.description = %q{Write a longer description or delete this line.}
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
- Feature.new(feature_key, rollout_resource_name).fetch!
13
- Control.rollout?(feature_key, id, rollout_resource_name)
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
- Feature.new(feature_key, rollout_resource_name).fetch!
18
- Control.release!(feature_key, id, rollout_resource_name)
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
- Feature.new(feature_key, rollout_resource_name).fetch!
23
- Control.unrelease!(feature_key, id, rollout_resource_name)
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
- private
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
- def rollout_resource_name
29
- klass_name = self.class.name
30
- klass_name.gsub!(/::/, '_')
31
- klass_name.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
32
- klass_name.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
33
- klass_name.tr!("-", "_")
34
- klass_name.downcase!
35
- klass_name
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
@@ -1,3 +1,3 @@
1
1
  module FeatureFlagger
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  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.1.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-23 00:00:00.000000000 Z
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: Write a longer description or delete this line.
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: Write a short summary, because Rubygems requires one.
114
+ summary: Partial release your features.
113
115
  test_files: []
114
116
  has_rdoc: