flux_capacitor 0.1.1 → 0.1.2

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: 49cda02b4b59eeec057fe99708c69c9d33550ba7
4
- data.tar.gz: 4106e315fe782950583290ac3c3e35e8b6227684
3
+ metadata.gz: d4107cf109861cb1776c98c445095f3570ed0e10
4
+ data.tar.gz: e2ec734dcb62f0d1f06a3de91b914cee9e53ef31
5
5
  SHA512:
6
- metadata.gz: d7aba405e5ccf1bf730e30eb3f873568b3de30ce4054fde39c01dfa5615c466f6908354509dd545ec37ab098ec34ae86471d5b05a6d194ebb133cbe514e1c7f6
7
- data.tar.gz: 5c07cf434a1de885608a0fe5cbe2fa3b2f24a996be6de0df6e2f9104e1ff6e554669b1fe5df9ad2993a277b322ec45ade27f2bf53185ab4edf0201d5606680a6
6
+ metadata.gz: 02ef0c049f13c79cb14cff6c2fcd699b4720f6cf6561b54de17e678daee5e4cdc9ffebb7ed05742d3176ce283d85ed4bee0e4094553dacd385db951d400afbcd
7
+ data.tar.gz: 457b0cc03af39e3a4dd1ddc38a01a0a6dbd3ffbd0d5d760d5bf6484162e7b5c881ccc5ac4a6847b9760019a00d4c96a2941ca0c01f7169a67c3888b19bd79665
@@ -10,8 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["raphaeleidus@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Utility for progressively rolling out a feature to existing content}
13
- spec.description = %q{When you have some service that might not be able to handle a large transition of historical content, say a dynamic image service.
14
- Instead of changing everything at once you can use the flux capacitor to progressively enable the new functionality based on content age.}
13
+ spec.description = File.read('README.md')
15
14
  spec.homepage = "https://github.com/raphaeleidus/flux_capacitor"
16
15
 
17
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
@@ -1,3 +1,3 @@
1
1
  module Flux
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flux_capacitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raphael Eidus
@@ -66,9 +66,82 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
- description: |-
70
- When you have some service that might not be able to handle a large transition of historical content, say a dynamic image service.
71
- Instead of changing everything at once you can use the flux capacitor to progressively enable the new functionality based on content age.
69
+ description: |
70
+ [![Gem Version](https://badge.fury.io/rb/flux_capacitor.svg)](https://badge.fury.io/rb/flux_capacitor)
71
+
72
+ # FluxCapacitor
73
+
74
+ Sometimes you want to change a feature or deploy a new feature but doing so all at once might take down some service. Enter Flux Capacitor. It allows you to gradually include more historical content in the new feature while allowing all future content to start out with the new feature already live.
75
+
76
+ ## Installation
77
+
78
+ Add this line to your application's Gemfile:
79
+
80
+ ```ruby
81
+ gem 'flux_capacitor'
82
+ ```
83
+
84
+ And then execute:
85
+
86
+ $ bundle
87
+
88
+ Or install it yourself as:
89
+
90
+ $ gem install flux_capacitor
91
+
92
+ ## Usage
93
+
94
+ ```ruby
95
+ require 'flux_capacitor'
96
+
97
+ pivot = DateTime.parse('2017/08/14 00:00:00-000') # when do you want to start rolling out the feature
98
+ oldest = MyModel.first.created_at # If you are using active record finding your oldest item is pretty easy
99
+ # otherwise if you know the date of your first item, just use that
100
+ end_point = DateTime.parse('2017/09/14') # The point where the feature is fully rolled out/safe to remove the Flux Capacitor.
101
+ # This dictates how quickly the feature rolls out. If you are concerned about overloading a required service set this to farther in the future
102
+
103
+ FEATURE_1_CAPACITOR = Flux::Capacitor.new(pivot, end_point, oldest)
104
+
105
+ def controller_method
106
+ model = MyModel.find(params[:id])
107
+ if FEATURE_1_CAPACITOR.travel_to?(model.created_at)
108
+ use_new_feature
109
+ else
110
+ use_old_feature
111
+ end
112
+ end
113
+ ```
114
+
115
+ If your feature doesn't map well to something where you have a date for each piece of content you can still use flux capacitor. It can also take strings and distribute them evenly over your rollout period using the murmur3 hashing algorithm.
116
+ ```ruby
117
+ require 'flux_capacitor'
118
+ pivot = DateTime.parse('2017/08/14 00:00:00-000') # when do you want to start rolling out the feature
119
+ end_point = DateTime.parse('2017/09/14') # when do you want the rollout to finish
120
+
121
+ # NOTE: We don't need an oldest date when using strings
122
+ FEATURE_1_CAPACITOR = Flux::Capacitor.new(pivot, end_point)
123
+
124
+ def controller_method
125
+ model = MyModel.find(params[:id])
126
+ if FEATURE_1_CAPACITOR.travel_to?(model.uuid)
127
+ use_new_feature
128
+ else
129
+ use_old_feature
130
+ end
131
+ end
132
+ ```
133
+
134
+ One note about using the string hashing method, new content could get the old feature for a while.
135
+
136
+ ## Development
137
+
138
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
139
+
140
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
141
+
142
+ ## Contributing
143
+
144
+ Bug reports and pull requests are welcome on GitHub at https://github.com/raphaeleidus/flux_capacitor.
72
145
  email:
73
146
  - raphaeleidus@gmail.com
74
147
  executables: []