File tree Expand file tree Collapse file tree 4 files changed +11
-23
lines changed
Expand file tree Collapse file tree 4 files changed +11
-23
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ ruby '>= 2.7.0'
44
55# Add your gems here
66gem 'rake' , '~> 13.0'
7- gem 'featurevisor' , '~> 0.1.1 '
7+ gem 'featurevisor' , '~> 0.2.0 '
88
99group :development do
1010 gem 'rubocop' , '~> 1.50'
Original file line number Diff line number Diff line change 22 remote: https://rubygems.org/
33 specs:
44 ast (2.4.3 )
5- featurevisor (0.1.1 )
5+ featurevisor (0.2.0 )
66 json (2.13.2 )
77 language_server-protocol (3.17.0.5 )
88 lint_roller (1.1.0 )
@@ -39,7 +39,7 @@ PLATFORMS
3939 ruby
4040
4141DEPENDENCIES
42- featurevisor (~> 0.1.1 )
42+ featurevisor (~> 0.2.0 )
4343 rake (~> 13.0 )
4444 rubocop (~> 1.50 )
4545
Original file line number Diff line number Diff line change 11# featurevisor-example-ruby
22
3- Example Ruby web server that demonstrates how to use Featurevisor SDK.
3+ Example Ruby application that demonstrates how to use Featurevisor [ Ruby SDK] ( https://github.com/featurevisor/featurevisor-ruby ) .
4+
5+ Learn more about Featurevisor [ here] ( https://featurevisor.com ) .
46
57## Installation
68
Original file line number Diff line number Diff line change 44require 'net/http'
55require 'json'
66
7- def symbolize_keys ( obj )
8- case obj
9- when Hash
10- obj . transform_keys ( &:to_sym ) . transform_values { |v | symbolize_keys ( v ) }
11- when Array
12- obj . map { |v | symbolize_keys ( v ) }
13- else
14- obj
15- end
16- end
17-
187##
19- # Initialize Featurevisor
8+ # Fetch datafile
209#
2110datafile_url = "https://featurevisor-example-cloudflare.pages.dev/production/featurevisor-tag-all.json"
22-
23- # Fetch the datafile
2411response = Net ::HTTP . get ( URI ( datafile_url ) )
25- datafile_content = JSON . parse ( response )
26- symbolized_datafile = symbolize_keys ( datafile_content ) # @TODO: this shouldn't be required
12+ datafile_content = JSON . parse ( response , symbolize_names : true )
2713
2814# Create Featurevisor instance
29- featurevisor = Featurevisor . create_instance (
30- datafile : symbolized_datafile ,
15+ f = Featurevisor . create_instance (
16+ datafile : datafile_content ,
3117)
3218
3319# Get the feature flag value
34- feature_flag_value = featurevisor . is_enabled ( "my_feature" )
20+ feature_flag_value = f . is_enabled ( "my_feature" )
3521
3622# Print results to terminal
3723puts "Feature flag 'my_feature' is enabled: #{ feature_flag_value } "
You can’t perform that action at this time.
0 commit comments