prefab-cloud-ruby 0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.envrc.sample +3 -0
- data/.github/workflows/ruby.yml +46 -0
- data/.gitmodules +3 -0
- data/.rubocop.yml +13 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +169 -0
- data/CODEOWNERS +1 -0
- data/Gemfile +26 -0
- data/Gemfile.lock +188 -0
- data/LICENSE.txt +20 -0
- data/README.md +94 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/bin/console +21 -0
- data/compile_protos.sh +18 -0
- data/lib/prefab/client.rb +153 -0
- data/lib/prefab/config_client.rb +292 -0
- data/lib/prefab/config_client_presenter.rb +18 -0
- data/lib/prefab/config_loader.rb +84 -0
- data/lib/prefab/config_resolver.rb +77 -0
- data/lib/prefab/config_value_unwrapper.rb +115 -0
- data/lib/prefab/config_value_wrapper.rb +18 -0
- data/lib/prefab/context.rb +179 -0
- data/lib/prefab/context_shape.rb +20 -0
- data/lib/prefab/context_shape_aggregator.rb +65 -0
- data/lib/prefab/criteria_evaluator.rb +136 -0
- data/lib/prefab/encryption.rb +65 -0
- data/lib/prefab/error.rb +6 -0
- data/lib/prefab/errors/env_var_parse_error.rb +11 -0
- data/lib/prefab/errors/initialization_timeout_error.rb +13 -0
- data/lib/prefab/errors/invalid_api_key_error.rb +19 -0
- data/lib/prefab/errors/missing_default_error.rb +13 -0
- data/lib/prefab/errors/missing_env_var_error.rb +11 -0
- data/lib/prefab/errors/uninitialized_error.rb +13 -0
- data/lib/prefab/evaluation.rb +52 -0
- data/lib/prefab/evaluation_summary_aggregator.rb +87 -0
- data/lib/prefab/example_contexts_aggregator.rb +78 -0
- data/lib/prefab/exponential_backoff.rb +21 -0
- data/lib/prefab/feature_flag_client.rb +42 -0
- data/lib/prefab/http_connection.rb +41 -0
- data/lib/prefab/internal_logger.rb +16 -0
- data/lib/prefab/local_config_parser.rb +151 -0
- data/lib/prefab/log_path_aggregator.rb +69 -0
- data/lib/prefab/logger_client.rb +264 -0
- data/lib/prefab/murmer3.rb +50 -0
- data/lib/prefab/options.rb +208 -0
- data/lib/prefab/periodic_sync.rb +69 -0
- data/lib/prefab/prefab.rb +56 -0
- data/lib/prefab/rate_limit_cache.rb +41 -0
- data/lib/prefab/resolved_config_presenter.rb +86 -0
- data/lib/prefab/time_helpers.rb +7 -0
- data/lib/prefab/weighted_value_resolver.rb +42 -0
- data/lib/prefab/yaml_config_parser.rb +34 -0
- data/lib/prefab-cloud-ruby.rb +57 -0
- data/lib/prefab_pb.rb +93 -0
- data/prefab-cloud-ruby.gemspec +155 -0
- data/test/.prefab.default.config.yaml +2 -0
- data/test/.prefab.unit_tests.config.yaml +28 -0
- data/test/integration_test.rb +150 -0
- data/test/integration_test_helpers.rb +151 -0
- data/test/support/common_helpers.rb +180 -0
- data/test/support/mock_base_client.rb +42 -0
- data/test/support/mock_config_client.rb +19 -0
- data/test/support/mock_config_loader.rb +1 -0
- data/test/test_client.rb +444 -0
- data/test/test_config_client.rb +109 -0
- data/test/test_config_loader.rb +117 -0
- data/test/test_config_resolver.rb +430 -0
- data/test/test_config_value_unwrapper.rb +224 -0
- data/test/test_config_value_wrapper.rb +42 -0
- data/test/test_context.rb +203 -0
- data/test/test_context_shape.rb +50 -0
- data/test/test_context_shape_aggregator.rb +147 -0
- data/test/test_criteria_evaluator.rb +726 -0
- data/test/test_encryption.rb +16 -0
- data/test/test_evaluation_summary_aggregator.rb +162 -0
- data/test/test_example_contexts_aggregator.rb +238 -0
- data/test/test_exponential_backoff.rb +18 -0
- data/test/test_feature_flag_client.rb +48 -0
- data/test/test_helper.rb +17 -0
- data/test/test_integration.rb +58 -0
- data/test/test_local_config_parser.rb +147 -0
- data/test/test_log_path_aggregator.rb +62 -0
- data/test/test_logger.rb +621 -0
- data/test/test_logger_initialization.rb +12 -0
- data/test/test_options.rb +75 -0
- data/test/test_prefab.rb +12 -0
- data/test/test_rate_limit_cache.rb +44 -0
- data/test/test_weighted_value_resolver.rb +71 -0
- metadata +337 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1aa20885e129588b6ccf76b4fddae442b7d285495a384d3e4d2aeba11b802089
|
4
|
+
data.tar.gz: 37bd9186041e1931d00f4a5c9fd518f7961a1564147b8693f03befdd9dc78dc9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1de0d80c388ceb6a68d65da6b4998c1e2a398664e3a9d04f4fce4fd8943176638f53c5b89a903d75449039fd1de713595eafeb930f3108f0fee59cdd35d176de
|
7
|
+
data.tar.gz: 917f146a34fa76b8440d126ebceff1d0bd79c7944135142b944389d259ab10295b9b80937832dd6438a7a2e38e276a546f2f96bd7638427996a46ec0646324f6
|
data/.envrc.sample
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ "main" ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ "main" ]
|
15
|
+
|
16
|
+
permissions:
|
17
|
+
contents: read
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
test:
|
21
|
+
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
strategy:
|
24
|
+
matrix:
|
25
|
+
ruby-version: ['2.7', '3.0', '3.1']
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
with:
|
30
|
+
submodules: recursive
|
31
|
+
- name: Set up Ruby
|
32
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
33
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
34
|
+
# uses: ruby/setup-ruby@v1
|
35
|
+
# uses: ruby/setup-ruby@2b019609e2b0f1ea1a2bc8ca11cb82ab46ada124
|
36
|
+
uses: ruby/setup-ruby@v1
|
37
|
+
with:
|
38
|
+
ruby-version: ${{ matrix.ruby-version }}
|
39
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
40
|
+
- name: Run tests
|
41
|
+
run: bundle exec rake
|
42
|
+
env:
|
43
|
+
PREFAB_INTEGRATION_TEST_API_KEY: ${{ secrets.PREFAB_INTEGRATION_TEST_API_KEY }}
|
44
|
+
PREFAB_INTEGRATION_TEST_ENCRYPTION_KEY: ${{ secrets.PREFAB_INTEGRATION_TEST_ENCRYPTION_KEY }}
|
45
|
+
NOT_A_NUMBER: "abcd"
|
46
|
+
IS_A_NUMBER: "1234"
|
data/.gitmodules
ADDED
data/.rubocop.yml
ADDED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.0.3
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 1.5.0 - 2024-02-12
|
4
|
+
|
5
|
+
- Fix potential inconsistent Context behavior (#172)
|
6
|
+
|
7
|
+
## 1.4.5 - 2024-01-31
|
8
|
+
|
9
|
+
- Refactor out a `should_log?` method (#170)
|
10
|
+
|
11
|
+
## 1.4.4 - 2024-01-26
|
12
|
+
|
13
|
+
- Raise when ENV var is missing
|
14
|
+
|
15
|
+
## 1.4.3 - 2024-01-17
|
16
|
+
|
17
|
+
- Updated proto definition file
|
18
|
+
|
19
|
+
## 1.4.2 - 2023-12-14
|
20
|
+
|
21
|
+
- Use reportable value even for invalid data (#166)
|
22
|
+
|
23
|
+
## 1.4.1 - 2023-12-08
|
24
|
+
|
25
|
+
- Include version in `get` request (#165)
|
26
|
+
|
27
|
+
## 1.4.0 - 2023-11-28
|
28
|
+
|
29
|
+
- ActiveJob tagged logger issue (#164)
|
30
|
+
- Compact Log Format (#163)
|
31
|
+
- Tagged Logging (#161)
|
32
|
+
- ContextKey logging thread safety (#162)
|
33
|
+
|
34
|
+
## 1.3.2 - 2023-11-15
|
35
|
+
|
36
|
+
- Send back cloud.prefab logging telemetry (#160)
|
37
|
+
|
38
|
+
## 1.3.1 - 2023-11-14
|
39
|
+
|
40
|
+
- Improve path of rails.controller logging & fix strong param include (#159)
|
41
|
+
|
42
|
+
## 1.3.0 - 2023-11-13
|
43
|
+
|
44
|
+
- Less logging when wifi is off and we load from cache (#157)
|
45
|
+
- Alpha: Add Provided & Secret Support (#152)
|
46
|
+
- Alpha: x_datafile (#156)
|
47
|
+
- Add single line action-controller output under rails.controller (#158)
|
48
|
+
|
49
|
+
## 1.2.1 - 2023-11-01
|
50
|
+
|
51
|
+
- Update protobuf definitions (#154)
|
52
|
+
|
53
|
+
## 1.2.0 - 2023-10-30
|
54
|
+
|
55
|
+
- Add `Prefab.get('key')` style usage after a `Prefab.init()` call (#151)
|
56
|
+
- Add `add_context_keys` and `with_context_keys` method for LoggerClient (#145)
|
57
|
+
|
58
|
+
## 1.1.2 - 2023-10-13
|
59
|
+
|
60
|
+
- Add `cloud.prefab.client.criteria_evaluator` `debug` logging of evaluations (#150)
|
61
|
+
- Add `x_use_local_cache` for local caching (#148)
|
62
|
+
- Tests run in RubyMine (#147)
|
63
|
+
|
64
|
+
## 1.1.1 - 2023-10-11
|
65
|
+
|
66
|
+
- Migrate happy-path client-initialization logging to `DEBUG` level rather than `INFO` (#144)
|
67
|
+
- Add `ConfigClientPresenter` for logging out stats upon successful client initialization (#144)
|
68
|
+
- Add support for default context (#146)
|
69
|
+
|
70
|
+
## 1.1.0 - 2023-09-18
|
71
|
+
|
72
|
+
- Add support for structured logging (#143)
|
73
|
+
- Ability to pass a hash of key/value context pairs to any of the user-facing log methods
|
74
|
+
|
75
|
+
## 1.0.1 - 2023-08-17
|
76
|
+
|
77
|
+
- Bug fix for StringList w/ ExampleContextsAggregator (#141)
|
78
|
+
|
79
|
+
## 1.0.0 - 2023-08-10
|
80
|
+
|
81
|
+
- Removed EvaluatedKeysAggregator (#137)
|
82
|
+
- Change `collect_evaluation_summaries` default to true (#136)
|
83
|
+
- Removed some backwards compatibility shims (#133)
|
84
|
+
- Standardizing options (#132)
|
85
|
+
- Note that the default value for `context_upload_mode` is `:periodic_example` which means example contexts will be collected.
|
86
|
+
This enables easy variant override assignment in our UI. More at https://prefab.cloud/blog/feature-flag-variant-assignment/
|
87
|
+
|
88
|
+
## 0.24.6 - 2023-07-31
|
89
|
+
|
90
|
+
- Logger Client compatibility (#129)
|
91
|
+
- Replace EvaluatedConfigs with ExampleContexts (#128)
|
92
|
+
- Add ConfigEvaluationSummaries (opt-in for now) (#123)
|
93
|
+
|
94
|
+
## 0.24.5 - 2023-07-10
|
95
|
+
|
96
|
+
- Report Client Version (#121)
|
97
|
+
|
98
|
+
## [0.24.4] - 2023-07-06
|
99
|
+
|
100
|
+
- Support Timed Loggers (#119)
|
101
|
+
- Added EvaluatedConfigsAggregator (disabled by default) (#118)
|
102
|
+
- Added EvaluatedKeysAggregator (disabled by default) (#117)
|
103
|
+
- Dropped Ruby 2.6 support (#116)
|
104
|
+
- Capture/report context shapes (#115)
|
105
|
+
- Added bin/console (#114)
|
106
|
+
|
107
|
+
## [0.24.3] - 2023-05-15
|
108
|
+
|
109
|
+
- Add JSON log formatter (#106)
|
110
|
+
|
111
|
+
# [0.24.2] - 2023-05-12
|
112
|
+
|
113
|
+
- Fix bug in FF rollout eval consistency (#108)
|
114
|
+
- Simplify forking (#107)
|
115
|
+
|
116
|
+
# [0.24.1] - 2023-04-26
|
117
|
+
|
118
|
+
- Fix misleading deprecation warning (#105)
|
119
|
+
|
120
|
+
# [0.24.0] - 2023-04-26
|
121
|
+
|
122
|
+
- Backwards compatibility for JIT context (#104)
|
123
|
+
- Remove upsert (#103)
|
124
|
+
- Add resolver presenter and `on_update` callback (#102)
|
125
|
+
- Deprecate `lookup_key` and introduce Context (#99)
|
126
|
+
|
127
|
+
# [0.23.8] - 2023-04-21
|
128
|
+
|
129
|
+
- Update protobuf (#101)
|
130
|
+
|
131
|
+
# [0.23.7] - 2023-04-21
|
132
|
+
|
133
|
+
- Guard against ActiveJob not being loaded (#100)
|
134
|
+
|
135
|
+
# [0.23.6] - 2023-04-17
|
136
|
+
|
137
|
+
- Fix bug in FF rollout eval consistency (#98)
|
138
|
+
- Add tests for block-form of logging (#96)
|
139
|
+
|
140
|
+
# [0.23.5] - 2023-04-13
|
141
|
+
|
142
|
+
- Cast the value to string when checking presence in string list (#95)
|
143
|
+
|
144
|
+
# [0.23.4] - 2023-04-12
|
145
|
+
|
146
|
+
- Remove GRPC (#93)
|
147
|
+
|
148
|
+
# [0.23.3] - 2023-04-07
|
149
|
+
|
150
|
+
- Use exponential backoff for log level uploading (#92)
|
151
|
+
|
152
|
+
# [0.23.2] - 2023-04-04
|
153
|
+
|
154
|
+
- Move log collection logs from INFO to DEBUG (#91)
|
155
|
+
- Fix: Handle trailing slash in PREFAB_API_URL (#90)
|
156
|
+
|
157
|
+
# [0.23.1] - 2023-03-30
|
158
|
+
|
159
|
+
- ActiveStorage not defined in Rails < 5.2 (#87)
|
160
|
+
|
161
|
+
# [0.23.0] - 2023-03-28
|
162
|
+
|
163
|
+
- Convenience for setting Rails.logger (#85)
|
164
|
+
- Log evaluation according to rules (#81)
|
165
|
+
|
166
|
+
# [0.22.0] - 2023-03-15
|
167
|
+
|
168
|
+
- Report log paths and usages (#79)
|
169
|
+
- Accept hash or keyword args in `initialize` (#78)
|
data/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @prefab-cloud/prefabdevs @prefab-cloud/prefabmaintainers @prefab-cloud/prefabadmins
|
data/Gemfile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'concurrent-ruby', '~> 1.0', '>= 1.0.5'
|
4
|
+
gem 'faraday'
|
5
|
+
gem 'googleapis-common-protos-types', platforms: :ruby
|
6
|
+
gem 'google-protobuf', platforms: :ruby
|
7
|
+
gem 'ld-eventsource'
|
8
|
+
gem 'uuid'
|
9
|
+
|
10
|
+
gem 'activesupport', '>= 4'
|
11
|
+
gem 'actionpack', '>= 4'
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem 'benchmark-ips'
|
15
|
+
gem 'bundler'
|
16
|
+
gem 'juwelier', '~> 2.4.9'
|
17
|
+
gem 'rdoc'
|
18
|
+
gem 'simplecov', '>= 0'
|
19
|
+
end
|
20
|
+
|
21
|
+
group :test do
|
22
|
+
gem 'minitest'
|
23
|
+
gem 'minitest-focus'
|
24
|
+
gem 'minitest-reporters'
|
25
|
+
gem 'timecop'
|
26
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionpack (7.1.2)
|
5
|
+
actionview (= 7.1.2)
|
6
|
+
activesupport (= 7.1.2)
|
7
|
+
nokogiri (>= 1.8.5)
|
8
|
+
racc
|
9
|
+
rack (>= 2.2.4)
|
10
|
+
rack-session (>= 1.0.1)
|
11
|
+
rack-test (>= 0.6.3)
|
12
|
+
rails-dom-testing (~> 2.2)
|
13
|
+
rails-html-sanitizer (~> 1.6)
|
14
|
+
actionview (7.1.2)
|
15
|
+
activesupport (= 7.1.2)
|
16
|
+
builder (~> 3.1)
|
17
|
+
erubi (~> 1.11)
|
18
|
+
rails-dom-testing (~> 2.2)
|
19
|
+
rails-html-sanitizer (~> 1.6)
|
20
|
+
activesupport (7.1.2)
|
21
|
+
base64
|
22
|
+
bigdecimal
|
23
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
24
|
+
connection_pool (>= 2.2.5)
|
25
|
+
drb
|
26
|
+
i18n (>= 1.6, < 2)
|
27
|
+
minitest (>= 5.1)
|
28
|
+
mutex_m
|
29
|
+
tzinfo (~> 2.0)
|
30
|
+
addressable (2.8.0)
|
31
|
+
public_suffix (>= 2.0.2, < 5.0)
|
32
|
+
ansi (1.5.0)
|
33
|
+
base64 (0.2.0)
|
34
|
+
benchmark-ips (2.10.0)
|
35
|
+
bigdecimal (3.1.4)
|
36
|
+
builder (3.2.4)
|
37
|
+
concurrent-ruby (1.1.10)
|
38
|
+
connection_pool (2.4.1)
|
39
|
+
crass (1.0.6)
|
40
|
+
descendants_tracker (0.0.4)
|
41
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
42
|
+
docile (1.3.5)
|
43
|
+
domain_name (0.5.20190701)
|
44
|
+
unf (>= 0.0.5, < 1.0.0)
|
45
|
+
drb (2.2.0)
|
46
|
+
ruby2_keywords
|
47
|
+
erubi (1.12.0)
|
48
|
+
faraday (1.3.0)
|
49
|
+
faraday-net_http (~> 1.0)
|
50
|
+
multipart-post (>= 1.2, < 3)
|
51
|
+
ruby2_keywords
|
52
|
+
faraday-net_http (1.0.1)
|
53
|
+
ffi (1.15.5)
|
54
|
+
ffi-compiler (1.0.1)
|
55
|
+
ffi (>= 1.0.0)
|
56
|
+
rake
|
57
|
+
git (1.13.0)
|
58
|
+
addressable (~> 2.8)
|
59
|
+
rchardet (~> 1.8)
|
60
|
+
github_api (0.19.0)
|
61
|
+
addressable (~> 2.4)
|
62
|
+
descendants_tracker (~> 0.0.4)
|
63
|
+
faraday (>= 0.8, < 2)
|
64
|
+
hashie (~> 3.5, >= 3.5.2)
|
65
|
+
oauth2 (~> 1.0)
|
66
|
+
google-protobuf (3.22.2)
|
67
|
+
googleapis-common-protos-types (1.5.0)
|
68
|
+
google-protobuf (~> 3.14)
|
69
|
+
hashie (3.6.0)
|
70
|
+
highline (2.0.3)
|
71
|
+
http (5.0.1)
|
72
|
+
addressable (~> 2.3)
|
73
|
+
http-cookie (~> 1.0)
|
74
|
+
http-form_data (~> 2.2)
|
75
|
+
llhttp-ffi (~> 0.3.0)
|
76
|
+
http-cookie (1.0.4)
|
77
|
+
domain_name (~> 0.5)
|
78
|
+
http-form_data (2.3.0)
|
79
|
+
i18n (1.14.1)
|
80
|
+
concurrent-ruby (~> 1.0)
|
81
|
+
juwelier (2.4.9)
|
82
|
+
builder
|
83
|
+
bundler
|
84
|
+
git
|
85
|
+
github_api
|
86
|
+
highline
|
87
|
+
kamelcase (~> 0)
|
88
|
+
nokogiri
|
89
|
+
psych
|
90
|
+
rake
|
91
|
+
rdoc
|
92
|
+
semver2
|
93
|
+
jwt (2.2.2)
|
94
|
+
kamelcase (0.0.2)
|
95
|
+
semver2 (~> 3)
|
96
|
+
ld-eventsource (2.2.0)
|
97
|
+
concurrent-ruby (~> 1.0)
|
98
|
+
http (>= 4.4.1, < 6.0.0)
|
99
|
+
llhttp-ffi (0.3.1)
|
100
|
+
ffi-compiler (~> 1.0)
|
101
|
+
rake (~> 13.0)
|
102
|
+
loofah (2.21.4)
|
103
|
+
crass (~> 1.0.2)
|
104
|
+
nokogiri (>= 1.12.0)
|
105
|
+
macaddr (1.7.2)
|
106
|
+
systemu (~> 2.6.5)
|
107
|
+
mini_portile2 (2.8.2)
|
108
|
+
minitest (5.16.2)
|
109
|
+
minitest-focus (1.3.1)
|
110
|
+
minitest (>= 4, < 6)
|
111
|
+
minitest-reporters (1.5.0)
|
112
|
+
ansi
|
113
|
+
builder
|
114
|
+
minitest (>= 5.0)
|
115
|
+
ruby-progressbar
|
116
|
+
multi_json (1.15.0)
|
117
|
+
multi_xml (0.6.0)
|
118
|
+
multipart-post (2.1.1)
|
119
|
+
mutex_m (0.2.0)
|
120
|
+
nokogiri (1.15.2)
|
121
|
+
mini_portile2 (~> 2.8.2)
|
122
|
+
racc (~> 1.4)
|
123
|
+
oauth2 (1.4.11)
|
124
|
+
faraday (>= 0.17.3, < 3.0)
|
125
|
+
jwt (>= 1.0, < 3.0)
|
126
|
+
multi_json (~> 1.3)
|
127
|
+
multi_xml (~> 0.5)
|
128
|
+
rack (>= 1.2, < 4)
|
129
|
+
psych (3.3.1)
|
130
|
+
public_suffix (4.0.6)
|
131
|
+
racc (1.7.0)
|
132
|
+
rack (3.0.6.1)
|
133
|
+
rack-session (2.0.0)
|
134
|
+
rack (>= 3.0.0)
|
135
|
+
rack-test (2.1.0)
|
136
|
+
rack (>= 1.3)
|
137
|
+
rails-dom-testing (2.2.0)
|
138
|
+
activesupport (>= 5.0.0)
|
139
|
+
minitest
|
140
|
+
nokogiri (>= 1.6)
|
141
|
+
rails-html-sanitizer (1.6.0)
|
142
|
+
loofah (~> 2.21)
|
143
|
+
nokogiri (~> 1.14)
|
144
|
+
rake (13.0.6)
|
145
|
+
rchardet (1.8.0)
|
146
|
+
rdoc (6.3.3)
|
147
|
+
ruby-progressbar (1.11.0)
|
148
|
+
ruby2_keywords (0.0.4)
|
149
|
+
semver2 (3.4.2)
|
150
|
+
simplecov (0.18.5)
|
151
|
+
docile (~> 1.1)
|
152
|
+
simplecov-html (~> 0.11)
|
153
|
+
simplecov-html (0.12.3)
|
154
|
+
systemu (2.6.5)
|
155
|
+
thread_safe (0.3.6)
|
156
|
+
timecop (0.9.4)
|
157
|
+
tzinfo (2.0.6)
|
158
|
+
concurrent-ruby (~> 1.0)
|
159
|
+
unf (0.1.4)
|
160
|
+
unf_ext
|
161
|
+
unf_ext (0.0.8)
|
162
|
+
uuid (2.3.9)
|
163
|
+
macaddr (~> 1.0)
|
164
|
+
|
165
|
+
PLATFORMS
|
166
|
+
ruby
|
167
|
+
|
168
|
+
DEPENDENCIES
|
169
|
+
actionpack (>= 4)
|
170
|
+
activesupport (>= 4)
|
171
|
+
benchmark-ips
|
172
|
+
bundler
|
173
|
+
concurrent-ruby (~> 1.0, >= 1.0.5)
|
174
|
+
faraday
|
175
|
+
google-protobuf
|
176
|
+
googleapis-common-protos-types
|
177
|
+
juwelier (~> 2.4.9)
|
178
|
+
ld-eventsource
|
179
|
+
minitest
|
180
|
+
minitest-focus
|
181
|
+
minitest-reporters
|
182
|
+
rdoc
|
183
|
+
simplecov
|
184
|
+
timecop
|
185
|
+
uuid
|
186
|
+
|
187
|
+
BUNDLED WITH
|
188
|
+
2.3.5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2023 Prefab, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# prefab-cloud-ruby
|
2
|
+
|
3
|
+
Ruby Client for Prefab Feature Flags, Dynamic log levels, and Config as a Service: https://www.prefab.cloud
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
client = Prefab::Client.new
|
7
|
+
|
8
|
+
context = {
|
9
|
+
user: {
|
10
|
+
team_id: 432,
|
11
|
+
id: 123,
|
12
|
+
subscription_level: 'pro',
|
13
|
+
email: "alice@example.com"
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
result = client.enabled? "my-first-feature-flag", context
|
18
|
+
|
19
|
+
puts "my-first-feature-flag is: #{result}"
|
20
|
+
```
|
21
|
+
|
22
|
+
See full documentation https://docs.prefab.cloud/docs/ruby-sdk/ruby
|
23
|
+
|
24
|
+
## Supports
|
25
|
+
|
26
|
+
- Feature Flags
|
27
|
+
- Dynamic log levels
|
28
|
+
- Live Config
|
29
|
+
- WebUI for tweaking config, log levels, and feature flags
|
30
|
+
|
31
|
+
## Important note about Forking and realtime updates
|
32
|
+
|
33
|
+
Many ruby web servers fork. When the process is forked, the current realtime update stream is disconnected. If you're using Puma or Unicorn, do the following.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
#config/initializers/prefab.rb
|
37
|
+
$prefab = Prefab::Client.new
|
38
|
+
$prefab.set_rails_loggers
|
39
|
+
```
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
#puma.rb
|
43
|
+
on_worker_boot do
|
44
|
+
$prefab = $prefab.fork
|
45
|
+
$prefab.set_rails_loggers
|
46
|
+
end
|
47
|
+
```
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
# unicorn.rb
|
51
|
+
after_fork do |server, worker|
|
52
|
+
$prefab = $prefab.fork
|
53
|
+
$prefab.set_rails_loggers
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
## Logging & Debugging
|
58
|
+
|
59
|
+
In classpath or ~/.prefab.default.config.yaml set
|
60
|
+
|
61
|
+
```
|
62
|
+
log-level:
|
63
|
+
cloud.prefab: debug
|
64
|
+
```
|
65
|
+
|
66
|
+
To debug issues before this config file has been read, set env var
|
67
|
+
|
68
|
+
```
|
69
|
+
PREFAB_LOG_CLIENT_BOOTSTRAP_LOG_LEVEL=debug
|
70
|
+
```
|
71
|
+
|
72
|
+
## Contributing to prefab-cloud-ruby
|
73
|
+
|
74
|
+
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
75
|
+
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
76
|
+
- Fork the project.
|
77
|
+
- Start a feature/bugfix branch.
|
78
|
+
- Commit and push until you are happy with your contribution.
|
79
|
+
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
80
|
+
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
81
|
+
|
82
|
+
## Release
|
83
|
+
|
84
|
+
```shell
|
85
|
+
update the changelog
|
86
|
+
update VERSION
|
87
|
+
bundle exec rake gemspec:generate
|
88
|
+
git commit & push
|
89
|
+
REMOTE_BRANCH=main LOCAL_BRANCH=main bundle exec rake release
|
90
|
+
```
|
91
|
+
|
92
|
+
## Copyright
|
93
|
+
|
94
|
+
Copyright (c) 2023 Jeff Dwyer. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
warn e.message
|
9
|
+
warn 'Run `bundle install` to install missing gems'
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
require 'juwelier'
|
14
|
+
Juwelier::Tasks.new do |gem|
|
15
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
16
|
+
gem.name = 'prefab-cloud-ruby'
|
17
|
+
gem.homepage = 'http://github.com/prefab-cloud/prefab-cloud-ruby'
|
18
|
+
gem.license = 'MIT'
|
19
|
+
gem.summary = %(Prefab Ruby Infrastructure)
|
20
|
+
gem.description = %(Feature Flags, Live Config, and Dynamic Log Levels as a service)
|
21
|
+
gem.email = 'jdwyer@prefab.cloud'
|
22
|
+
gem.authors = ['Jeff Dwyer']
|
23
|
+
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Juwelier::RubygemsDotOrgTasks.new
|
27
|
+
require 'rake/testtask'
|
28
|
+
Rake::TestTask.new(:test) do |test|
|
29
|
+
test.libs << 'lib' << 'test'
|
30
|
+
test.pattern = 'test/**/test_*.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
|
34
|
+
desc 'Code coverage detail'
|
35
|
+
task :simplecov do
|
36
|
+
ENV['COVERAGE'] = 'true'
|
37
|
+
Rake::Task['test'].execute
|
38
|
+
end
|
39
|
+
|
40
|
+
task default: :test
|
41
|
+
|
42
|
+
require 'rdoc/task'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ''
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "prefab-cloud-ruby #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.5.0
|
data/bin/console
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'irb'
|
5
|
+
require 'bundler/setup'
|
6
|
+
|
7
|
+
gemspec = Dir.glob(File.expand_path("../../*.gemspec", __FILE__)).first
|
8
|
+
spec = Gem::Specification.load(gemspec)
|
9
|
+
|
10
|
+
# Add the require paths to the $LOAD_PATH
|
11
|
+
spec.require_paths.each do |path|
|
12
|
+
full_path = File.expand_path("../" + path, __dir__)
|
13
|
+
$LOAD_PATH.unshift(full_path) unless $LOAD_PATH.include?(full_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
spec.require_paths.each do |path|
|
17
|
+
require "./lib/prefab-cloud-ruby"
|
18
|
+
end
|
19
|
+
|
20
|
+
# Start an IRB session
|
21
|
+
IRB.start(__FILE__)
|
data/compile_protos.sh
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -e
|
4
|
+
|
5
|
+
gem install grpc-tools
|
6
|
+
|
7
|
+
(
|
8
|
+
cd ../prefab-cloud
|
9
|
+
git pull --rebase
|
10
|
+
)
|
11
|
+
|
12
|
+
grpc_tools_ruby_protoc -I ../prefab-cloud/ --ruby_out=lib --grpc_out=lib prefab.proto
|
13
|
+
|
14
|
+
gsed -i 's/^module Prefab$/module PrefabProto/g' lib/prefab_pb.rb
|
15
|
+
|
16
|
+
# on M1 you need to
|
17
|
+
# 1. run in rosetta
|
18
|
+
# 2. mv gems/2.6.0/gems/grpc-tools-1.43.1/bin/x86_64-macos x86-macos
|