|
1 | | -# Openfeature::Sdk |
| 1 | +# OpenFeature SDK for Ruby |
2 | 2 |
|
3 | | -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/openfeature/sdk`. To experiment with that code, run `bin/console` for an interactive prompt. |
| 3 | +[](https://cloud-native.slack.com/archives/C0344AANLA1) |
| 4 | +[](https://github.com/open-feature/spec/tree/v0.5.1) |
| 5 | + |
4 | 6 |
|
5 | | -TODO: Delete this and the text above, and describe your gem |
| 7 | +This is the Ruby implementation of [OpenFeature](https://openfeature.dev), a vendor-agnostic abstraction library for evaluating feature flags. |
| 8 | + |
| 9 | +We support multiple data types for flags (numbers, strings, booleans, objects) as well as hooks, which can alter the lifecycle of a flag evaluation. |
| 10 | + |
| 11 | +## Requirements |
| 12 | + |
| 13 | +- Ruby 2.7.6 |
| 14 | +- Ruby 3.0.4 |
| 15 | +- Ruby 3.1.2 |
6 | 16 |
|
7 | 17 | ## Installation |
8 | 18 |
|
9 | 19 | Install the gem and add to the application's Gemfile by executing: |
10 | 20 |
|
11 | | - $ bundle add openfeature-sdk |
| 21 | +```sh |
| 22 | +bundle add openfeature-sdk |
| 23 | +``` |
12 | 24 |
|
13 | 25 | If bundler is not being used to manage dependencies, install the gem by executing: |
14 | 26 |
|
15 | | - $ gem install openfeature-sdk |
| 27 | +```sh |
| 28 | +gem install openfeature-sdk |
| 29 | +``` |
16 | 30 |
|
17 | 31 | ## Usage |
18 | 32 |
|
19 | | -TODO: Write usage instructions here |
| 33 | +```ruby |
| 34 | +require 'openfeature/sdk' |
| 35 | +require 'json' # For JSON.dump |
| 36 | + |
| 37 | +# API Initialization and configuration |
| 38 | + |
| 39 | +OpenFeature::SDK.configure do |config| |
| 40 | + # your provider of choice |
| 41 | + config.provider = OpenFeature::SDK::Provider::NoOpProvider.new |
| 42 | +end |
20 | 43 |
|
21 | | -## Development |
| 44 | +# Create a client |
| 45 | +client = OpenFeature::SDK.build_client(name: "my-app") |
22 | 46 |
|
23 | | -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. |
| 47 | +# get a bool value |
| 48 | +const bool_value = client.fetch_boolean_value(flag_key: 'boolean_flag', default_value: false); |
24 | 49 |
|
25 | | -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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). |
| 50 | +// get a string value |
| 51 | +const string_value = client.fetch_string_value(flag_key: 'string_flag', default_value: false); |
| 52 | + |
| 53 | +// get an numeric value |
| 54 | +const float_value = client.fetch_number_value(flag_key: 'number_value', default_value: 1.0); |
| 55 | +const integer_value = client.fetch_number_value(flag_key: 'number_value', default_value: 1); |
| 56 | + |
| 57 | +// get an object value |
| 58 | +const object = await client.fetch_object_value('object_value', JSON.dump({ name: 'object'})); |
| 59 | +``` |
| 60 | + |
| 61 | +For complete documentation, visit: https://docs.openfeature.dev/docs/category/concepts |
26 | 62 |
|
27 | 63 | ## Contributing |
28 | 64 |
|
29 | | -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/openfeature-sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/openfeature-sdk/blob/main/CODE_OF_CONDUCT.md). |
| 65 | +See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to the OpenFeature project. |
30 | 66 |
|
31 | | -## License |
| 67 | +Our community meetings are held regularly and open to everyone. Check the [OpenFeature community calendar](https://calendar.google.com/calendar/u/0?cid=MHVhN2kxaGl2NWRoMThiMjd0b2FoNjM2NDRAZ3JvdXAuY2FsZW5kYXIuZ29vZ2xlLmNvbQ) for specific dates and for the Zoom meeting links. |
32 | 68 |
|
33 | | -The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). |
34 | 69 |
|
35 | | -## Code of Conduct |
| 70 | +## License |
36 | 71 |
|
37 | | -Everyone interacting in the Openfeature::Sdk project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/openfeature-sdk/blob/main/CODE_OF_CONDUCT.md). |
| 72 | +[Apache License 2.0](LICENSE) |
0 commit comments