Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Add an example sinatra app using openfeature-sdk #63

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem "concurrent-ruby"
gem "cowsay"
gem "openfeature-sdk", path: ".."
gem "puma"
gem "sinatra"
38 changes: 38 additions & 0 deletions examples/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
PATH
remote: ..
specs:
openfeature-sdk (0.1.0)

GEM
remote: https://rubygems.org/
specs:
concurrent-ruby (1.2.2)
cowsay (0.3.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.9)
puma (6.3.1)
nio4r (~> 2.0)
rack (2.2.8)
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
ruby2_keywords (0.0.5)
sinatra (3.1.0)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.1.0)
tilt (~> 2.0)
tilt (2.2.0)

PLATFORMS
arm64-darwin-22

DEPENDENCIES
concurrent-ruby
cowsay
openfeature-sdk!
puma
sinatra

BUNDLED WITH
2.4.19
18 changes: 18 additions & 0 deletions examples/app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require "sinatra"
require "cowsay"
require "openfeature/sdk"

OpenFeature::SDK.configure do |config|
config.provider = OpenFeature::SDK::Provider::NoOpProvider.new
end
feature_flags = OpenFeature::SDK.build_client(name: "my-app")

get "/" do
if feature_flags.fetch_boolean_value(flag_key: "with-cows", default_value: false)
"<pre>#{Cowsay.say "Hello, world!", "cow"}</pre>"
else
"<p>Hello, world!</p>"
end
end
Loading