Skip to content

Commit 54a6fb8

Browse files
committed
chore: upgrade to Ruby SDK v0.2.0
1 parent 015280b commit 54a6fb8

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ruby '>= 2.7.0'
44

55
# Add your gems here
66
gem 'rake', '~> 13.0'
7-
gem 'featurevisor', '~> 0.1.1'
7+
gem 'featurevisor', '~> 0.2.0'
88

99
group :development do
1010
gem 'rubocop', '~> 1.50'

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ GEM
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

4141
DEPENDENCIES
42-
featurevisor (~> 0.1.1)
42+
featurevisor (~> 0.2.0)
4343
rake (~> 13.0)
4444
rubocop (~> 1.50)
4545

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
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

app.rb

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,20 @@
44
require 'net/http'
55
require '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
#
2110
datafile_url = "https://featurevisor-example-cloudflare.pages.dev/production/featurevisor-tag-all.json"
22-
23-
# Fetch the datafile
2411
response = 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
3723
puts "Feature flag 'my_feature' is enabled: #{feature_flag_value}"

0 commit comments

Comments
 (0)