1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#!/usr/bin/env ruby
require 'unleash'
require 'unleash/context'
puts ">> START simple.rb"
# Unleash.configure do |config|
# config.url = 'http://unleash.herokuapp.com/api'
# config.app_name = 'simple-test'
# config.refresh_interval = 2
# config.metrics_interval = 2
# config.retry_limit = 2
# end
# @unleash = Unleash::Client.new
# or:
@unleash = Unleash::Client.new(
url: 'https://app.unleash-hosted.com/demo/api',
app_name: 'simple-test',
instance_id: 'local-test-cli',
refresh_interval: 2,
metrics_interval: 2,
retry_limit: 2,
custom_http_headers: {'Authorization': '943ca9171e2c884c545c5d82417a655fb77cec970cc3b78a8ff87f4406b495d0'},
)
# feature_name = "AwesomeFeature"
feature_name = "4343443"
unleash_context = Unleash::Context.new
unleash_context.user_id = 123
sleep 1
3.times do
if @unleash.is_enabled?(feature_name, unleash_context)
puts "> #{feature_name} is enabled"
else
puts "> #{feature_name} is not enabled"
end
sleep 1
puts "---"
puts ""
puts ""
end
sleep 3
feature_name = "foobar"
if @unleash.is_enabled?(feature_name, unleash_context, true)
puts "> #{feature_name} is enabled"
else
puts "> #{feature_name} is not enabled"
end
puts "> shutting down client..."
@unleash.shutdown
puts ">> END simple.rb"
|