Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/servactory/featury
Managing Ruby application features
https://github.com/servactory/featury
configs features managing-features rails ruby ruby-on-rails settings
Last synced: about 1 month ago
JSON representation
Managing Ruby application features
- Host: GitHub
- URL: https://github.com/servactory/featury
- Owner: servactory
- License: mit
- Created: 2024-06-20T15:24:46.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-08T16:48:57.000Z (about 2 months ago)
- Last Synced: 2024-11-20T14:49:16.326Z (about 1 month ago)
- Topics: configs, features, managing-features, rails, ruby, ruby-on-rails, settings
- Language: Ruby
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
## Purpose
Featury is designed to group and manage multiple features within a project.
It provides the flexibility to utilize any pre-existing solution or create your own.
It's easily adjustable to align with the unique needs and objectives of your project.[//]: # (## Documentation)
[//]: # (See [featury.servactory.com](https://featury.servactory.com) for documentation.)
## Quick Start
### Installation
```ruby
gem "featury"
```### Usage
#### Basic class for your features
For instance, assume that you are utilizing Flipper for managing features.
In such scenario, the base class could potentially be structured as follows:```ruby
class ApplicationFeature < Featury::Base
action :enabled? do |features:, **options|
features.all? { |feature| Flipper.enabled?(feature, *options.values) }
endaction :disabled? do |features:, **options|
features.any? { |feature| !Flipper.enabled?(feature, *options.values) }
endaction :enable do |features:, **options|
features.all? { |feature| Flipper.enable(feature, *options.values) }
endaction :disable do |features:, **options|
features.all? { |feature| Flipper.disable(feature, *options.values) }
end
end
```#### Features of your project
```ruby
class UserFeature::Onboarding < ApplicationFeature
resource :user, type: Usercondition ->(resources:) { resources.user.onboarding_awaiting? }
prefix :user_onboarding
features :passage # => :user_onboarding_passage
groups BillingFeature,
PaymentSystemFeature
end
``````ruby
class BillingFeature < ApplicationFeature
prefix :billingfeatures :api, # => :billing_api
:webhooks # => :billing_webhooks
end
``````ruby
class PaymentSystemFeature < ApplicationFeature
prefix :payment_systemfeatures :api, # => :payment_system_api
:webhooks # => :payment_system_webhooks
end
```The `resource` method provides an indication of how the transmitted information ought to be processed.
Besides the options provided by [Servactory](https://github.com/servactory/servactory), additional ones are available for stipulating the processing mode of the transmitted data.If a resource needs to be conveyed as a feature flag option, utilize the `option` parameter:
```ruby
resource :user, type: User, option: true
```To transfer a resource to a nested group, utilize the `nested` option:
```ruby
resource :user, type: User, nested: true
```#### Working with the features of your project
Each of these actions will be applied to every feature flag.
Subsequently, the outcome of these actions will be contingent upon the combined results of all feature flags.```ruby
UserFeature::Onboarding.enabled?(user:) # => true
UserFeature::Onboarding.disabled?(user:) # => false
UserFeature::Onboarding.enable(user:) # => true
UserFeature::Onboarding.disable(user:) # => true
```You can also utilize the `with` method to pass necessary arguments.
```ruby
feature = UserFeature::Onboarding.with(user:)feature.enabled? # => true
feature.disabled? # => false
feature.enable # => true
feature.disable # => true
```If a feature flag is deactivated, possibly via automation processes,
the primary feature class subsequently responds with `false` when
queried about its enablement status.In the preceding example, there might be a scenario where the payment system is
undergoing technical maintenance and therefore is temporarily shut down.
Consequently, the onboarding process for new users will be halted until further notice.## Contributing
This project is intended to be a safe, welcoming space for collaboration.
Contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
We recommend reading the [contributing guide](./CONTRIBUTING.md) as well.## License
Featury is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).