unleash 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 +5 -5
- data/.travis.yml +5 -1
- data/README.md +46 -14
- data/TODO.md +1 -1
- data/lib/unleash.rb +12 -0
- data/lib/unleash/activation_strategy.rb +1 -1
- data/lib/unleash/configuration.rb +1 -1
- data/lib/unleash/feature_toggle.rb +0 -21
- data/lib/unleash/version.rb +1 -1
- data/unleash-client.gemspec +3 -0
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3e17e0aeb7e67031de9d1088f574059c27e897f7a4d1e14106274f4b2aed5b14
|
4
|
+
data.tar.gz: c12cf65f061e004f8b040b4bffa09c1515d432d678ed8e12d4baabf5ef36ba5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d76a97471f879db4a8458f916833923e31e6ea2b671d5d9421122bf54275ca27183ee18b064eae61e7a406b268d6a4c58cdc8ac2b617f00d67dc7c2015c0ceff
|
7
|
+
data.tar.gz: ed965bd8bb3c3d561e7eb93a0c44f91f9186fddb7b2932da025bc571ffdf3a4d9691a41a112375df51a01f19a22b81c4c1b849eccf00ba6ed5baed45020c6393
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Unleash::Client
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/Unleash/unleash-client-ruby.svg?branch=master)](https://travis-ci.org/Unleash/unleash-client-ruby)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/github/Unleash/unleash-client-ruby/badge.svg?branch=master)](https://coveralls.io/github/Unleash/unleash-client-ruby?branch=master)
|
5
|
+
|
3
6
|
Unleash client so you can roll out your features with confidence.
|
4
7
|
|
5
8
|
Leverage the [Unleash Server](https://github.com/Unleash/unleash) for powerful feature toggling in your ruby/rails applications.
|
@@ -9,7 +12,7 @@ Leverage the [Unleash Server](https://github.com/Unleash/unleash) for powerful f
|
|
9
12
|
Add this line to your application's Gemfile:
|
10
13
|
|
11
14
|
```ruby
|
12
|
-
gem 'unleash', '~> 0.1.
|
15
|
+
gem 'unleash', '~> 0.1.1'
|
13
16
|
```
|
14
17
|
|
15
18
|
And then execute:
|
@@ -22,15 +25,15 @@ Or install it yourself as:
|
|
22
25
|
|
23
26
|
## Configure
|
24
27
|
|
25
|
-
It is **required** to configure the `
|
28
|
+
It is **required** to configure the `url` of the unleash server. Please substitute the sample `'http://unleash.herokuapp.com/api'` for the url of your own instance.
|
26
29
|
|
27
30
|
It is **highly recommended** to configure `app_name` and the `instance_id`.
|
28
31
|
|
29
32
|
For other options please see `lib/unleash/configuration.rb`.
|
30
33
|
|
31
34
|
```ruby
|
32
|
-
Unleash
|
33
|
-
config.
|
35
|
+
Unleash.configure do |config|
|
36
|
+
config.url = 'http://unleash.herokuapp.com/api'
|
34
37
|
config.app_name = 'my_ruby_app'
|
35
38
|
end
|
36
39
|
```
|
@@ -38,7 +41,7 @@ end
|
|
38
41
|
or instantiate the client with the valid configuration:
|
39
42
|
|
40
43
|
```ruby
|
41
|
-
UNLEASH = Unleash::Client.new(
|
44
|
+
UNLEASH = Unleash::Client.new(url: 'http://unleash.herokuapp.com/api', app_name: 'my_ruby_app')
|
42
45
|
```
|
43
46
|
|
44
47
|
## Usage in a plain Ruby Application
|
@@ -47,7 +50,7 @@ UNLEASH = Unleash::Client.new(hostname: 'host.domain', app_name: 'my_ruby_app')
|
|
47
50
|
require 'unleash'
|
48
51
|
require 'unleash/context'
|
49
52
|
|
50
|
-
@unleash = Unleash::Client.new(
|
53
|
+
@unleash = Unleash::Client.new(url: 'http://unleash.herokuapp.com/api', app_name: 'my_ruby_app')
|
51
54
|
|
52
55
|
feature_name = "AwesomeFeature"
|
53
56
|
unleash_context = Unleash::Context.new
|
@@ -62,22 +65,41 @@ end
|
|
62
65
|
|
63
66
|
## Usage in a Rails Application
|
64
67
|
|
65
|
-
Note: known to not work currently with [puma](https://github.com/puma/puma).
|
66
|
-
|
67
68
|
#### Add Initializer
|
68
69
|
|
69
70
|
Put in `config/initializers/unleash.rb`:
|
70
71
|
|
71
72
|
```ruby
|
72
|
-
Unleash
|
73
|
-
config.
|
74
|
-
config.app_name = Rails.application.class.parent
|
73
|
+
Unleash.configure do |config|
|
74
|
+
config.url = 'http://unleash.herokuapp.com/api'
|
75
|
+
config.app_name = Rails.application.class.parent.to_s
|
75
76
|
# config.instance_id = "#{Socket.gethostname}"
|
76
77
|
end
|
78
|
+
|
79
|
+
UNLEASH = Unleash::Client.new
|
77
80
|
```
|
78
81
|
For `config.instance_id` use a string with a unique identification for the running instance. For example: it could be the hostname, if you only run one App per host. Or the docker container id, if you are running in docker. If it is not set the client will generate an unique UUID for each execution.
|
79
82
|
|
80
83
|
|
84
|
+
#### Add Initializer if using [Puma](https://github.com/puma/puma)
|
85
|
+
|
86
|
+
In `puma.rb` ensure that the unleash client is configured and instantiated as below, inside the `on_worker_boot` code block:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
on_worker_boot do
|
90
|
+
# ...
|
91
|
+
|
92
|
+
Unleash.configure do |config|
|
93
|
+
config.url = 'http://unleash.herokuapp.com/api'
|
94
|
+
config.app_name = Rails.application.class.parent.to_s
|
95
|
+
end
|
96
|
+
Rails.configuration.unleash = Unleash::Client.new
|
97
|
+
end
|
98
|
+
```
|
99
|
+
|
100
|
+
Instead of the configuration in `config/initializers/unleash.rb`.
|
101
|
+
|
102
|
+
|
81
103
|
#### Set Unleash::Context
|
82
104
|
|
83
105
|
Be sure to add the following method and callback in the application controller to have `@unleash_context` set for all requests:
|
@@ -97,13 +119,23 @@ Add in `app/controllers/application_controller.rb`:
|
|
97
119
|
end
|
98
120
|
```
|
99
121
|
|
122
|
+
Or if you see better fit, only in the controllers that you will be using unleash.
|
123
|
+
|
100
124
|
#### Sample usage
|
101
125
|
|
102
126
|
Then wherever in your application that you need a feature toggle, you can use:
|
103
127
|
|
104
128
|
```ruby
|
105
129
|
if UNLEASH.is_enabled? "AwesomeFeature", @unleash_context
|
106
|
-
puts "enabled"
|
130
|
+
puts "AwesomeFeature is enabled"
|
131
|
+
end
|
132
|
+
```
|
133
|
+
|
134
|
+
or if client is set in `Rails.configuration.unleash`:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
if Rails.configuration.unleash.is_enabled? "AwesomeFeature", @unleash_context
|
138
|
+
puts "AwesomeFeature is enabled"
|
107
139
|
end
|
108
140
|
```
|
109
141
|
|
@@ -115,7 +147,7 @@ bundle exec examples/simple.rb
|
|
115
147
|
|
116
148
|
## Available Strategies
|
117
149
|
|
118
|
-
This client comes with
|
150
|
+
This client comes with the all the required strategies out of the box:
|
119
151
|
|
120
152
|
* ApplicationHostnameStrategy
|
121
153
|
* DefaultStrategy
|
@@ -133,7 +165,7 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
133
165
|
|
134
166
|
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).
|
135
167
|
|
136
|
-
See
|
168
|
+
See (TODO.md) for known limitations, and feature roadmap.
|
137
169
|
|
138
170
|
|
139
171
|
## Contributing
|
data/TODO.md
CHANGED
@@ -6,7 +6,6 @@ The Ruby client should be pretty stable now. But no warranty is given, and some
|
|
6
6
|
|
7
7
|
Implement:
|
8
8
|
----------
|
9
|
-
* Support for allowing custom strategies.
|
10
9
|
* Possibility for custom HTTP headers when interacting with unleash server.
|
11
10
|
|
12
11
|
To test: (and write tests for)
|
@@ -34,4 +33,5 @@ DONE:
|
|
34
33
|
* Configurable Logging (logger + level)
|
35
34
|
* Switch hashing function to use murmurhash3 as per https://github.com/Unleash/unleash/issues/247
|
36
35
|
* Document usage with Rails
|
36
|
+
* Support for allowing custom strategies.
|
37
37
|
|
data/lib/unleash.rb
CHANGED
@@ -1,12 +1,24 @@
|
|
1
1
|
require 'unleash/version'
|
2
2
|
require 'unleash/configuration'
|
3
|
+
require 'unleash/strategy/base'
|
3
4
|
require 'unleash/context'
|
4
5
|
require 'unleash/client'
|
5
6
|
require 'logger'
|
6
7
|
|
8
|
+
Gem.find_files('unleash/strategy/**/*.rb').each { |path| require path }
|
9
|
+
|
7
10
|
module Unleash
|
8
11
|
TIME_RESOLUTION = 3
|
9
12
|
|
13
|
+
STRATEGIES = Unleash::Strategy.constants
|
14
|
+
.select { |c| Unleash::Strategy.const_get(c).is_a? Class }
|
15
|
+
.map { |c|
|
16
|
+
lowered_c = c.to_s
|
17
|
+
lowered_c[0] = lowered_c[0].downcase
|
18
|
+
[lowered_c.to_sym, Object::const_get("Unleash::Strategy::#{c}").new]
|
19
|
+
}
|
20
|
+
.to_h
|
21
|
+
|
10
22
|
class << self
|
11
23
|
attr_accessor :configuration, :toggle_fetcher, :toggles, :toggle_metrics, :reporter, :logger
|
12
24
|
end
|
@@ -9,7 +9,7 @@ module Unleash
|
|
9
9
|
if params.is_a?(Hash)
|
10
10
|
self.params = params
|
11
11
|
else
|
12
|
-
Unleash.logger.
|
12
|
+
Unleash.logger.warn "Invalid params provided for ActivationStrategy #{params}"
|
13
13
|
self.params = {}
|
14
14
|
end
|
15
15
|
end
|
@@ -1,27 +1,6 @@
|
|
1
1
|
require 'unleash/activation_strategy'
|
2
|
-
require 'unleash/strategy/base'
|
3
|
-
require 'unleash/strategy/default'
|
4
|
-
require 'unleash/strategy/application_hostname'
|
5
|
-
require 'unleash/strategy/gradual_rollout_random'
|
6
|
-
require 'unleash/strategy/gradual_rollout_sessionid'
|
7
|
-
require 'unleash/strategy/gradual_rollout_userid'
|
8
|
-
require 'unleash/strategy/remote_address'
|
9
|
-
require 'unleash/strategy/user_with_id'
|
10
|
-
require 'unleash/strategy/unknown'
|
11
2
|
|
12
3
|
module Unleash
|
13
|
-
STRATEGIES = {
|
14
|
-
applicationHostname: Unleash::Strategy::ApplicationHostname.new,
|
15
|
-
gradualRolloutRandom: Unleash::Strategy::GradualRolloutRandom.new,
|
16
|
-
gradualRolloutSessionId: Unleash::Strategy::GradualRolloutSessionId.new,
|
17
|
-
gradualRolloutUserId: Unleash::Strategy::GradualRolloutUserId.new,
|
18
|
-
remoteAddress: Unleash::Strategy::RemoteAddress.new,
|
19
|
-
userWithId: Unleash::Strategy::UserWithId.new,
|
20
|
-
unknown: Unleash::Strategy::Unknown.new,
|
21
|
-
default: Unleash::Strategy::Default.new,
|
22
|
-
}
|
23
|
-
|
24
|
-
|
25
4
|
class FeatureToggle
|
26
5
|
attr_accessor :name, :enabled, :strategies, :choices, :choices_lock
|
27
6
|
|
data/lib/unleash/version.rb
CHANGED
data/unleash-client.gemspec
CHANGED
@@ -21,10 +21,13 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.bindir = "exe"
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
|
+
spec.required_ruby_version = "~> 2.2"
|
24
25
|
|
25
26
|
spec.add_dependency "murmurhash3", "~> 0.1.6"
|
26
27
|
|
27
28
|
spec.add_development_dependency "bundler", "~> 1.14"
|
28
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
30
|
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
spec.add_development_dependency "coveralls"
|
32
|
+
|
30
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unleash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renato Arruda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: murmurhash3
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: |-
|
70
84
|
Unleash is a feature toggle system, that gives you a great overview
|
71
85
|
over all feature toggles across all your applications and services.
|
@@ -118,9 +132,9 @@ require_paths:
|
|
118
132
|
- lib
|
119
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
120
134
|
requirements:
|
121
|
-
- - "
|
135
|
+
- - "~>"
|
122
136
|
- !ruby/object:Gem::Version
|
123
|
-
version: '
|
137
|
+
version: '2.2'
|
124
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
139
|
requirements:
|
126
140
|
- - ">="
|
@@ -128,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
142
|
version: '0'
|
129
143
|
requirements: []
|
130
144
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.6
|
145
|
+
rubygems_version: 2.7.6
|
132
146
|
signing_key:
|
133
147
|
specification_version: 4
|
134
148
|
summary: Unleash feature toggle client.
|