featurehub-sdk 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +124 -63
- data/LICENSE +21 -0
- data/README.md +235 -0
- data/examples/rails_example/.env.example +13 -0
- data/examples/rails_example/.gitattributes +7 -0
- data/examples/rails_example/.gitignore +103 -0
- data/examples/rails_example/.ruby-version +1 -0
- data/examples/rails_example/Dockerfile +12 -0
- data/examples/rails_example/Gemfile +80 -0
- data/examples/rails_example/Gemfile.lock +283 -0
- data/examples/rails_example/README.md +36 -0
- data/examples/rails_example/Rakefile +8 -0
- data/examples/rails_example/app/assets/config/manifest.js +4 -0
- data/examples/rails_example/app/assets/images/.keep +0 -0
- data/examples/rails_example/app/assets/stylesheets/application.css +15 -0
- data/examples/rails_example/app/channels/application_cable/channel.rb +6 -0
- data/examples/rails_example/app/channels/application_cable/connection.rb +6 -0
- data/examples/rails_example/app/controllers/application_controller.rb +4 -0
- data/examples/rails_example/app/controllers/concerns/.keep +0 -0
- data/examples/rails_example/app/controllers/home_controller.rb +12 -0
- data/examples/rails_example/app/helpers/application_helper.rb +4 -0
- data/examples/rails_example/app/helpers/home_helper.rb +4 -0
- data/examples/rails_example/app/javascript/application.js +3 -0
- data/examples/rails_example/app/javascript/controllers/application.js +9 -0
- data/examples/rails_example/app/javascript/controllers/hello_controller.js +7 -0
- data/examples/rails_example/app/javascript/controllers/index.js +11 -0
- data/examples/rails_example/app/jobs/application_job.rb +9 -0
- data/examples/rails_example/app/mailers/application_mailer.rb +6 -0
- data/examples/rails_example/app/models/application_record.rb +5 -0
- data/examples/rails_example/app/models/concerns/.keep +0 -0
- data/examples/rails_example/app/views/home/index.html.erb +6 -0
- data/examples/rails_example/app/views/layouts/application.html.erb +16 -0
- data/examples/rails_example/app/views/layouts/mailer.html.erb +13 -0
- data/examples/rails_example/app/views/layouts/mailer.text.erb +1 -0
- data/examples/rails_example/bin/bundle +118 -0
- data/examples/rails_example/bin/importmap +5 -0
- data/examples/rails_example/bin/rails +6 -0
- data/examples/rails_example/bin/rake +6 -0
- data/examples/rails_example/bin/setup +35 -0
- data/examples/rails_example/config/application.rb +24 -0
- data/examples/rails_example/config/boot.rb +6 -0
- data/examples/rails_example/config/cable.yml +10 -0
- data/examples/rails_example/config/credentials.yml.enc +1 -0
- data/examples/rails_example/config/database.yml +25 -0
- data/examples/rails_example/config/environment.rb +7 -0
- data/examples/rails_example/config/environments/development.rb +72 -0
- data/examples/rails_example/config/environments/production.rb +95 -0
- data/examples/rails_example/config/environments/test.rb +62 -0
- data/examples/rails_example/config/importmap.rb +9 -0
- data/examples/rails_example/config/initializers/assets.rb +14 -0
- data/examples/rails_example/config/initializers/content_security_policy.rb +27 -0
- data/examples/rails_example/config/initializers/featurehub.rb +8 -0
- data/examples/rails_example/config/initializers/filter_parameter_logging.rb +10 -0
- data/examples/rails_example/config/initializers/inflections.rb +18 -0
- data/examples/rails_example/config/initializers/permissions_policy.rb +13 -0
- data/examples/rails_example/config/locales/en.yml +33 -0
- data/examples/rails_example/config/puma.rb +57 -0
- data/examples/rails_example/config/routes.rb +8 -0
- data/examples/rails_example/config/storage.yml +34 -0
- data/examples/rails_example/config.ru +8 -0
- data/examples/rails_example/db/seeds.rb +9 -0
- data/examples/rails_example/lib/assets/.keep +0 -0
- data/examples/rails_example/lib/tasks/.keep +0 -0
- data/examples/rails_example/log/.keep +0 -0
- data/examples/rails_example/public/404.html +67 -0
- data/examples/rails_example/public/422.html +67 -0
- data/examples/rails_example/public/500.html +66 -0
- data/examples/rails_example/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/rails_example/public/apple-touch-icon.png +0 -0
- data/examples/rails_example/public/favicon.ico +0 -0
- data/examples/rails_example/public/robots.txt +1 -0
- data/examples/rails_example/storage/.keep +0 -0
- data/examples/rails_example/test/application_system_test_case.rb +7 -0
- data/examples/rails_example/test/channels/application_cable/connection_test.rb +15 -0
- data/examples/rails_example/test/controllers/.keep +0 -0
- data/examples/rails_example/test/controllers/home_controller_test.rb +9 -0
- data/examples/rails_example/test/fixtures/files/.keep +0 -0
- data/examples/rails_example/test/helpers/.keep +0 -0
- data/examples/rails_example/test/integration/.keep +0 -0
- data/examples/rails_example/test/mailers/.keep +0 -0
- data/examples/rails_example/test/models/.keep +0 -0
- data/examples/rails_example/test/system/.keep +0 -0
- data/examples/rails_example/test/test_helper.rb +17 -0
- data/examples/rails_example/tmp/.keep +0 -0
- data/examples/rails_example/tmp/pids/.keep +0 -0
- data/examples/rails_example/tmp/storage/.keep +0 -0
- data/examples/rails_example/vendor/.keep +0 -0
- data/examples/rails_example/vendor/javascript/.keep +0 -0
- data/examples/sinatra/.gitignore +3 -0
- data/examples/sinatra/.ruby-version +1 -0
- data/examples/sinatra/Dockerfile +42 -0
- data/examples/sinatra/Gemfile +16 -0
- data/examples/sinatra/Gemfile.lock +86 -0
- data/examples/sinatra/README.adoc +10 -0
- data/examples/sinatra/app/application.rb +141 -0
- data/examples/sinatra/build.sh +2 -0
- data/examples/sinatra/conf/nginx.conf +57 -0
- data/examples/sinatra/conf/nsswitch.conf +21 -0
- data/examples/sinatra/config.ru +17 -0
- data/examples/sinatra/docker_start.sh +3 -0
- data/examples/sinatra/sinatra.iml +22 -0
- data/examples/sinatra/start.sh +3 -0
- data/examples/sinatra/thin.ru +9 -0
- data/featurehub-ruby-sdk.iml +9 -0
- data/featurehub-sdk.gemspec +42 -0
- data/lib/feature_hub/sdk/feature_hub_config.rb +0 -2
- data/lib/feature_hub/sdk/feature_repository.rb +1 -1
- data/lib/feature_hub/sdk/impl/rollout_holders.rb +3 -3
- data/lib/feature_hub/sdk/streaming_edge_service.rb +1 -1
- data/lib/feature_hub/sdk/version.rb +1 -1
- metadata +114 -13
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rack"
|
|
4
|
+
require "sinatra"
|
|
5
|
+
require "featurehub-sdk"
|
|
6
|
+
require "json"
|
|
7
|
+
|
|
8
|
+
def configure_featurehub
|
|
9
|
+
puts "FeatureHub SDK Version is #{FeatureHub::Sdk::VERSION}"
|
|
10
|
+
config = FeatureHub::Sdk::FeatureHubConfig.new(ENV.fetch("FEATUREHUB_EDGE_URL", "http://localhost:8903"),
|
|
11
|
+
[
|
|
12
|
+
ENV.fetch("FEATUREHUB_CLIENT_API_KEY",
|
|
13
|
+
"41ef6f5e-a70b-4ace-b6b5-8a3f1d636101/2PTj12Bn50Xn7Wt4yS9heBXtok3KGFAE9KW0Cms3") # rubocop:disable Layout/LineLength
|
|
14
|
+
])
|
|
15
|
+
config.use_polling_edge_service(1)
|
|
16
|
+
config.init
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
Todo = Struct.new(:id, :title, :resolved)
|
|
20
|
+
|
|
21
|
+
# sample app
|
|
22
|
+
class App < Sinatra::Base
|
|
23
|
+
# Middleware
|
|
24
|
+
# use Rack::CanonicalHost, ENV['CANONICAL_HOST']
|
|
25
|
+
configure do
|
|
26
|
+
rack = File.new("logs/rack.log", "a+")
|
|
27
|
+
use Rack::CommonLogger, rack
|
|
28
|
+
|
|
29
|
+
set :fh_config, configure_featurehub
|
|
30
|
+
set :users, {}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
before do
|
|
34
|
+
content_type "application/json"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Routes
|
|
38
|
+
# "resolve" a specific todo for this user
|
|
39
|
+
put("/todo/:user/:id/resolve") do
|
|
40
|
+
user = params["user"]
|
|
41
|
+
id = params["id"].to_s
|
|
42
|
+
todos = user_todos(user)
|
|
43
|
+
todo = todos.detect { |todo| todo.id.to_s == id }
|
|
44
|
+
todo&.resolved = true
|
|
45
|
+
todo_list(user)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# delete a specific todo for this user
|
|
49
|
+
delete("/todo/:user/:id") do
|
|
50
|
+
user = params["user"]
|
|
51
|
+
id = params["id"].to_s
|
|
52
|
+
todos = user_todos(user)
|
|
53
|
+
new_todos = todos.filter { |todo| todo.id.to_s != id }
|
|
54
|
+
settings.users[user] = new_todos
|
|
55
|
+
todo_list(user)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# delete a user
|
|
59
|
+
delete("/todo/:user") do
|
|
60
|
+
user = params["user"]
|
|
61
|
+
users = settings.users || {}
|
|
62
|
+
users[user] = []
|
|
63
|
+
status(204)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# add a user and the todo in the body
|
|
67
|
+
post("/todo/:user") do
|
|
68
|
+
user = params["user"]
|
|
69
|
+
todos = user_todos(user)
|
|
70
|
+
new_todo = JSON.parse(request.body.read)
|
|
71
|
+
if new_todo["title"].nil?
|
|
72
|
+
status(400)
|
|
73
|
+
else
|
|
74
|
+
todos.push(Todo.new(new_todo["id"] || 1, new_todo["title"], new_todo["resolved"] || false))
|
|
75
|
+
todo_list(user)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# get all the todos for this user
|
|
80
|
+
get("/todo/:user") do
|
|
81
|
+
todo_list(params["user"])
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
get("/health/readiness") do
|
|
85
|
+
if config.repository.ready?
|
|
86
|
+
"ok"
|
|
87
|
+
else
|
|
88
|
+
status(500)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
def todo_list(user)
|
|
95
|
+
ctx = settings.fh_config.new_context.user_key(user).build
|
|
96
|
+
todos = user_todos(user)
|
|
97
|
+
|
|
98
|
+
new_todos = []
|
|
99
|
+
|
|
100
|
+
todos.each do |todo|
|
|
101
|
+
new_todos.push(Todo.new(todo.id, process_title(ctx, todo.title), todo.resolved).to_h)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
new_todos.to_json
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def user_todos(user)
|
|
108
|
+
todos = settings.users[user] || []
|
|
109
|
+
settings.users[user] = todos
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def process_title(ctx, title)
|
|
113
|
+
new_title = title
|
|
114
|
+
|
|
115
|
+
new_title = "#{title} #{ctx.string("FEATURE_STRING")}" if ctx.set?("FEATURE_STRING") && title == "buy"
|
|
116
|
+
|
|
117
|
+
new_title = "#{title} #{ctx.number("FEATURE_NUMBER")}" if ctx.set?("FEATURE_NUMBER") && title == "pay"
|
|
118
|
+
|
|
119
|
+
if ctx.set?("FEATURE_JSON") && title == "find"
|
|
120
|
+
json = ctx.json("FEATURE_JSON")
|
|
121
|
+
new_title = if json.nil?
|
|
122
|
+
title.to_s
|
|
123
|
+
else
|
|
124
|
+
"#{title} #{json["foo"]}"
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
new_title = new_title.upcase if ctx.enabled?("FEATURE_TITLE_TO_UPPERCASE")
|
|
129
|
+
|
|
130
|
+
puts("features via repository: #{settings.fh_config.repository.features}")
|
|
131
|
+
puts("features via edge service: #{settings.fh_config.get_or_create_edge_service.repository}")
|
|
132
|
+
|
|
133
|
+
puts("enabled? #{ctx.repo.features}")
|
|
134
|
+
puts(ctx.enabled?("FEATURE_TITLE_TO_UPPERCASE"))
|
|
135
|
+
puts(ctx.flag("FEATURE_TITLE_TO_UPPERCASE"))
|
|
136
|
+
puts(settings.fh_config.repository.feature("FEATURE_TITLE_TO_UPPERCASE").feature_type)
|
|
137
|
+
puts(settings.fh_config.repository.feature("FEATURE_TITLE_TO_UPPERCASE").flag)
|
|
138
|
+
|
|
139
|
+
new_title&.strip
|
|
140
|
+
end
|
|
141
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
worker_processes 5;
|
|
2
|
+
env RACK_MULTIPART_PART_LIMIT=256;
|
|
3
|
+
error_log /dev/stderr;
|
|
4
|
+
|
|
5
|
+
include /etc/nginx/modules-enabled/*.conf;
|
|
6
|
+
|
|
7
|
+
events {
|
|
8
|
+
worker_connections 1024;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
http {
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
passenger_user_switching on;
|
|
15
|
+
passenger_user root;
|
|
16
|
+
passenger_default_user root;
|
|
17
|
+
|
|
18
|
+
passenger_max_pool_size 6;
|
|
19
|
+
|
|
20
|
+
passenger_disable_security_update_check on;
|
|
21
|
+
passenger_disable_anonymous_telemetry on;
|
|
22
|
+
|
|
23
|
+
include /etc/nginx/conf/vhosts/*.conf;
|
|
24
|
+
include /etc/nginx/conf.d/*.conf;
|
|
25
|
+
|
|
26
|
+
include mime.types;
|
|
27
|
+
default_type application/octet-stream;
|
|
28
|
+
|
|
29
|
+
sendfile on;
|
|
30
|
+
|
|
31
|
+
keepalive_timeout 65;
|
|
32
|
+
server {
|
|
33
|
+
access_log /dev/stdout;
|
|
34
|
+
listen 8099 default_server;
|
|
35
|
+
server_name localhost;
|
|
36
|
+
root /app/featurehub;
|
|
37
|
+
passenger_app_root /app/featurehub;
|
|
38
|
+
passenger_enabled on;
|
|
39
|
+
passenger_startup_file config.ru;
|
|
40
|
+
passenger_app_type rack;
|
|
41
|
+
|
|
42
|
+
client_max_body_size 50M;
|
|
43
|
+
|
|
44
|
+
error_page 500 502 503 504 /50x.html;
|
|
45
|
+
location = /50x.html {
|
|
46
|
+
root html;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
location /nginx_status {
|
|
50
|
+
stub_status on;
|
|
51
|
+
access_log off;
|
|
52
|
+
allow 127.0.0.1;
|
|
53
|
+
allow 10.0.0.0/8;
|
|
54
|
+
deny all;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# /etc/nsswitch.conf
|
|
2
|
+
#
|
|
3
|
+
# Example configuration of GNU Name Service Switch functionality.
|
|
4
|
+
# If you have the `glibc-doc-reference' and `info' packages installed, try:
|
|
5
|
+
# `info libc "Name Service Switch"' for information about this file.
|
|
6
|
+
|
|
7
|
+
passwd: compat extrausers
|
|
8
|
+
group: compat extrausers
|
|
9
|
+
shadow: compat extrausers
|
|
10
|
+
gshadow: files
|
|
11
|
+
|
|
12
|
+
hosts: files dns
|
|
13
|
+
networks: files
|
|
14
|
+
|
|
15
|
+
protocols: db files
|
|
16
|
+
services: db files
|
|
17
|
+
ethers: db files
|
|
18
|
+
rpc: db files
|
|
19
|
+
|
|
20
|
+
netgroup: nis
|
|
21
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "app/application"
|
|
4
|
+
|
|
5
|
+
require "bundler"
|
|
6
|
+
Bundler.setup(:default)
|
|
7
|
+
|
|
8
|
+
if defined?(PhusionPassenger)
|
|
9
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
|
10
|
+
if forked
|
|
11
|
+
puts("process forking, create a new edge instance #{App.settings}")
|
|
12
|
+
App.settings.fh_config.force_new_edge_service
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
run App
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="jdk" jdkName="rbenv: 3.0.6" jdkType="RUBY_SDK" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.10, rbenv: 3.0.6) [gem]" level="application" />
|
|
9
|
+
<orderEntry type="library" scope="PROVIDED" name="domain_name (v0.5.20190701, rbenv: 3.0.6) [gem]" level="application" />
|
|
10
|
+
<orderEntry type="library" scope="PROVIDED" name="eventmachine (v1.2.7, rbenv: 3.0.6) [gem]" level="application" />
|
|
11
|
+
<orderEntry type="library" scope="PROVIDED" name="ffi (v1.15.5, rbenv: 3.0.6) [gem]" level="application" />
|
|
12
|
+
<orderEntry type="library" scope="PROVIDED" name="ffi-compiler (v1.0.1, rbenv: 3.0.6) [gem]" level="application" />
|
|
13
|
+
<orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.5, rbenv: 3.0.6) [gem]" level="application" />
|
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="http-form_data (v2.3.0, rbenv: 3.0.6) [gem]" level="application" />
|
|
15
|
+
<orderEntry type="library" scope="PROVIDED" name="llhttp-ffi (v0.4.0, rbenv: 3.0.6) [gem]" level="application" />
|
|
16
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, rbenv: 3.0.6) [gem]" level="application" />
|
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="ruby2_keywords (v0.0.5, rbenv: 3.0.6) [gem]" level="application" />
|
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="sem_version (v2.0.1, rbenv: 3.0.6) [gem]" level="application" />
|
|
19
|
+
<orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, rbenv: 3.0.6) [gem]" level="application" />
|
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.8.2, rbenv: 3.0.6) [gem]" level="application" />
|
|
21
|
+
</component>
|
|
22
|
+
</module>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require "feature_hub/sdk/version"
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "featurehub-sdk"
|
|
9
|
+
spec.version = FeatureHub::Sdk::VERSION
|
|
10
|
+
spec.authors = ["Richard Vowles", "Irina Southwell"]
|
|
11
|
+
spec.email = ["richard@bluetrainsoftware.com"]
|
|
12
|
+
|
|
13
|
+
spec.summary = "FeatureHub Ruby SDK"
|
|
14
|
+
spec.description = "FeatureHub Ruby SDK"
|
|
15
|
+
spec.homepage = "https://www.featurehub.io"
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
spec.required_ruby_version = ">= 3.2.0"
|
|
18
|
+
|
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
20
|
+
|
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
22
|
+
spec.metadata["source_code_uri"] = "https://github.com/featurehub-io/featurehub-ruby-sdk"
|
|
23
|
+
spec.metadata["changelog_uri"] = "https://github.com/featurehub-io/featurehub-ruby-sdk/featurehub-sdk/CHANGELOG.md"
|
|
24
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
25
|
+
|
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
28
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
29
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
30
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
spec.bindir = "exe"
|
|
34
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
35
|
+
spec.require_paths = ["lib"]
|
|
36
|
+
|
|
37
|
+
spec.add_dependency "concurrent-ruby", "~> 1.3"
|
|
38
|
+
spec.add_dependency "faraday", "~> 2"
|
|
39
|
+
spec.add_dependency "ld-eventsource", "~> 2.3.0"
|
|
40
|
+
spec.add_dependency "murmurhash3", "~> 0.1.7"
|
|
41
|
+
spec.add_dependency "sem_version", "~> 2.0.0"
|
|
42
|
+
end
|
|
@@ -110,14 +110,12 @@ module FeatureHub
|
|
|
110
110
|
FeatureHub::Sdk::StreamingEdgeService.new(repo, api_keys, edge_url, logger)
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
-
# rubocop:disable Style/GuardClause
|
|
114
113
|
def detect_client_evaluated(api_keys)
|
|
115
114
|
@client_evaluated = !api_keys.detect { |k| k.include?("*") }.nil?
|
|
116
115
|
if api_keys.detect { |k| (@client_evaluated && !k.include?("*")) || (!@client_evaluated && k.include?("*")) }
|
|
117
116
|
raise "api keys must all be of one type"
|
|
118
117
|
end
|
|
119
118
|
end
|
|
120
|
-
# rubocop:enable Style/GuardClause
|
|
121
119
|
|
|
122
120
|
def parse_edge_url(edge_url)
|
|
123
121
|
if edge_url[-1] == "/"
|
|
@@ -50,7 +50,7 @@ module FeatureHub
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def find_interceptor(feature_value)
|
|
53
|
-
@interceptors.
|
|
53
|
+
@interceptors.filter_map { |interceptor| interceptor.intercepted_value(feature_value) }.first
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def ready?
|
|
@@ -73,11 +73,11 @@ module FeatureHub
|
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def float_values
|
|
76
|
-
@values.
|
|
76
|
+
@values.compact.map(&:to_f)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def str_values
|
|
80
|
-
@values.
|
|
80
|
+
@values.compact.map(&:to_s)
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
def to_s
|
|
@@ -96,7 +96,7 @@ module FeatureHub
|
|
|
96
96
|
@id = strategy["id"]
|
|
97
97
|
@name = strategy["name"]
|
|
98
98
|
@percentage = (strategy["percentage"] || "0").to_i
|
|
99
|
-
@percentage_attributes =
|
|
99
|
+
@percentage_attributes = strategy["percentageAttributes"] || []
|
|
100
100
|
@value = strategy["value"]
|
|
101
101
|
end
|
|
102
102
|
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: featurehub-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Richard Vowles
|
|
8
8
|
- Irina Southwell
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: exe
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: concurrent-ruby
|
|
@@ -17,14 +16,14 @@ dependencies:
|
|
|
17
16
|
requirements:
|
|
18
17
|
- - "~>"
|
|
19
18
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '1.
|
|
19
|
+
version: '1.3'
|
|
21
20
|
type: :runtime
|
|
22
21
|
prerelease: false
|
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
23
|
requirements:
|
|
25
24
|
- - "~>"
|
|
26
25
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: '1.
|
|
26
|
+
version: '1.3'
|
|
28
27
|
- !ruby/object:Gem::Dependency
|
|
29
28
|
name: faraday
|
|
30
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -45,28 +44,28 @@ dependencies:
|
|
|
45
44
|
requirements:
|
|
46
45
|
- - "~>"
|
|
47
46
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: 2.
|
|
47
|
+
version: 2.3.0
|
|
49
48
|
type: :runtime
|
|
50
49
|
prerelease: false
|
|
51
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
52
51
|
requirements:
|
|
53
52
|
- - "~>"
|
|
54
53
|
- !ruby/object:Gem::Version
|
|
55
|
-
version: 2.
|
|
54
|
+
version: 2.3.0
|
|
56
55
|
- !ruby/object:Gem::Dependency
|
|
57
56
|
name: murmurhash3
|
|
58
57
|
requirement: !ruby/object:Gem::Requirement
|
|
59
58
|
requirements:
|
|
60
59
|
- - "~>"
|
|
61
60
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: 0.1.
|
|
61
|
+
version: 0.1.7
|
|
63
62
|
type: :runtime
|
|
64
63
|
prerelease: false
|
|
65
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
65
|
requirements:
|
|
67
66
|
- - "~>"
|
|
68
67
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: 0.1.
|
|
68
|
+
version: 0.1.7
|
|
70
69
|
- !ruby/object:Gem::Dependency
|
|
71
70
|
name: sem_version
|
|
72
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -95,8 +94,112 @@ files:
|
|
|
95
94
|
- CODE_OF_CONDUCT.md
|
|
96
95
|
- Gemfile
|
|
97
96
|
- Gemfile.lock
|
|
97
|
+
- LICENSE
|
|
98
98
|
- LICENSE.txt
|
|
99
|
+
- README.md
|
|
99
100
|
- Rakefile
|
|
101
|
+
- examples/rails_example/.env.example
|
|
102
|
+
- examples/rails_example/.gitattributes
|
|
103
|
+
- examples/rails_example/.gitignore
|
|
104
|
+
- examples/rails_example/.ruby-version
|
|
105
|
+
- examples/rails_example/Dockerfile
|
|
106
|
+
- examples/rails_example/Gemfile
|
|
107
|
+
- examples/rails_example/Gemfile.lock
|
|
108
|
+
- examples/rails_example/README.md
|
|
109
|
+
- examples/rails_example/Rakefile
|
|
110
|
+
- examples/rails_example/app/assets/config/manifest.js
|
|
111
|
+
- examples/rails_example/app/assets/images/.keep
|
|
112
|
+
- examples/rails_example/app/assets/stylesheets/application.css
|
|
113
|
+
- examples/rails_example/app/channels/application_cable/channel.rb
|
|
114
|
+
- examples/rails_example/app/channels/application_cable/connection.rb
|
|
115
|
+
- examples/rails_example/app/controllers/application_controller.rb
|
|
116
|
+
- examples/rails_example/app/controllers/concerns/.keep
|
|
117
|
+
- examples/rails_example/app/controllers/home_controller.rb
|
|
118
|
+
- examples/rails_example/app/helpers/application_helper.rb
|
|
119
|
+
- examples/rails_example/app/helpers/home_helper.rb
|
|
120
|
+
- examples/rails_example/app/javascript/application.js
|
|
121
|
+
- examples/rails_example/app/javascript/controllers/application.js
|
|
122
|
+
- examples/rails_example/app/javascript/controllers/hello_controller.js
|
|
123
|
+
- examples/rails_example/app/javascript/controllers/index.js
|
|
124
|
+
- examples/rails_example/app/jobs/application_job.rb
|
|
125
|
+
- examples/rails_example/app/mailers/application_mailer.rb
|
|
126
|
+
- examples/rails_example/app/models/application_record.rb
|
|
127
|
+
- examples/rails_example/app/models/concerns/.keep
|
|
128
|
+
- examples/rails_example/app/views/home/index.html.erb
|
|
129
|
+
- examples/rails_example/app/views/layouts/application.html.erb
|
|
130
|
+
- examples/rails_example/app/views/layouts/mailer.html.erb
|
|
131
|
+
- examples/rails_example/app/views/layouts/mailer.text.erb
|
|
132
|
+
- examples/rails_example/bin/bundle
|
|
133
|
+
- examples/rails_example/bin/importmap
|
|
134
|
+
- examples/rails_example/bin/rails
|
|
135
|
+
- examples/rails_example/bin/rake
|
|
136
|
+
- examples/rails_example/bin/setup
|
|
137
|
+
- examples/rails_example/config.ru
|
|
138
|
+
- examples/rails_example/config/application.rb
|
|
139
|
+
- examples/rails_example/config/boot.rb
|
|
140
|
+
- examples/rails_example/config/cable.yml
|
|
141
|
+
- examples/rails_example/config/credentials.yml.enc
|
|
142
|
+
- examples/rails_example/config/database.yml
|
|
143
|
+
- examples/rails_example/config/environment.rb
|
|
144
|
+
- examples/rails_example/config/environments/development.rb
|
|
145
|
+
- examples/rails_example/config/environments/production.rb
|
|
146
|
+
- examples/rails_example/config/environments/test.rb
|
|
147
|
+
- examples/rails_example/config/importmap.rb
|
|
148
|
+
- examples/rails_example/config/initializers/assets.rb
|
|
149
|
+
- examples/rails_example/config/initializers/content_security_policy.rb
|
|
150
|
+
- examples/rails_example/config/initializers/featurehub.rb
|
|
151
|
+
- examples/rails_example/config/initializers/filter_parameter_logging.rb
|
|
152
|
+
- examples/rails_example/config/initializers/inflections.rb
|
|
153
|
+
- examples/rails_example/config/initializers/permissions_policy.rb
|
|
154
|
+
- examples/rails_example/config/locales/en.yml
|
|
155
|
+
- examples/rails_example/config/puma.rb
|
|
156
|
+
- examples/rails_example/config/routes.rb
|
|
157
|
+
- examples/rails_example/config/storage.yml
|
|
158
|
+
- examples/rails_example/db/seeds.rb
|
|
159
|
+
- examples/rails_example/lib/assets/.keep
|
|
160
|
+
- examples/rails_example/lib/tasks/.keep
|
|
161
|
+
- examples/rails_example/log/.keep
|
|
162
|
+
- examples/rails_example/public/404.html
|
|
163
|
+
- examples/rails_example/public/422.html
|
|
164
|
+
- examples/rails_example/public/500.html
|
|
165
|
+
- examples/rails_example/public/apple-touch-icon-precomposed.png
|
|
166
|
+
- examples/rails_example/public/apple-touch-icon.png
|
|
167
|
+
- examples/rails_example/public/favicon.ico
|
|
168
|
+
- examples/rails_example/public/robots.txt
|
|
169
|
+
- examples/rails_example/storage/.keep
|
|
170
|
+
- examples/rails_example/test/application_system_test_case.rb
|
|
171
|
+
- examples/rails_example/test/channels/application_cable/connection_test.rb
|
|
172
|
+
- examples/rails_example/test/controllers/.keep
|
|
173
|
+
- examples/rails_example/test/controllers/home_controller_test.rb
|
|
174
|
+
- examples/rails_example/test/fixtures/files/.keep
|
|
175
|
+
- examples/rails_example/test/helpers/.keep
|
|
176
|
+
- examples/rails_example/test/integration/.keep
|
|
177
|
+
- examples/rails_example/test/mailers/.keep
|
|
178
|
+
- examples/rails_example/test/models/.keep
|
|
179
|
+
- examples/rails_example/test/system/.keep
|
|
180
|
+
- examples/rails_example/test/test_helper.rb
|
|
181
|
+
- examples/rails_example/tmp/.keep
|
|
182
|
+
- examples/rails_example/tmp/pids/.keep
|
|
183
|
+
- examples/rails_example/tmp/storage/.keep
|
|
184
|
+
- examples/rails_example/vendor/.keep
|
|
185
|
+
- examples/rails_example/vendor/javascript/.keep
|
|
186
|
+
- examples/sinatra/.gitignore
|
|
187
|
+
- examples/sinatra/.ruby-version
|
|
188
|
+
- examples/sinatra/Dockerfile
|
|
189
|
+
- examples/sinatra/Gemfile
|
|
190
|
+
- examples/sinatra/Gemfile.lock
|
|
191
|
+
- examples/sinatra/README.adoc
|
|
192
|
+
- examples/sinatra/app/application.rb
|
|
193
|
+
- examples/sinatra/build.sh
|
|
194
|
+
- examples/sinatra/conf/nginx.conf
|
|
195
|
+
- examples/sinatra/conf/nsswitch.conf
|
|
196
|
+
- examples/sinatra/config.ru
|
|
197
|
+
- examples/sinatra/docker_start.sh
|
|
198
|
+
- examples/sinatra/sinatra.iml
|
|
199
|
+
- examples/sinatra/start.sh
|
|
200
|
+
- examples/sinatra/thin.ru
|
|
201
|
+
- featurehub-ruby-sdk.iml
|
|
202
|
+
- featurehub-sdk.gemspec
|
|
100
203
|
- featurehub-sdk.iml
|
|
101
204
|
- lib/feature_hub/sdk/context.rb
|
|
102
205
|
- lib/feature_hub/sdk/feature_hub_config.rb
|
|
@@ -124,7 +227,6 @@ metadata:
|
|
|
124
227
|
source_code_uri: https://github.com/featurehub-io/featurehub-ruby-sdk
|
|
125
228
|
changelog_uri: https://github.com/featurehub-io/featurehub-ruby-sdk/featurehub-sdk/CHANGELOG.md
|
|
126
229
|
rubygems_mfa_required: 'true'
|
|
127
|
-
post_install_message:
|
|
128
230
|
rdoc_options: []
|
|
129
231
|
require_paths:
|
|
130
232
|
- lib
|
|
@@ -132,15 +234,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
132
234
|
requirements:
|
|
133
235
|
- - ">="
|
|
134
236
|
- !ruby/object:Gem::Version
|
|
135
|
-
version: 2.
|
|
237
|
+
version: 3.2.0
|
|
136
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
239
|
requirements:
|
|
138
240
|
- - ">="
|
|
139
241
|
- !ruby/object:Gem::Version
|
|
140
242
|
version: '0'
|
|
141
243
|
requirements: []
|
|
142
|
-
rubygems_version:
|
|
143
|
-
signing_key:
|
|
244
|
+
rubygems_version: 4.0.3
|
|
144
245
|
specification_version: 4
|
|
145
246
|
summary: FeatureHub Ruby SDK
|
|
146
247
|
test_files: []
|