flagsmith 4.1.1 → 5.0.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/.release-please-manifest.json +1 -0
- data/CHANGELOG.md +232 -0
- data/CODEOWNERS +1 -0
- data/Gemfile.lock +7 -5
- data/README.md +0 -2
- data/lib/flagsmith/engine/core.rb +107 -48
- data/lib/flagsmith/engine/environments/models.rb +6 -3
- data/lib/flagsmith/engine/evaluation/core.rb +142 -0
- data/lib/flagsmith/engine/features/constants.rb +14 -0
- data/lib/flagsmith/engine/features/models.rb +1 -1
- data/lib/flagsmith/engine/mappers/environment.rb +59 -0
- data/lib/flagsmith/engine/mappers/identity.rb +97 -0
- data/lib/flagsmith/engine/mappers/segments.rb +65 -0
- data/lib/flagsmith/engine/mappers.rb +66 -0
- data/lib/flagsmith/engine/segments/evaluator.rb +181 -17
- data/lib/flagsmith/engine/segments/models.rb +56 -22
- data/lib/flagsmith/sdk/api_client.rb +1 -0
- data/lib/flagsmith/sdk/config.rb +14 -1
- data/lib/flagsmith/sdk/models/flags.rb +25 -11
- data/lib/flagsmith/sdk/realtime_client.rb +63 -0
- data/lib/flagsmith/sdk/utils.rb +29 -0
- data/lib/flagsmith/version.rb +1 -1
- data/lib/flagsmith.rb +64 -26
- data/release-please-config.json +62 -0
- metadata +32 -7
- data/flagsmith.gemspec +0 -39
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 762e4371604e455f15016c74783f28b39383f314d5ca5d0a07dc3f70d5410c7b
|
|
4
|
+
data.tar.gz: a791e1905a651beb4dbcf8564b582232bd153e86b646945513f6fe7a5eb6fa57
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a01bd726d58150a70bd13186baaea23fe12d9c90455d81e5421b58676576e60f53de914f64978d1dd94805dbdc31a2dbd3266998bed1a60eecfc111492b8e90a
|
|
7
|
+
data.tar.gz: 01ba85177dc76451b9c4d0a1e9960b03f9adcec247477c3bad6c73814af719ce1aa5061416203a5dabc0aeba5f6f3e9f1f587d0e970be9c84742921532bbc1fb
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{".":"5.0.0"}
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [5.0.0](https://github.com/Flagsmith/flagsmith-ruby-client/compare/v4.3.0...v5.0.0) (2025-11-12)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### ⚠ BREAKING CHANGES
|
|
7
|
+
|
|
8
|
+
* evaluation context mappers ([#87](https://github.com/Flagsmith/flagsmith-ruby-client/issues/87))
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* added-version-in-user-agent-header ([#86](https://github.com/Flagsmith/flagsmith-ruby-client/issues/86)) ([a7216f5](https://github.com/Flagsmith/flagsmith-ruby-client/commit/a7216f51ce99142473b0c12a72940d406543c4bd))
|
|
13
|
+
* evaluation context mappers ([#87](https://github.com/Flagsmith/flagsmith-ruby-client/issues/87)) ([287ce6d](https://github.com/Flagsmith/flagsmith-ruby-client/commit/287ce6d173cf72564da88b8e9c98d042a1deb941))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### CI
|
|
17
|
+
|
|
18
|
+
* add release please ([#77](https://github.com/Flagsmith/flagsmith-ruby-client/issues/77)) ([a815cd9](https://github.com/Flagsmith/flagsmith-ruby-client/commit/a815cd9f2274f9bda9842786f2a09a358f203f46))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Docs
|
|
22
|
+
|
|
23
|
+
* removing hero image from SDK readme ([#78](https://github.com/Flagsmith/flagsmith-ruby-client/issues/78)) ([154c5b2](https://github.com/Flagsmith/flagsmith-ruby-client/commit/154c5b22f0b10c7a013605cf1265c6338f986c62))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Other
|
|
27
|
+
|
|
28
|
+
* add root CODEOWNERS ([#83](https://github.com/Flagsmith/flagsmith-ruby-client/issues/83)) ([da0c6e0](https://github.com/Flagsmith/flagsmith-ruby-client/commit/da0c6e045212dd3f7912f0e5e847be0bd5c3ad66))
|
|
29
|
+
* versioned test data ([#80](https://github.com/Flagsmith/flagsmith-ruby-client/issues/80)) ([18eedd9](https://github.com/Flagsmith/flagsmith-ruby-client/commit/18eedd9d51a6a5489fed16e47c167a8bb4c3ae4c))
|
|
30
|
+
|
|
31
|
+
<a id="v4.3.0"></a>
|
|
32
|
+
## [v4.3.0](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v4.3.0) - 2024-12-06
|
|
33
|
+
|
|
34
|
+
## What's Changed
|
|
35
|
+
* Bump rexml from 3.2.8 to 3.3.9 by [@dependabot](https://github.com/dependabot) in [#71](https://github.com/Flagsmith/flagsmith-ruby-client/pull/71)
|
|
36
|
+
* fix: allow false as a flag value by [@bdchauvette](https://github.com/bdchauvette) in [#68](https://github.com/Flagsmith/flagsmith-ruby-client/pull/68)
|
|
37
|
+
* feat: Enable realtime mode (SSE) by [@zachaysan](https://github.com/zachaysan) in [#73](https://github.com/Flagsmith/flagsmith-ruby-client/pull/73)
|
|
38
|
+
* Make segment operators nil-safe by [@rolodato](https://github.com/rolodato) in [#69](https://github.com/Flagsmith/flagsmith-ruby-client/pull/69)
|
|
39
|
+
* chore: Bump to 4.3.0 by [@zachaysan](https://github.com/zachaysan) in [#74](https://github.com/Flagsmith/flagsmith-ruby-client/pull/74)
|
|
40
|
+
|
|
41
|
+
## New Contributors
|
|
42
|
+
* [@bdchauvette](https://github.com/bdchauvette) made their first contribution in [#68](https://github.com/Flagsmith/flagsmith-ruby-client/pull/68)
|
|
43
|
+
* [@rolodato](https://github.com/rolodato) made their first contribution in [#69](https://github.com/Flagsmith/flagsmith-ruby-client/pull/69)
|
|
44
|
+
|
|
45
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v4.2.0...v4.3.0
|
|
46
|
+
|
|
47
|
+
[Changes][v4.3.0]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
<a id="v4.2.0"></a>
|
|
51
|
+
## [v4.2.0](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v4.2.0) - 2024-10-22
|
|
52
|
+
|
|
53
|
+
## What's Changed
|
|
54
|
+
* feat: Support transient identities and traits by [@khvn26](https://github.com/khvn26) in [#66](https://github.com/Flagsmith/flagsmith-ruby-client/pull/66)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v4.1.1...v4.2.0
|
|
58
|
+
|
|
59
|
+
[Changes][v4.2.0]
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
<a id="v4.1.1"></a>
|
|
63
|
+
## [v4.1.1](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v4.1.1) - 2024-05-22
|
|
64
|
+
|
|
65
|
+
## What's Changed
|
|
66
|
+
* fix: Squash exceptions for polling manager by [@zachaysan](https://github.com/zachaysan) in [#55](https://github.com/Flagsmith/flagsmith-ruby-client/pull/55)
|
|
67
|
+
* Bump rexml from 3.2.6 to 3.2.8 by [@dependabot](https://github.com/dependabot) in [#60](https://github.com/Flagsmith/flagsmith-ruby-client/pull/60)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v4.1.0...v4.1.1
|
|
71
|
+
|
|
72
|
+
[Changes][v4.1.1]
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
<a id="v4.1.0"></a>
|
|
76
|
+
## [v4.1.0](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v4.1.0) - 2024-04-19
|
|
77
|
+
|
|
78
|
+
## What's Changed
|
|
79
|
+
* feat: Add identity overrides to client by [@zachaysan](https://github.com/zachaysan) in [#50](https://github.com/Flagsmith/flagsmith-ruby-client/pull/50)
|
|
80
|
+
* fix: Make local evaluation multivariate work by [@zachaysan](https://github.com/zachaysan) in [#51](https://github.com/Flagsmith/flagsmith-ruby-client/pull/51)
|
|
81
|
+
* Bump puma from 6.3.1 to 6.4.2 in /example by [@dependabot](https://github.com/dependabot) in [#39](https://github.com/Flagsmith/flagsmith-ruby-client/pull/39)
|
|
82
|
+
* chore: remove examples by [@dabeeeenster](https://github.com/dabeeeenster) in [#48](https://github.com/Flagsmith/flagsmith-ruby-client/pull/48)
|
|
83
|
+
* fix: Mute analytics processor on failure by [@zachaysan](https://github.com/zachaysan) in [#57](https://github.com/Flagsmith/flagsmith-ruby-client/pull/57)
|
|
84
|
+
* fix: Stop repeated calls to update environment when polling manager is set by [@zachaysan](https://github.com/zachaysan) in [#58](https://github.com/Flagsmith/flagsmith-ruby-client/pull/58)
|
|
85
|
+
|
|
86
|
+
## New Contributors
|
|
87
|
+
* [@dabeeeenster](https://github.com/dabeeeenster) made their first contribution in [#48](https://github.com/Flagsmith/flagsmith-ruby-client/pull/48)
|
|
88
|
+
|
|
89
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v4.0.1...v4.1.0
|
|
90
|
+
|
|
91
|
+
[Changes][v4.1.0]
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
<a id="v4.0.1"></a>
|
|
95
|
+
## [v4.0.1](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v4.0.1) - 2024-02-06
|
|
96
|
+
|
|
97
|
+
## What's Changed
|
|
98
|
+
* fix: Remove dev dependences by [@zachaysan](https://github.com/zachaysan) in [#45](https://github.com/Flagsmith/flagsmith-ruby-client/pull/45)
|
|
99
|
+
* chore: Bump version to 4.0.1 by [@zachaysan](https://github.com/zachaysan) in [#46](https://github.com/Flagsmith/flagsmith-ruby-client/pull/46)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v4.0.0...v4.0.1
|
|
103
|
+
|
|
104
|
+
[Changes][v4.0.1]
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
<a id="v4.0.0"></a>
|
|
108
|
+
## [Version 4.0.0 (v4.0.0)](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v4.0.0) - 2024-01-30
|
|
109
|
+
|
|
110
|
+
## What's Changed
|
|
111
|
+
* Bump puma from 5.6.4 to 6.3.1 in /example by [@dependabot](https://github.com/dependabot) in [#35](https://github.com/Flagsmith/flagsmith-ruby-client/pull/35)
|
|
112
|
+
* chore: update CI Ruby version to 3.1 by [@khvn26](https://github.com/khvn26) in [#34](https://github.com/Flagsmith/flagsmith-ruby-client/pull/34)
|
|
113
|
+
* fix: Pin the faraday gem file to avoid TypeError superclass mismatch by [@zachaysan](https://github.com/zachaysan) in [#37](https://github.com/Flagsmith/flagsmith-ruby-client/pull/37)
|
|
114
|
+
* feat: Add offline mode for using the client locally by [@zachaysan](https://github.com/zachaysan) in [#38](https://github.com/Flagsmith/flagsmith-ruby-client/pull/38)
|
|
115
|
+
* chore: Remove faraday middleware by [@zachaysan](https://github.com/zachaysan) in [#40](https://github.com/Flagsmith/flagsmith-ruby-client/pull/40)
|
|
116
|
+
* chore: Bump version to 4.0.0 by [@zachaysan](https://github.com/zachaysan) in [#41](https://github.com/Flagsmith/flagsmith-ruby-client/pull/41)
|
|
117
|
+
|
|
118
|
+
## New Contributors
|
|
119
|
+
* [@zachaysan](https://github.com/zachaysan) made their first contribution in [#37](https://github.com/Flagsmith/flagsmith-ruby-client/pull/37)
|
|
120
|
+
|
|
121
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.2.0...v4.0.0
|
|
122
|
+
|
|
123
|
+
[Changes][v4.0.0]
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
<a id="v3.2.0"></a>
|
|
127
|
+
## [Version 3.2.0 (v3.2.0)](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v3.2.0) - 2023-07-25
|
|
128
|
+
|
|
129
|
+
## What's Changed
|
|
130
|
+
* Prevent publish workflow from running by [@matthewelwell](https://github.com/matthewelwell) in [#25](https://github.com/Flagsmith/flagsmith-ruby-client/pull/25)
|
|
131
|
+
* Bump rack from 2.2.3.1 to 2.2.6.4 in /example by [@dependabot](https://github.com/dependabot) in [#27](https://github.com/Flagsmith/flagsmith-ruby-client/pull/27)
|
|
132
|
+
* Update dependencies by [@matthewelwell](https://github.com/matthewelwell) in [#28](https://github.com/Flagsmith/flagsmith-ruby-client/pull/28)
|
|
133
|
+
* ci: add rubocop by [@matthewelwell](https://github.com/matthewelwell) in [#32](https://github.com/Flagsmith/flagsmith-ruby-client/pull/32)
|
|
134
|
+
* feat: implement `IN` operator by [@khvn26](https://github.com/khvn26) in [#31](https://github.com/Flagsmith/flagsmith-ruby-client/pull/31)
|
|
135
|
+
|
|
136
|
+
## New Contributors
|
|
137
|
+
* [@khvn26](https://github.com/khvn26) made their first contribution in [#31](https://github.com/Flagsmith/flagsmith-ruby-client/pull/31)
|
|
138
|
+
|
|
139
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.1.1...v3.2.0
|
|
140
|
+
|
|
141
|
+
[Changes][v3.2.0]
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
<a id="v3.1.1"></a>
|
|
145
|
+
## [Version 3.1.1 (v3.1.1)](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v3.1.1) - 2023-02-22
|
|
146
|
+
|
|
147
|
+
## What's Changed
|
|
148
|
+
* Fix analytics flush timer by [@matthewelwell](https://github.com/matthewelwell) in [#23](https://github.com/Flagsmith/flagsmith-ruby-client/pull/23)
|
|
149
|
+
* Release 3.1.1 by [@matthewelwell](https://github.com/matthewelwell) in [#24](https://github.com/Flagsmith/flagsmith-ruby-client/pull/24)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.1.0...v3.1.1
|
|
153
|
+
|
|
154
|
+
[Changes][v3.1.1]
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
<a id="v3.1.0"></a>
|
|
158
|
+
## [Version 3.1.0 (v3.1.0)](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v3.1.0) - 2022-11-01
|
|
159
|
+
|
|
160
|
+
## What's Changed
|
|
161
|
+
* Add modulo operator by [@matthewelwell](https://github.com/matthewelwell) in [#21](https://github.com/Flagsmith/flagsmith-ruby-client/pull/21)
|
|
162
|
+
* Add get identity segments method by [@matthewelwell](https://github.com/matthewelwell) in [#18](https://github.com/Flagsmith/flagsmith-ruby-client/pull/18)
|
|
163
|
+
* Add IS_SET and IS_NOT_SET segment operators by [@matthewelwell](https://github.com/matthewelwell) in [#20](https://github.com/Flagsmith/flagsmith-ruby-client/pull/20)
|
|
164
|
+
* Release 3.1.0 by [@matthewelwell](https://github.com/matthewelwell) in [#19](https://github.com/Flagsmith/flagsmith-ruby-client/pull/19)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.0.2...v3.1.0
|
|
168
|
+
|
|
169
|
+
[Changes][v3.1.0]
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
<a id="v3.0.2"></a>
|
|
173
|
+
## [Version 3.0.2 (v3.0.2)](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v3.0.2) - 2022-07-13
|
|
174
|
+
|
|
175
|
+
## What's Changed
|
|
176
|
+
* Use feature name instead of id for analytics by [@matthewelwell](https://github.com/matthewelwell) in [#17](https://github.com/Flagsmith/flagsmith-ruby-client/pull/17)
|
|
177
|
+
* Bump rack from 2.2.3 to 2.2.3.1 in /example by [@dependabot](https://github.com/dependabot) in [#12](https://github.com/Flagsmith/flagsmith-ruby-client/pull/12)
|
|
178
|
+
* Bump rexml from 3.2.4 to 3.2.5 by [@dependabot](https://github.com/dependabot) in [#8](https://github.com/Flagsmith/flagsmith-ruby-client/pull/8)
|
|
179
|
+
* Release 3.0.2 by [@matthewelwell](https://github.com/matthewelwell) in [#16](https://github.com/Flagsmith/flagsmith-ruby-client/pull/16)
|
|
180
|
+
|
|
181
|
+
## New Contributors
|
|
182
|
+
* [@dependabot](https://github.com/dependabot) made their first contribution in [#12](https://github.com/Flagsmith/flagsmith-ruby-client/pull/12)
|
|
183
|
+
|
|
184
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.0.1...v3.0.2
|
|
185
|
+
|
|
186
|
+
[Changes][v3.0.2]
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
<a id="v3.0.1"></a>
|
|
190
|
+
## [Version 3.0.1 (v3.0.1)](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v3.0.1) - 2022-06-09
|
|
191
|
+
|
|
192
|
+
## What's Changed
|
|
193
|
+
* Add BaseFlag and DefaultFlag classes by [@matthewelwell](https://github.com/matthewelwell) in [#14](https://github.com/Flagsmith/flagsmith-ruby-client/pull/14)
|
|
194
|
+
* Release 3.0.1 by [@matthewelwell](https://github.com/matthewelwell) in [#15](https://github.com/Flagsmith/flagsmith-ruby-client/pull/15)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.0.0...v3.0.1
|
|
198
|
+
|
|
199
|
+
[Changes][v3.0.1]
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
<a id="v3.0.0"></a>
|
|
203
|
+
## [Version 3.0.0 (v3.0.0)](https://github.com/Flagsmith/flagsmith-ruby-client/releases/tag/v3.0.0) - 2022-06-07
|
|
204
|
+
|
|
205
|
+
## What's Changed
|
|
206
|
+
* Example app by [@byReham](https://github.com/byReham) in [#10](https://github.com/Flagsmith/flagsmith-ruby-client/pull/10)
|
|
207
|
+
* Update default url by [@matthewelwell](https://github.com/matthewelwell) in [#11](https://github.com/Flagsmith/flagsmith-ruby-client/pull/11)
|
|
208
|
+
* Release/3.0.0 by [@byReham](https://github.com/byReham) in [#9](https://github.com/Flagsmith/flagsmith-ruby-client/pull/9)
|
|
209
|
+
|
|
210
|
+
## New Contributors
|
|
211
|
+
* [@byReham](https://github.com/byReham) made their first contribution in [#10](https://github.com/Flagsmith/flagsmith-ruby-client/pull/10)
|
|
212
|
+
* [@matthewelwell](https://github.com/matthewelwell) made their first contribution in [#11](https://github.com/Flagsmith/flagsmith-ruby-client/pull/11)
|
|
213
|
+
|
|
214
|
+
**Full Changelog**: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v2.0.0...v3.0.0
|
|
215
|
+
|
|
216
|
+
[Changes][v3.0.0]
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
[v4.3.0]: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v4.2.0...v4.3.0
|
|
220
|
+
[v4.2.0]: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v4.1.1...v4.2.0
|
|
221
|
+
[v4.1.1]: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v4.1.0...v4.1.1
|
|
222
|
+
[v4.1.0]: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v4.0.1...v4.1.0
|
|
223
|
+
[v4.0.1]: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v4.0.0...v4.0.1
|
|
224
|
+
[v4.0.0]: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.2.0...v4.0.0
|
|
225
|
+
[v3.2.0]: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.1.1...v3.2.0
|
|
226
|
+
[v3.1.1]: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.1.0...v3.1.1
|
|
227
|
+
[v3.1.0]: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.0.2...v3.1.0
|
|
228
|
+
[v3.0.2]: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.0.1...v3.0.2
|
|
229
|
+
[v3.0.1]: https://github.com/Flagsmith/flagsmith-ruby-client/compare/v3.0.0...v3.0.1
|
|
230
|
+
[v3.0.0]: https://github.com/Flagsmith/flagsmith-ruby-client/tree/v3.0.0
|
|
231
|
+
|
|
232
|
+
<!-- Generated by https://github.com/rhysd/changelog-from-release v3.9.0 -->
|
data/CODEOWNERS
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @flagsmith/flagsmith-back-end
|
data/Gemfile.lock
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
flagsmith (
|
|
4
|
+
flagsmith (5.0.0)
|
|
5
5
|
faraday (>= 2.0.1)
|
|
6
6
|
faraday-retry
|
|
7
|
+
jsonpath (~> 1.1)
|
|
7
8
|
semantic
|
|
8
9
|
|
|
9
10
|
GEM
|
|
@@ -21,8 +22,11 @@ GEM
|
|
|
21
22
|
faraday (~> 2.0)
|
|
22
23
|
gem-release (2.2.2)
|
|
23
24
|
json (2.7.1)
|
|
25
|
+
jsonpath (1.1.5)
|
|
26
|
+
multi_json
|
|
24
27
|
language_server-protocol (3.17.0.3)
|
|
25
28
|
method_source (1.0.0)
|
|
29
|
+
multi_json (1.17.0)
|
|
26
30
|
net-http (0.4.1)
|
|
27
31
|
uri
|
|
28
32
|
parallel (1.24.0)
|
|
@@ -39,8 +43,7 @@ GEM
|
|
|
39
43
|
rainbow (3.1.1)
|
|
40
44
|
rake (13.1.0)
|
|
41
45
|
regexp_parser (2.9.0)
|
|
42
|
-
rexml (3.
|
|
43
|
-
strscan (>= 3.0.9)
|
|
46
|
+
rexml (3.3.9)
|
|
44
47
|
rspec (3.12.0)
|
|
45
48
|
rspec-core (~> 3.12.0)
|
|
46
49
|
rspec-expectations (~> 3.12.0)
|
|
@@ -69,9 +72,8 @@ GEM
|
|
|
69
72
|
parser (>= 3.2.1.0)
|
|
70
73
|
ruby-progressbar (1.13.0)
|
|
71
74
|
semantic (1.6.1)
|
|
72
|
-
strscan (3.1.0)
|
|
73
75
|
unicode-display_width (2.5.0)
|
|
74
|
-
uri (0.13.
|
|
76
|
+
uri (0.13.2)
|
|
75
77
|
|
|
76
78
|
PLATFORMS
|
|
77
79
|
ruby
|
data/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
<img width="100%" src="https://github.com/Flagsmith/flagsmith/raw/main/static-files/hero.png"/>
|
|
2
|
-
|
|
3
1
|
# Flagsmith Ruby Client
|
|
4
2
|
|
|
5
3
|
The SDK clients for Ruby [https://www.flagsmith.com/](https://www.flagsmith.com/). Flagsmith allows you to manage feature flags and remote config across multiple projects, environments and organizations.
|
|
@@ -5,84 +5,143 @@ require 'securerandom'
|
|
|
5
5
|
|
|
6
6
|
require_relative 'environments/models'
|
|
7
7
|
require_relative 'features/models'
|
|
8
|
+
require_relative 'features/constants'
|
|
8
9
|
require_relative 'identities/models'
|
|
9
10
|
require_relative 'organisations/models'
|
|
10
11
|
require_relative 'projects/models'
|
|
11
12
|
require_relative 'segments/evaluator'
|
|
12
13
|
require_relative 'segments/models'
|
|
13
14
|
require_relative 'utils/hash_func'
|
|
15
|
+
require_relative 'mappers'
|
|
14
16
|
|
|
15
17
|
module Flagsmith
|
|
18
|
+
# Core evaluation logic for feature flags
|
|
16
19
|
module Engine
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
extend self
|
|
21
|
+
include Flagsmith::Engine::Utils::HashFunc
|
|
22
|
+
include Flagsmith::Engine::Features::TargetingReasons
|
|
23
|
+
include Flagsmith::Engine::Segments::Evaluator
|
|
24
|
+
|
|
25
|
+
# Get evaluation result from evaluation context
|
|
26
|
+
#
|
|
27
|
+
# @param evaluation_context [Hash] The evaluation context
|
|
28
|
+
# @return [Hash] Evaluation result with flags and segments
|
|
29
|
+
def get_evaluation_result(evaluation_context)
|
|
30
|
+
evaluation_context = get_enriched_context(evaluation_context)
|
|
31
|
+
segments, segment_overrides = evaluate_segments(evaluation_context)
|
|
32
|
+
flags = evaluate_features(evaluation_context, segment_overrides)
|
|
33
|
+
{
|
|
34
|
+
flags: flags,
|
|
35
|
+
segments: segments
|
|
36
|
+
}
|
|
37
|
+
end
|
|
23
38
|
|
|
24
|
-
|
|
39
|
+
# Returns { segments: EvaluationResultSegments; segmentOverrides: Record<string, SegmentOverride>; }
|
|
40
|
+
def evaluate_segments(evaluation_context)
|
|
41
|
+
return [], {} if evaluation_context[:segments].nil?
|
|
25
42
|
|
|
26
|
-
|
|
43
|
+
identity_segments = get_segments_from_context(evaluation_context)
|
|
27
44
|
|
|
28
|
-
|
|
45
|
+
segments = identity_segments.map do |segment|
|
|
46
|
+
{ name: segment[:name], metadata: segment[:metadata] }.compact
|
|
29
47
|
end
|
|
30
48
|
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
segment_overrides = process_segment_overrides(identity_segments)
|
|
50
|
+
|
|
51
|
+
[segments, segment_overrides]
|
|
52
|
+
end
|
|
33
53
|
|
|
34
|
-
|
|
54
|
+
# Returns Record<string: override.name, SegmentOverride>
|
|
55
|
+
def process_segment_overrides(identity_segments) # rubocop:disable Metrics/MethodLength
|
|
56
|
+
segment_overrides = {}
|
|
35
57
|
|
|
36
|
-
|
|
58
|
+
identity_segments.each do |segment|
|
|
59
|
+
Array(segment[:overrides]).each do |override|
|
|
60
|
+
next unless should_apply_override(override, segment_overrides)
|
|
61
|
+
|
|
62
|
+
segment_overrides[override[:name]] = {
|
|
63
|
+
feature: override,
|
|
64
|
+
segment_name: segment[:name]
|
|
65
|
+
}
|
|
66
|
+
end
|
|
37
67
|
end
|
|
38
68
|
|
|
39
|
-
|
|
40
|
-
|
|
69
|
+
segment_overrides
|
|
70
|
+
end
|
|
41
71
|
|
|
42
|
-
|
|
72
|
+
def evaluate_features(evaluation_context, segment_overrides)
|
|
73
|
+
identity_key = get_identity_key(evaluation_context)
|
|
43
74
|
|
|
44
|
-
|
|
75
|
+
(evaluation_context[:features] || {}).each_with_object({}) do |(_, feature), flags|
|
|
76
|
+
segment_override = segment_overrides[feature[:name]]
|
|
77
|
+
final_feature = segment_override ? segment_override[:feature] : feature
|
|
78
|
+
|
|
79
|
+
flag_result = build_flag_result(final_feature, identity_key, segment_override)
|
|
80
|
+
flags[final_feature[:name].to_sym] = flag_result
|
|
45
81
|
end
|
|
82
|
+
end
|
|
46
83
|
|
|
47
|
-
|
|
48
|
-
|
|
84
|
+
# Returns {value: any; reason?: string}
|
|
85
|
+
def evaluate_feature_value(feature, identity_key = nil)
|
|
86
|
+
return get_multivariate_feature_value(feature, identity_key) if feature[:variants]&.any? && identity_key
|
|
49
87
|
|
|
50
|
-
|
|
51
|
-
|
|
88
|
+
{ value: feature[:value], reason: nil }
|
|
89
|
+
end
|
|
52
90
|
|
|
53
|
-
|
|
91
|
+
# Returns {value: any; reason?: string}
|
|
92
|
+
def get_multivariate_feature_value(feature, identity_key)
|
|
93
|
+
percentage_value = hashed_percentage_for_object_ids([feature[:key], identity_key])
|
|
94
|
+
sorted_variants = (feature[:variants] || []).sort_by { |v| v[:priority] || WEAKEST_PRIORITY }
|
|
54
95
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
override = ->(fs) { feature_states[fs.feature.id] = fs }
|
|
59
|
-
environment.feature_states.each(&override)
|
|
96
|
+
variant = find_matching_variant(sorted_variants, percentage_value)
|
|
97
|
+
variant || { value: feature[:value], reason: nil }
|
|
98
|
+
end
|
|
60
99
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
100
|
+
def find_matching_variant(sorted_variants, percentage_value)
|
|
101
|
+
start_percentage = 0
|
|
102
|
+
sorted_variants.each do |variant|
|
|
103
|
+
limit = start_percentage + variant[:weight]
|
|
104
|
+
return { value: variant[:value], reason: "#{TARGETING_REASON_SPLIT}; weight=#{variant[:weight]}" } if start_percentage <= percentage_value && percentage_value < limit
|
|
64
105
|
|
|
65
|
-
|
|
66
|
-
identity.identity_features.each(&override)
|
|
67
|
-
feature_states
|
|
106
|
+
start_percentage = limit
|
|
68
107
|
end
|
|
108
|
+
nil
|
|
109
|
+
end
|
|
69
110
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
yield feature_state if block_given?
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
111
|
+
# returns boolean
|
|
112
|
+
def should_apply_override(override, existing_overrides)
|
|
113
|
+
current_override = existing_overrides[override[:name]]
|
|
114
|
+
!current_override || stronger_priority?(override[:priority], current_override[:feature][:priority])
|
|
115
|
+
end
|
|
79
116
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
117
|
+
private
|
|
118
|
+
|
|
119
|
+
def build_flag_result(feature, identity_key, segment_override)
|
|
120
|
+
evaluated = evaluate_feature_value(feature, identity_key)
|
|
121
|
+
|
|
122
|
+
flag_result = {
|
|
123
|
+
name: feature[:name],
|
|
124
|
+
enabled: feature[:enabled],
|
|
125
|
+
value: evaluated[:value],
|
|
126
|
+
reason: evaluated[:reason] || (segment_override ? "#{TARGETING_REASON_TARGETING_MATCH}; segment=#{segment_override[:segment_name]}" : TARGETING_REASON_DEFAULT)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
flag_result[:metadata] = feature[:metadata] if feature[:metadata]
|
|
130
|
+
flag_result
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Extract identity key from evaluation context
|
|
134
|
+
#
|
|
135
|
+
# @param evaluation_context [Hash] The evaluation context
|
|
136
|
+
# @return [String, nil] The identity key or nil if no identity
|
|
137
|
+
def get_identity_key(evaluation_context)
|
|
138
|
+
return nil unless evaluation_context[:identity]
|
|
139
|
+
|
|
140
|
+
evaluation_context[:identity][:key]
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def stronger_priority?(priority_a, priority_b)
|
|
144
|
+
(priority_a || WEAKEST_PRIORITY) < (priority_b || WEAKEST_PRIORITY)
|
|
86
145
|
end
|
|
87
146
|
end
|
|
88
147
|
end
|
|
@@ -4,17 +4,20 @@ module Flagsmith
|
|
|
4
4
|
module Engine
|
|
5
5
|
# EnvironmentModel
|
|
6
6
|
class Environment
|
|
7
|
-
attr_reader :id, :api_key
|
|
7
|
+
attr_reader :id, :api_key, :name
|
|
8
8
|
attr_accessor :project, :feature_states, :amplitude_config, :segment_config,
|
|
9
9
|
:mixpanel_config, :heap_config, :identity_overrides
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
# rubocop:disable Metrics/ParameterLists
|
|
12
|
+
def initialize(id:, api_key:, project:, name: nil, feature_states: [], identity_overrides: [])
|
|
12
13
|
@id = id
|
|
13
14
|
@api_key = api_key
|
|
15
|
+
@name = name
|
|
14
16
|
@project = project
|
|
15
17
|
@feature_states = feature_states
|
|
16
18
|
@identity_overrides = identity_overrides
|
|
17
19
|
end
|
|
20
|
+
# rubocop:enable Metrics/ParameterLists
|
|
18
21
|
|
|
19
22
|
class << self
|
|
20
23
|
# rubocop:disable Metrics/MethodLength
|
|
@@ -28,7 +31,7 @@ module Flagsmith
|
|
|
28
31
|
Flagsmith::Engine::Identity.build(io)
|
|
29
32
|
end
|
|
30
33
|
|
|
31
|
-
new(**json.slice(:id, :api_key).merge(
|
|
34
|
+
new(**json.slice(:id, :api_key, :name).merge(
|
|
32
35
|
project: project,
|
|
33
36
|
feature_states: feature_states,
|
|
34
37
|
identity_overrides: identity_overrides
|