rollout-redis 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: 3b85cb7955ab58bf0ede95038078e71e534db5e477af94d9af605b3c3f48aee3
4
- data.tar.gz: a210b3007e3cc5f1bad76c3574b9729d138c5eec19df5ef4b620b29c56f7ba72
3
+ metadata.gz: 3cbcf193e2048b5dfd5e694a7556844e7d7d9c4aa7426b6f0583a589f7fc8b70
4
+ data.tar.gz: 62d2b603c6a59495c6eca0816cdda4a2ba8b6944544e572a80f208af3c821615
5
5
  SHA512:
6
- metadata.gz: eb078df42c0404c25f3439635391751cc83b3ad90a3647fac163d42240cac7afefe376d4c7de50bd9eb8565bf724bf8288fec7823f81ae10d8eb894643cad852
7
- data.tar.gz: f6a3a0c1da29db894c75fbb3b5516f9975ae6031fe0569b158ca3e5707dfa0bdd3fffe924da8bdaf6720501d75ac0073b99eea66bfb937393367f5a431e6a2e1
6
+ metadata.gz: cae46805987da343fc78d1ec937a8a42c793eb09dce7dd98aeec2f33f0a615500324ba901e4585a34aa7f64a021766021bf8d942197443e0820005881f3151fd
7
+ data.tar.gz: c679e1a883c8ec708325f3a1a628dc125b9df9d0e014c2b67b7f479b700c10264db42abbf14561052dc19ee4b49564a11e9705744db4cbc146f8f17295b45032
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
 
8
+ ## [0.3.0] - 2023-10-24
9
+
10
+ ### Added
11
+ - Providing some rake tasks to the consumers of the gem for allowing them to easily manage their feature flags in their applications:
12
+ - `bundle exec rake rollout:on` rake task for activating feature flags
13
+ - `bundle exec rake rollout:off` rake task for deactivating feature flags
14
+ - `bundle exec rake rollout:list` rake task for listing stored feature flags
15
+
8
16
  ## [0.2.0] - 2023-10-23
9
17
 
10
18
  ### Added
data/README.md CHANGED
@@ -14,6 +14,7 @@ Topics covered in this README:
14
14
  - [Gradual activation based on percentages](#gradual-activation-based-on-percentages)
15
15
  - [Caching Feature Flags](#caching-feature-flags)
16
16
  - [Auto-deactivating flags](#auto-deactivating-flags)
17
+ - [Rake tasks](#rake-tasks)
17
18
  - [Migrating from rollout gem](#migrating-from-rollout-gem-🚨)
18
19
  - [Changelog](#changelog)
19
20
  - [Contributing](#contributing)
@@ -159,6 +160,39 @@ end
159
160
 
160
161
  When any unexpected error appears during the wrapped code execution, the Rollout gem will take it into account for automatically deactivating the feature flag if the threshold of errors is reached. All the managed or captured errors inside the wrapped code will not be taken into consideration.
161
162
 
163
+ ## Rake tasks
164
+
165
+ In order to have access to the rollout rakes, you have to load manually the task definitions. For doing so load the rollout rake task:
166
+
167
+ ```ruby
168
+ require 'rollout'
169
+
170
+ load 'rollout/tasks/rollout.rake'
171
+ ```
172
+
173
+ ### Usage
174
+
175
+ To activate/deactivate features, execute the following rake tasks:
176
+
177
+ ```shell
178
+ bundle exec rake rollout:on[feature_name]
179
+ bundle exec rake rollout:off[feature_name]
180
+ ```
181
+
182
+ To a gradual activation based on percentages, pass the percentage as the second parameter when executing the `on` task.
183
+
184
+ ```shell
185
+ bundle exec rake rollout:on[feature_name,50]
186
+ ```
187
+
188
+ _NOTE_: In both cases, `feature_name` **must not** include quotes e.g. `bundle exec rake rollout:on['feature_name']`, as the gem will be unable to fetch its activation status if so.
189
+
190
+ For listing all the stored feature flags, do:
191
+
192
+ ```shell
193
+ bundle exec rake rollout:list
194
+ ```
195
+
162
196
  ## Migrating from rollout gem 🚨
163
197
 
164
198
  If you are currently using the unmaintained [rollout](https://github.com/fetlife/rollout) gem, you should consider checking this [migration guide](https://github.com/jcagarcia/rollout-redis/blob/main/MIGRATING_FROM_ROLLOUT_GEM.md) for start using the new `rollout-redis` gem.
@@ -0,0 +1,63 @@
1
+
2
+ namespace :rollout do
3
+ desc "Activate a feature"
4
+ task :on, [:feature, :percentage] => :environment do |task, args|
5
+ if args.feature
6
+ puts "Activating feature #{args.feature}..."
7
+ if args.percentage
8
+ activated = rollout.activate(args.feature, args.percentage.to_i)
9
+ else
10
+ activated = rollout.activate(args.feature)
11
+ end
12
+
13
+ if activated
14
+ puts "Feature flag #{args.feature} has been activated! :)"
15
+ else
16
+ puts "Feature flag #{args.feature} has NOT been activated! :("
17
+ end
18
+ end
19
+ end
20
+
21
+ desc "Deactivate a feature"
22
+ task :off, [:feature] => :environment do |task, args|
23
+ if args.feature
24
+ puts "Deactivating feature #{args.feature}..."
25
+ deactivated = rollout.deactivate(args.feature)
26
+ if deactivated
27
+ puts "Feature flag #{args.feature} has been deactivated! :)"
28
+ else
29
+ puts "Feature flag #{args.feature} has NOT been deactivated! :("
30
+ end
31
+ end
32
+ end
33
+
34
+ desc "List features"
35
+ task list: :environment do
36
+ features = rollout.features
37
+ puts "This is the list of all the available features:"
38
+ puts ""
39
+ if !features.empty?
40
+ puts features
41
+ else
42
+ puts "- No feature flags stored"
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ def rollout
49
+ @rollout ||= Rollout.new(storage)
50
+ end
51
+
52
+ def storage
53
+ begin
54
+ @storage ||= Redis.new(
55
+ host: ENV.fetch('ROLLOUT_REDIS_HOST'),
56
+ port: ENV.fetch('ROLLOUT_REDIS_PORT')
57
+ )
58
+ rescue KeyError => e
59
+ puts "ROLLOUT_REDIS_HOST and ROLLOUT_REDIS_PORT are mandatory env variables to define in order to run rollout rake tasks"
60
+ raise e
61
+ end
62
+ end
63
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Rollout
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'bundler', '>= 2.4'
28
28
  spec.add_development_dependency 'rspec', '~> 3.12'
29
29
  spec.add_development_dependency 'mock_redis', '~> 0.37'
30
+ spec.add_development_dependency 'rake', '~> 13'
30
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollout-redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Carlos García
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0.37'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '13'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '13'
75
89
  description: Fast and easy feature flags based on the latest Redis versions.
76
90
  email:
77
91
  - jugade92@gmail.com
@@ -84,6 +98,7 @@ files:
84
98
  - Rakefile
85
99
  - lib/rollout.rb
86
100
  - lib/rollout/feature.rb
101
+ - lib/rollout/tasks/rollout.rake
87
102
  - lib/rollout/version.rb
88
103
  - rollout-redis.gemspec
89
104
  homepage: https://github.com/jcagarcia/rollout-redis