flipper 1.5.0.rc2 → 1.5.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/lib/flipper/cli.rb +11 -2
- data/lib/flipper/cloud/shared_memory.rb +1 -1
- data/lib/flipper/sem_ver.rb +5 -1
- data/lib/flipper/test_help.rb +14 -7
- data/lib/flipper/typecast.rb +16 -1
- data/lib/flipper/version.rb +1 -1
- data/lib/generators/flipper/table_prefix.rb +9 -6
- data/lib/generators/flipper/templates/update/migrations/01_create_flipper_tables.rb.erb +1 -1
- data/lib/generators/flipper/templates/update/migrations/02_change_flipper_gates_value_to_text.rb.erb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bcd315c90967e5b1cf80a834bcadda7d0439fced33abf49a76300eca785e8f27
|
|
4
|
+
data.tar.gz: 22f0d9856d41984f0ac35be264bcfb0a07bdef7f5e59211c82c61d8535333ea0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8e826172032e682aa69f6ae04394636325f3586b1927c3fb46185da2cefd5921b684aab71dd50a9b8586425b8a928fff59c03e55db681f993076f3c319aad142
|
|
7
|
+
data.tar.gz: fa4c786c16e36e48d246e50c673223fe88ea7d024466f807bc4d6b1747abc4a15caaf4267a1423b6713717ca675e7e905537f070a2c1f6ddc2af0c094c94a532
|
data/lib/flipper/cli.rb
CHANGED
|
@@ -46,9 +46,18 @@ module Flipper
|
|
|
46
46
|
c.on('-t NUM', '--percentage-of-time=NUM', Numeric, "#{action} for a percentage of time") do |num|
|
|
47
47
|
values << percentage(Types::PercentageOfTime, num)
|
|
48
48
|
end
|
|
49
|
-
c.on('-x expressions', '--expression=JSON', "#{action} for the given expression") do |
|
|
49
|
+
c.on('-x expressions', '--expression=JSON', "#{action} for the given expression") do |json|
|
|
50
50
|
begin
|
|
51
|
-
|
|
51
|
+
expression = Flipper::Expression.build(JSON.parse(json))
|
|
52
|
+
|
|
53
|
+
# Check before anything is enabled, so a bad expression doesn't
|
|
54
|
+
# leave the other values given with it half applied.
|
|
55
|
+
raise ArgumentError, "#{expression.value.inspect} is not an expression" unless expression.is_a?(Flipper::Expression)
|
|
56
|
+
if action == "enable" && expression.empty_groups?
|
|
57
|
+
raise ArgumentError, "#{expression.value.inspect} contains empty Any/All groups"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
values << expression
|
|
52
61
|
rescue JSON::ParserError => e
|
|
53
62
|
ui.error "JSON parse error #{e.message}"
|
|
54
63
|
ui.trace(e)
|
data/lib/flipper/sem_ver.rb
CHANGED
|
@@ -23,8 +23,12 @@ module Flipper
|
|
|
23
23
|
/x
|
|
24
24
|
EMPTY = [].freeze
|
|
25
25
|
|
|
26
|
-
# Returns a SemVer, or nil when the string isn't a version.
|
|
26
|
+
# Returns a SemVer, or nil when the string isn't a version. Strings with
|
|
27
|
+
# invalid bytes or in encodings that aren't ASCII compatible (like UTF-16)
|
|
28
|
+
# return nil too, since PATTERN can't match them without raising.
|
|
27
29
|
def self.parse(string)
|
|
30
|
+
return unless string.is_a?(::String) && string.valid_encoding? && string.encoding.ascii_compatible?
|
|
31
|
+
|
|
28
32
|
match = PATTERN.match(string)
|
|
29
33
|
return unless match
|
|
30
34
|
|
data/lib/flipper/test_help.rb
CHANGED
|
@@ -24,12 +24,14 @@ module Flipper
|
|
|
24
24
|
|
|
25
25
|
prune_named_test_adapters(Flipper.configuration).each do |named|
|
|
26
26
|
test_adapter = named_test_adapters[named]
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
# Clear the Memory adapter directly. Going through the named DSL can
|
|
28
|
+
# miss features a memoized list doesn't have, or reach the other store
|
|
29
|
+
# of a write-through adapter wrapping Memory.
|
|
30
|
+
Flipper.new(test_adapter[:adapter]).features.each(&:remove) if test_adapter
|
|
31
|
+
|
|
32
|
+
# Install a fresh one if the named configuration changed since we
|
|
33
|
+
# installed the test adapter (or we never did).
|
|
34
|
+
if test_adapter.nil? || test_adapter[:version] != named.version
|
|
33
35
|
install_named_test_adapter(named)
|
|
34
36
|
end
|
|
35
37
|
end
|
|
@@ -49,8 +51,13 @@ module Flipper
|
|
|
49
51
|
named_configurations.each { |named| install_named_test_adapter(named) }
|
|
50
52
|
end
|
|
51
53
|
|
|
54
|
+
# Kept on the module, not the object that includes it, so each test's
|
|
55
|
+
# flipper_reset sees the adapters flipper_configure installed at boot.
|
|
56
|
+
NAMED_TEST_ADAPTERS = {}
|
|
57
|
+
private_constant :NAMED_TEST_ADAPTERS
|
|
58
|
+
|
|
52
59
|
def named_test_adapters
|
|
53
|
-
|
|
60
|
+
NAMED_TEST_ADAPTERS
|
|
54
61
|
end
|
|
55
62
|
|
|
56
63
|
# Forget test adapters for named configurations that no longer exist and
|
data/lib/flipper/typecast.rb
CHANGED
|
@@ -82,12 +82,27 @@ module Flipper
|
|
|
82
82
|
# Returns a String.
|
|
83
83
|
def self.to_feature_name(value)
|
|
84
84
|
# U+2800 renders as a fixed-width blank but is not default-ignorable or whitespace.
|
|
85
|
-
value.to_s
|
|
85
|
+
to_utf8(value.to_s)
|
|
86
86
|
.scrub('')
|
|
87
87
|
.gsub(/[\p{Default_Ignorable_Code_Point}\p{Cc}\u2800]/, '')
|
|
88
88
|
.gsub(/\A[[:space:]]+|[[:space:]]+\z/, '')
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
+
# Private: Convert a string to UTF-8 so the unicode regexps above can
|
|
92
|
+
# match it. Binary strings are read as UTF-8, leaving scrub to drop
|
|
93
|
+
# invalid bytes. Encodings with no UTF-8 converter are read as UTF-8 only
|
|
94
|
+
# when their bytes are valid UTF-8, otherwise the name becomes empty.
|
|
95
|
+
def self.to_utf8(value)
|
|
96
|
+
return value if value.encoding == Encoding::UTF_8 || value.ascii_only?
|
|
97
|
+
return String.new(value, encoding: Encoding::UTF_8) if value.encoding == Encoding::BINARY
|
|
98
|
+
|
|
99
|
+
value.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: '')
|
|
100
|
+
rescue Encoding::ConverterNotFoundError
|
|
101
|
+
utf8 = String.new(value, encoding: Encoding::UTF_8)
|
|
102
|
+
utf8.valid_encoding? ? utf8 : ''
|
|
103
|
+
end
|
|
104
|
+
private_class_method :to_utf8
|
|
105
|
+
|
|
91
106
|
def self.features_hash(source)
|
|
92
107
|
normalized_source = {}
|
|
93
108
|
(source || {}).each do |feature_key, gates|
|
data/lib/flipper/version.rb
CHANGED
|
@@ -3,11 +3,14 @@ require 'active_support/core_ext/string/inflections'
|
|
|
3
3
|
module Flipper
|
|
4
4
|
module Generators
|
|
5
5
|
module TablePrefix
|
|
6
|
+
# Lowercase so the migration file name matches what Rails' migrator accepts.
|
|
7
|
+
FORMAT = /\A[a-z0-9_]*\z/
|
|
8
|
+
|
|
6
9
|
def self.included(generator)
|
|
7
10
|
generator.class_option :table_prefix,
|
|
8
11
|
type: :string,
|
|
9
12
|
default: '',
|
|
10
|
-
desc: 'Prefix for the flipper_features and flipper_gates tables'
|
|
13
|
+
desc: 'Prefix for the flipper_features and flipper_gates tables, such as cross_app_ (lowercase letters, numbers and underscores)'
|
|
11
14
|
end
|
|
12
15
|
|
|
13
16
|
private
|
|
@@ -24,10 +27,6 @@ module Flipper
|
|
|
24
27
|
file_name.sub('flipper', "#{table_prefix}flipper")
|
|
25
28
|
end
|
|
26
29
|
|
|
27
|
-
def migration_class_name(class_name)
|
|
28
|
-
class_name.sub('Flipper', "#{table_prefix.camelize}Flipper")
|
|
29
|
-
end
|
|
30
|
-
|
|
31
30
|
def feature_index_name
|
|
32
31
|
:"index_#{table_prefix}flipper_features_on_key" unless table_prefix.empty?
|
|
33
32
|
end
|
|
@@ -37,7 +36,11 @@ module Flipper
|
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
def table_prefix
|
|
40
|
-
options[:table_prefix].to_s
|
|
39
|
+
prefix = options[:table_prefix].to_s
|
|
40
|
+
unless FORMAT.match?(prefix)
|
|
41
|
+
raise Thor::Error, "--table-prefix must contain only lowercase letters, numbers and underscores (got #{prefix.inspect})"
|
|
42
|
+
end
|
|
43
|
+
prefix
|
|
41
44
|
end
|
|
42
45
|
end
|
|
43
46
|
end
|
data/lib/generators/flipper/templates/update/migrations/02_change_flipper_gates_value_to_text.rb.erb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
<%
|
|
4
|
-
migration_class = migration_class_name
|
|
4
|
+
migration_class = migration_class_name
|
|
5
5
|
gate_table = gate_table_name
|
|
6
6
|
gate_index = gate_index_name
|
|
7
7
|
%>class <%= migration_class %> < ActiveRecord::Migration<%= migration_version %>
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: flipper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.0
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Nunemaker
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -194,7 +194,7 @@ metadata:
|
|
|
194
194
|
homepage_uri: https://www.flippercloud.io
|
|
195
195
|
source_code_uri: https://github.com/flippercloud/flipper
|
|
196
196
|
bug_tracker_uri: https://github.com/flippercloud/flipper/issues
|
|
197
|
-
changelog_uri: https://github.com/flippercloud/flipper/releases/tag/v1.5.0
|
|
197
|
+
changelog_uri: https://github.com/flippercloud/flipper/releases/tag/v1.5.0
|
|
198
198
|
funding_uri: https://github.com/sponsors/flippercloud
|
|
199
199
|
post_install_message:
|
|
200
200
|
rdoc_options: []
|