flagsmith 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 963916124a96866380ffb9defdda64421c2205e28f46a2dfe0fdecbb1c068989
|
4
|
+
data.tar.gz: 97ecf1f596db52665c0c69d46df178ab47223c7eede56e6a2c2da222b2d760e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73dd7ed243d419f59259c04edc73fde2e8a6bd915da45e2ac2db1c5ff802771e1ab59669a718f0e0af36cf2ff3f33206625785a52268e50fdc96cc9440537027
|
7
|
+
data.tar.gz: 33248a4a9343cb15898d4db5821260f83c1d3ec4fed858cb7adbf612e6c0c355ccbe1e68b4e1f0861fe5fdd72d48ce9713bee4b12127d9bfb5d89e6a3b812888
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
flagsmith (3.0.
|
4
|
+
flagsmith (3.0.1)
|
5
5
|
faraday
|
6
6
|
faraday-retry
|
7
7
|
faraday_middleware
|
@@ -29,8 +29,8 @@ GEM
|
|
29
29
|
faraday-em_synchrony (1.0.0)
|
30
30
|
faraday-excon (1.1.0)
|
31
31
|
faraday-httpclient (1.0.1)
|
32
|
-
faraday-multipart (1.0.
|
33
|
-
multipart-post (
|
32
|
+
faraday-multipart (1.0.4)
|
33
|
+
multipart-post (~> 2)
|
34
34
|
faraday-net_http (1.0.1)
|
35
35
|
faraday-net_http_persistent (1.2.0)
|
36
36
|
faraday-patron (1.0.0)
|
@@ -40,7 +40,7 @@ GEM
|
|
40
40
|
faraday (~> 1.0)
|
41
41
|
gem-release (2.2.0)
|
42
42
|
method_source (1.0.0)
|
43
|
-
multipart-post (2.
|
43
|
+
multipart-post (2.2.0)
|
44
44
|
parallel (1.20.1)
|
45
45
|
parser (3.0.0.0)
|
46
46
|
ast (~> 2.4.1)
|
@@ -2,8 +2,6 @@ $flagsmith = Flagsmith::Client.new(
|
|
2
2
|
enable_local_evaluation: true,
|
3
3
|
environment_refresh_interval_seconds: 60,
|
4
4
|
default_flag_handler: lambda { |feature_name|
|
5
|
-
Flagsmith::
|
6
|
-
feature_name: feature_name, enabled: false, value: {}.to_json, feature_id: nil
|
7
|
-
)
|
5
|
+
Flagsmith::Flags::DefaultFlag.new(enabled: false, value: {}.to_json)
|
8
6
|
}
|
9
7
|
)
|
@@ -4,7 +4,79 @@ module Flagsmith
|
|
4
4
|
module Flags
|
5
5
|
class NotFound < StandardError; end
|
6
6
|
|
7
|
-
|
7
|
+
class BaseFlag
|
8
|
+
include Comparable
|
9
|
+
|
10
|
+
attr_reader :enabled, :value, :default
|
11
|
+
|
12
|
+
def initialize(enabled:, value:, default:)
|
13
|
+
@enabled = enabled
|
14
|
+
@value = value
|
15
|
+
@default = default
|
16
|
+
end
|
17
|
+
|
18
|
+
def enabled?
|
19
|
+
enabled
|
20
|
+
end
|
21
|
+
|
22
|
+
alias is_default default
|
23
|
+
end
|
24
|
+
|
25
|
+
class DefaultFlag < BaseFlag
|
26
|
+
def initialize(enabled:, value:)
|
27
|
+
super(enabled: enabled, value: value, default: true)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Flag < BaseFlag
|
32
|
+
|
33
|
+
attr_reader :feature_name, :feature_id
|
34
|
+
|
35
|
+
def initialize(feature_name:, enabled:, value:, feature_id:)
|
36
|
+
super(enabled: enabled, value: value, default: false)
|
37
|
+
@feature_name = feature_name
|
38
|
+
@feature_id = feature_id
|
39
|
+
end
|
40
|
+
|
41
|
+
def <=>(other)
|
42
|
+
feature_name <=> other.feature_name
|
43
|
+
end
|
44
|
+
|
45
|
+
def [](key)
|
46
|
+
to_h[key]
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_h
|
50
|
+
{
|
51
|
+
feature_id: feature_id,
|
52
|
+
feature_name: feature_name,
|
53
|
+
value: value,
|
54
|
+
enabled: enabled,
|
55
|
+
default: default
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
class << self
|
60
|
+
def from_feature_state_model(feature_state_model, identity_id)
|
61
|
+
new(
|
62
|
+
enabled: feature_state_model.enabled,
|
63
|
+
value: feature_state_model.get_value(identity_id),
|
64
|
+
feature_name: feature_state_model.feature.name,
|
65
|
+
feature_id: feature_state_model.feature.id
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
def from_api(json_flag_data)
|
70
|
+
new(
|
71
|
+
enabled: json_flag_data[:enabled],
|
72
|
+
value: json_flag_data[:feature_state_value] || json_flag_data[:value],
|
73
|
+
feature_name: json_flag_data.dig(:feature, :name),
|
74
|
+
feature_id: json_flag_data.dig(:feature, :id)
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
8
80
|
class Collection
|
9
81
|
include Enumerable
|
10
82
|
|
@@ -75,7 +147,7 @@ module Flagsmith
|
|
75
147
|
def from_api(json_data, **args)
|
76
148
|
to_flag_object = lambda { |json_flag, acc|
|
77
149
|
acc[normalize_key(json_flag.dig(:feature, :name))] =
|
78
|
-
Flagsmith::Flag.from_api(json_flag)
|
150
|
+
Flagsmith::Flags::Flag.from_api(json_flag)
|
79
151
|
}
|
80
152
|
|
81
153
|
new(
|
@@ -87,7 +159,7 @@ module Flagsmith
|
|
87
159
|
def from_feature_state_models(feature_states, identity_id: nil, **args)
|
88
160
|
to_flag_object = lambda { |feature_state, acc|
|
89
161
|
acc[normalize_key(feature_state.feature.name)] =
|
90
|
-
|
162
|
+
Flagsmith::Flags::Flag.from_feature_state_model(feature_state, identity_id)
|
91
163
|
}
|
92
164
|
|
93
165
|
new(
|
data/lib/flagsmith/version.rb
CHANGED
data/lib/flagsmith.rb
CHANGED
@@ -14,8 +14,7 @@ require 'flagsmith/sdk/config'
|
|
14
14
|
require 'flagsmith/sdk/errors'
|
15
15
|
require 'flagsmith/sdk/intervals'
|
16
16
|
require 'flagsmith/sdk/pooling_manager'
|
17
|
-
require 'flagsmith/sdk/models/
|
18
|
-
require 'flagsmith/sdk/models/flags/collection'
|
17
|
+
require 'flagsmith/sdk/models/flags'
|
19
18
|
require 'flagsmith/sdk/instance_methods'
|
20
19
|
|
21
20
|
require 'flagsmith/engine/core'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flagsmith
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Stuart
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-06-
|
12
|
+
date: 2022-06-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -222,8 +222,7 @@ files:
|
|
222
222
|
- lib/flagsmith/sdk/errors.rb
|
223
223
|
- lib/flagsmith/sdk/instance_methods.rb
|
224
224
|
- lib/flagsmith/sdk/intervals.rb
|
225
|
-
- lib/flagsmith/sdk/models/
|
226
|
-
- lib/flagsmith/sdk/models/flags/collection.rb
|
225
|
+
- lib/flagsmith/sdk/models/flags.rb
|
227
226
|
- lib/flagsmith/sdk/pooling_manager.rb
|
228
227
|
- lib/flagsmith/version.rb
|
229
228
|
homepage: https://flagsmith.com
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Flagsmith
|
4
|
-
# Flag object
|
5
|
-
class Flag
|
6
|
-
include Comparable
|
7
|
-
|
8
|
-
attr_reader :enabled, :value, :default, :feature_name, :feature_id
|
9
|
-
|
10
|
-
def initialize(feature_name:, enabled:, value:, feature_id:, default: false)
|
11
|
-
@feature_name = feature_name
|
12
|
-
@feature_id = feature_id
|
13
|
-
@enabled = enabled
|
14
|
-
@value = value
|
15
|
-
@default = default
|
16
|
-
end
|
17
|
-
|
18
|
-
def enabled?
|
19
|
-
@enabled
|
20
|
-
end
|
21
|
-
|
22
|
-
alias is_default default
|
23
|
-
|
24
|
-
def <=>(other)
|
25
|
-
feature_name <=> other.feature_name
|
26
|
-
end
|
27
|
-
|
28
|
-
def [](key)
|
29
|
-
to_h[key]
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_h
|
33
|
-
{
|
34
|
-
feature_id: feature_id,
|
35
|
-
feature_name: feature_name,
|
36
|
-
value: value,
|
37
|
-
enabled: enabled,
|
38
|
-
default: default
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
class << self
|
43
|
-
def from_feature_state_model(feature_state_model, identity_id)
|
44
|
-
new(
|
45
|
-
enabled: feature_state_model.enabled,
|
46
|
-
value: feature_state_model.get_value(identity_id),
|
47
|
-
feature_name: feature_state_model.feature.name,
|
48
|
-
feature_id: feature_state_model.feature.id
|
49
|
-
)
|
50
|
-
end
|
51
|
-
|
52
|
-
def from_api(json_flag_data)
|
53
|
-
new(
|
54
|
-
enabled: json_flag_data[:enabled],
|
55
|
-
value: json_flag_data[:feature_state_value] || json_flag_data[:value],
|
56
|
-
feature_name: json_flag_data.dig(:feature, :name),
|
57
|
-
feature_id: json_flag_data.dig(:feature, :id)
|
58
|
-
)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|