remote_config 1.0.0.pre.beta.1 → 1.0.0.pre.beta.2
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/README.md +24 -11
- data/bin/rails +1 -1
- data/lib/generators/remote_config/install_generator.rb +21 -0
- data/lib/generators/remote_config/templates/remote_config.rb +29 -0
- data/lib/remote_config/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc66fc47eae896e43f629b96329258ec51f1559f59cdbefc7eab008545ce93ab
|
4
|
+
data.tar.gz: 8c5898ef0c3c52e2ff78ed2617b8fc8ab8752c79dfe31df59bca1f0af307f7ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7fed882be9d6deb0042c82acd8c0c657a055ff43080b4331cd4264439c6ba68321b66ae3be93b8a858bf40d4707869a8e0862e5c424afd2eb5d9b1e06215af3
|
7
|
+
data.tar.gz: 8b395cd921bccb4906f22c4945f5d3e33e22df8897f47db63d496f578952f07648a7d055e002db16b229cfc7563106a1e11ca3a005e2f6eed67d6ebecad9baf0
|
data/README.md
CHANGED
@@ -4,6 +4,27 @@ A gem for managing feature and release flags in the backend and providing them r
|
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
7
|
+
Add the following lines to your Gemfile:
|
8
|
+
|
9
|
+
```rb
|
10
|
+
gem "config"
|
11
|
+
gem "remote_config"
|
12
|
+
```
|
13
|
+
|
14
|
+
Run the Config gem's install generator:
|
15
|
+
|
16
|
+
```sh
|
17
|
+
rails g config:install
|
18
|
+
```
|
19
|
+
|
20
|
+
Run this gem's install generator:
|
21
|
+
|
22
|
+
```sh
|
23
|
+
rails g remote_config:install
|
24
|
+
```
|
25
|
+
|
26
|
+
With a default Config gem setup you should be good to go! Review the `app/config/remote_config` initializer and make sure the release stages make sense for your setup.
|
27
|
+
|
7
28
|
### Feature Flagging
|
8
29
|
|
9
30
|
Flagging allows checking of config values and doing different things based on their boolean value.
|
@@ -88,7 +109,7 @@ By default the feature flagging looks for values under under `features` and rele
|
|
88
109
|
If you want to nest a flag under another, for example, you have a `coffee_ordering` release flag and you want to add a `coffee_ordernig.pre_pay` release flag. Then you can nest the new flag under the old one and add a `_` key underneath it for it's own value, e.g:
|
89
110
|
|
90
111
|
```yml
|
91
|
-
|
112
|
+
release_flags:
|
92
113
|
coffee_ordering:
|
93
114
|
_: uat
|
94
115
|
pre_pay: development
|
@@ -98,7 +119,7 @@ releases:
|
|
98
119
|
An example `app/config/settings.yml` might look like:
|
99
120
|
|
100
121
|
```yml
|
101
|
-
|
122
|
+
release_flags:
|
102
123
|
loyalty: uat
|
103
124
|
coffee_ordering:
|
104
125
|
_: production
|
@@ -109,14 +130,6 @@ releases:
|
|
109
130
|
v3:
|
110
131
|
_: development
|
111
132
|
|
112
|
-
|
133
|
+
feature_flags:
|
113
134
|
pay_in_car: true
|
114
135
|
```
|
115
|
-
|
116
|
-
NOTE: it may be useful to split out your releases and features YML into different files and load them in.
|
117
|
-
|
118
|
-
`app/config/releases.yml`
|
119
|
-
`app/config/features.yml`
|
120
|
-
|
121
|
-
TODO: provide ruby snippet of how to set this up in the initializers
|
122
|
-
|
data/bin/rails
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# installed from the root of your application.
|
4
4
|
|
5
5
|
ENGINE_ROOT = File.expand_path("..", __dir__)
|
6
|
-
ENGINE_PATH = File.expand_path("../lib/
|
6
|
+
ENGINE_PATH = File.expand_path("../lib/remote_config/engine", __dir__)
|
7
7
|
APP_PATH = File.expand_path("../spec/rails_app/config/application", __dir__)
|
8
8
|
|
9
9
|
# Set up gems listed in the Gemfile.
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RemoteConfig
|
4
|
+
module Generators
|
5
|
+
# Adapter for fetching feature and release flags from a set up config using
|
6
|
+
# the Config gem (see https://github.com/rubyconfig/config).
|
7
|
+
class InstallGenerator < ::Rails::Generators::Base
|
8
|
+
desc "Generates a custom Rails RemoteConfig initializer file."
|
9
|
+
|
10
|
+
# rubocop:disable Naming/MemoizedInstanceVariableName
|
11
|
+
def self.source_root
|
12
|
+
@_config_source_root ||= File.expand_path("templates", __dir__)
|
13
|
+
end
|
14
|
+
# rubocop:enable Naming/MemoizedInstanceVariableName
|
15
|
+
|
16
|
+
def copy_initializer
|
17
|
+
template "remote_config.rb", "config/initializers/remote_config.rb"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RemoteConfig.configure do |config|
|
4
|
+
# Overwrite to change the adapter to fetch the flags from a different source.
|
5
|
+
# Currently, the gem only comes with the RubyConfigAdapter.
|
6
|
+
config.adapter = RemoteConfig::Adapters::RubyConfigAdapter
|
7
|
+
|
8
|
+
# Options to be provided to the specific adapters initialization.
|
9
|
+
config.adapter_options = {
|
10
|
+
const_name: "Settings",
|
11
|
+
feature_flags_key: "feature_flags",
|
12
|
+
release_flags_key: "release_flags"
|
13
|
+
}
|
14
|
+
|
15
|
+
# Defines the release stages that are used to check release flags for their
|
16
|
+
# current environments release status.
|
17
|
+
#
|
18
|
+
# A release flag is true if the current environment is in the release stage
|
19
|
+
# configured for the flag.
|
20
|
+
# e.g.
|
21
|
+
# - if you have a release stage uat: [:uat, :dev, :development]
|
22
|
+
# - and release flag "coffee.pre_pay" is configured to "uat"
|
23
|
+
# - then it will return true when the Rails.env is either uat, dev or development
|
24
|
+
# - and it will return false on other environments, e.g. production, staging
|
25
|
+
config.release_stages = {
|
26
|
+
production: %i[production development],
|
27
|
+
development: %i[development]
|
28
|
+
}
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remote_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.beta.
|
4
|
+
version: 1.0.0.pre.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Montgomery Anderson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Remote Config for Ruby on Rails
|
14
14
|
email: montgomery.c.anderson@gmail.com
|
@@ -28,6 +28,8 @@ files:
|
|
28
28
|
- app/models/remote_config/application_record.rb
|
29
29
|
- bin/rails
|
30
30
|
- config/routes.rb
|
31
|
+
- lib/generators/remote_config/install_generator.rb
|
32
|
+
- lib/generators/remote_config/templates/remote_config.rb
|
31
33
|
- lib/remote_config.rb
|
32
34
|
- lib/remote_config/adapters/base.rb
|
33
35
|
- lib/remote_config/adapters/ruby_config_adapter.rb
|