flipper-notifications 0.1.10 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f6ffe2530157b223628713342f83960c5a89dc2a8fca928df146c9553552279
4
- data.tar.gz: c4fba936bef2a2629c6171bfd2418a08c7b8b379b12b87cbcc97808f0b8a4815
3
+ metadata.gz: 7ebe2222f7ac1c82c9f61744dc46e24bef7e4a2ab7810897e60ccbde80af881f
4
+ data.tar.gz: 0f6f376af814b3ca684a6e81ff7785fb8333bc90e852f765c052407bdc681fd6
5
5
  SHA512:
6
- metadata.gz: c576ff049c4ff0000dc628793e293a83e6a8814d0d73278bb62094207133c64860f0dc43028a800fd6e2b0072ff86a7bf01a790b20b70db5055eda9e73ca4ec9
7
- data.tar.gz: 54d2344c796fbafa721d18e55cfc68d46bd703df8a7b06bb9e5ef38b27171c144fb9757492ce26428937febaa6bdeeae2c24abdb07aa4243db7866153ad8cc55
6
+ metadata.gz: a19b0d90814fb2ceacea8951fcadf46d9073418bfee82aab5a6142b9b48e1986739cd895d06860094c4c854f875654de8373d01d2d25f3fffdf7f9abb238bfdb
7
+ data.tar.gz: e1baaed8d9a84743ff65b860dc7da007d57cb7be52a6fdadfe44b06a1c854db748e33b00a6379ecc1d460b29289f23ff3e65cb7c7106dc2f38c1b60334c7fc20
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  matrix:
18
18
  ruby_version:
19
- - 3.2
19
+ - '.ruby-version'
20
20
  steps:
21
21
  - uses: actions/checkout@v2
22
22
  - name: Set up Ruby
@@ -16,8 +16,9 @@ jobs:
16
16
  strategy:
17
17
  matrix:
18
18
  ruby_version:
19
- - '3.1'
20
- - '3.2'
19
+ - '3.3'
20
+ - '.ruby-version'
21
+
21
22
  steps:
22
23
  - uses: actions/checkout@v2
23
24
  - name: Set up Ruby
@@ -22,8 +22,6 @@ jobs:
22
22
  - uses: actions/checkout@v2
23
23
  - name: Set up Ruby
24
24
  uses: ruby/setup-ruby@v1
25
- with:
26
- ruby-version: 3.1
27
25
  - name: Install dependencies
28
26
  run: bundle install
29
27
  - name: Run Rubocop
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.2
1
+ 3.4.13
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flipper-notifications (0.1.10)
4
+ flipper-notifications (0.2.0)
5
5
  activesupport (>= 7, < 8.2)
6
6
  flipper (>= 0.24, < 2.0)
7
7
  httparty (~> 0.17)
@@ -9,21 +9,31 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activejob (7.0.4)
13
- activesupport (= 7.0.4)
12
+ activejob (7.0.10)
13
+ activesupport (= 7.0.10)
14
14
  globalid (>= 0.3.6)
15
- activesupport (7.0.4)
15
+ activesupport (7.0.10)
16
+ base64
17
+ benchmark (>= 0.3)
18
+ bigdecimal
16
19
  concurrent-ruby (~> 1.0, >= 1.0.2)
20
+ drb
17
21
  i18n (>= 1.6, < 2)
22
+ logger (>= 1.4.2)
18
23
  minitest (>= 5.1)
24
+ mutex_m
25
+ securerandom (>= 0.3)
19
26
  tzinfo (~> 2.0)
20
- addressable (2.8.1)
21
- public_suffix (>= 2.0.2, < 6.0)
22
- ast (2.4.2)
27
+ addressable (2.9.2)
28
+ public_suffix (>= 2.0.2, < 8.0)
29
+ ast (2.4.3)
30
+ base64 (0.3.0)
31
+ benchmark (0.5.0)
23
32
  bigdecimal (3.1.9)
24
33
  bundler-gem_version_tasks (0.2.1)
25
34
  concurrent-ruby (1.2.3)
26
- crack (0.4.5)
35
+ crack (1.0.1)
36
+ bigdecimal
27
37
  rexml
28
38
  csv (3.3.2)
29
39
  debug (1.7.1)
@@ -31,11 +41,12 @@ GEM
31
41
  reline (>= 0.3.1)
32
42
  diff-lcs (1.5.0)
33
43
  docile (1.4.0)
44
+ drb (2.2.3)
34
45
  flipper (1.3.2)
35
46
  concurrent-ruby (< 2)
36
47
  globalid (1.0.0)
37
48
  activesupport (>= 5.0)
38
- hashdiff (1.0.1)
49
+ hashdiff (1.2.2)
39
50
  httparty (0.22.0)
40
51
  csv
41
52
  mini_mime (>= 1.0.0)
@@ -45,21 +56,29 @@ GEM
45
56
  io-console (0.6.0)
46
57
  irb (1.6.2)
47
58
  reline (>= 0.3.0)
48
- json (2.6.3)
59
+ json (3.1.0)
60
+ language_server-protocol (3.17.0.6)
61
+ lint_roller (1.1.0)
62
+ logger (1.7.0)
49
63
  mini_mime (1.1.5)
50
64
  minitest (5.22.3)
51
65
  multi_xml (0.7.1)
52
66
  bigdecimal (~> 3.1)
53
- parallel (1.22.1)
54
- parser (3.1.3.0)
67
+ mutex_m (0.3.0)
68
+ parallel (2.3.0)
69
+ parser (3.3.14.0)
55
70
  ast (~> 2.4.1)
56
- public_suffix (5.0.1)
71
+ racc
72
+ prism (2.1.0-arm64-darwin)
73
+ prism (2.1.0-x86_64-linux-gnu)
74
+ public_suffix (7.0.5)
75
+ racc (1.8.1)
57
76
  rainbow (3.1.1)
58
77
  rake (13.0.6)
59
- regexp_parser (2.6.1)
78
+ regexp_parser (2.13.4)
60
79
  reline (0.3.2)
61
80
  io-console (~> 0.5)
62
- rexml (3.2.5)
81
+ rexml (3.4.4)
63
82
  rspec (3.12.0)
64
83
  rspec-core (~> 3.12.0)
65
84
  rspec-expectations (~> 3.12.0)
@@ -73,19 +92,24 @@ GEM
73
92
  diff-lcs (>= 1.2.0, < 2.0)
74
93
  rspec-support (~> 3.12.0)
75
94
  rspec-support (3.12.0)
76
- rubocop (1.41.1)
77
- json (~> 2.3)
78
- parallel (~> 1.10)
79
- parser (>= 3.1.2.1)
95
+ rubocop (1.92.3)
96
+ json (>= 2.3)
97
+ language_server-protocol (~> 3.17.0.2)
98
+ lint_roller (~> 1.1.0)
99
+ parallel (>= 1.10)
100
+ parser (>= 3.3.0.2)
80
101
  rainbow (>= 2.2.2, < 4.0)
81
- regexp_parser (>= 1.8, < 3.0)
82
- rexml (>= 3.2.5, < 4.0)
83
- rubocop-ast (>= 1.23.0, < 2.0)
102
+ regexp_parser (>= 2.11.3, < 3.0)
103
+ rubocop-ast (>= 1.49.0, < 2.0)
84
104
  ruby-progressbar (~> 1.7)
85
- unicode-display_width (>= 1.4.0, < 3.0)
86
- rubocop-ast (1.24.0)
87
- parser (>= 3.1.1.0)
88
- ruby-progressbar (1.11.0)
105
+ unicode-display_width (>= 2.4.0, < 4.0)
106
+ rubocop-ast (1.53.0)
107
+ ast (~> 2.4)
108
+ parser (>= 3.3.7.2)
109
+ prism (>= 1.7)
110
+ racc
111
+ ruby-progressbar (1.13.0)
112
+ securerandom (0.4.1)
89
113
  simplecov (0.21.2)
90
114
  docile (~> 1.1)
91
115
  simplecov-html (~> 0.11)
@@ -94,8 +118,10 @@ GEM
94
118
  simplecov_json_formatter (0.1.4)
95
119
  tzinfo (2.0.6)
96
120
  concurrent-ruby (~> 1.0)
97
- unicode-display_width (2.3.0)
98
- webmock (3.18.1)
121
+ unicode-display_width (3.3.0)
122
+ unicode-emoji (~> 4.3)
123
+ unicode-emoji (4.3.0)
124
+ webmock (3.35.0)
99
125
  addressable (>= 2.8.0)
100
126
  crack (>= 0.3.2)
101
127
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -104,6 +130,7 @@ PLATFORMS
104
130
  arm64-darwin-21
105
131
  arm64-darwin-23
106
132
  arm64-darwin-24
133
+ arm64-darwin-25
107
134
  x86_64-linux
108
135
 
109
136
  DEPENDENCIES
data/README.md CHANGED
@@ -23,7 +23,7 @@ Or install it yourself as:
23
23
 
24
24
  ## Dependencies
25
25
 
26
- * Ruby 3
26
+ * Ruby 3.3+
27
27
  * ActiveSupport 7+
28
28
 
29
29
  This gem is designed to work within a Rails app. At the very least, you will
@@ -53,6 +53,34 @@ Flipper::Notifications.configure do |config|
53
53
  end
54
54
  ```
55
55
 
56
+ ### Stale State with Cached Adapters
57
+
58
+ Notifications are rendered inside a background job (`WebhookNotificationJob`),
59
+ which may run in a **different process** from the one that changed the feature.
60
+ The message ("The feature is now fully enabled/disabled", the list of groups,
61
+ actors, and percentages) is built by reading the feature's current state at
62
+ job-run time.
63
+
64
+ If your Flipper adapter is fronted by a **per-process cache** — for example an
65
+ in-memory `ActiveSupportCacheStore` layer — the process running the job can hold
66
+ a stale value: enabling a feature in your web process does not invalidate a
67
+ worker's in-memory cache. The notification then reports the wrong state.
68
+
69
+ By default state is read through the global `Flipper`. Point `config.flipper` at
70
+ a cache-free instance backed by your source of truth so notifications always
71
+ render the real value:
72
+
73
+ ```ruby
74
+ # config/initializers/flipper.rb
75
+
76
+ Flipper::Notifications.configure do |config|
77
+ config.flipper = Flipper.new(Flipper::Adapters::ActiveRecord.new)
78
+ end
79
+ ```
80
+
81
+ This only affects how notifications **read** state; your application keeps using
82
+ its cached `Flipper` everywhere else.
83
+
56
84
  ### Slack invalid_blocks Errors
57
85
 
58
86
  Slack limits the size of webhook messages. The Slack API returns a 400 status
@@ -162,6 +190,7 @@ git checkout main
162
190
  git pull
163
191
  bundle exec rake version:bump:<major, minor, or patch>
164
192
  bundle exec rubocop -a
193
+ bundle install --gemfile=spec/rails/defaults/Gemfile
165
194
  git commit -a --amend --no-edit
166
195
  bundle exec rake release
167
196
  ```
@@ -14,6 +14,8 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://github.com/wrapbook/flipper-notifications"
15
15
  spec.license = "MIT"
16
16
 
17
+ spec.required_ruby_version = ">= 3.3"
18
+
17
19
  spec.metadata["homepage_uri"] = spec.homepage
18
20
  spec.metadata["source_code_uri"] = spec.homepage
19
21
  spec.metadata["changelog_uri"] = "#{spec.homepage}/releases"
@@ -8,14 +8,31 @@ module Flipper
8
8
  @enabled = false
9
9
  @notifiers = []
10
10
  @webhook_character_limit = nil
11
+ @flipper = nil
11
12
  end
12
13
 
13
14
  attr_accessor :enabled, :notifiers, :webhook_character_limit
15
+ attr_writer :flipper
14
16
 
15
17
  def enabled?
16
18
  @enabled
17
19
  end
18
20
 
21
+ # The Flipper instance used to READ feature state when rendering a
22
+ # notification. Defaults to the global `Flipper`.
23
+ #
24
+ # Notifications are rendered in a background job, which may run in a
25
+ # different process from the one that changed the feature. If your Flipper
26
+ # adapter is fronted by a per-process cache (e.g. an in-memory
27
+ # ActiveSupportCacheStore), the reading process can hold a stale value and
28
+ # the message reports the wrong state. Point this at a cache-free instance
29
+ # backed by your source of truth to always render the real value, e.g.:
30
+ #
31
+ # config.flipper = Flipper.new(Flipper::Adapters::ActiveRecord.new)
32
+ def flipper
33
+ @flipper || Flipper
34
+ end
35
+
19
36
  end
20
37
  end
21
38
  end
@@ -20,14 +20,14 @@ module Flipper
20
20
  end
21
21
 
22
22
  def initialize(feature_name:, operation:)
23
- @feature = Flipper.feature(feature_name)
23
+ @feature = Flipper::Notifications.configuration.flipper.feature(feature_name)
24
24
  @operation = operation.to_s
25
25
  end
26
26
 
27
27
  attr_reader :feature, :operation
28
28
 
29
29
  def summary_markdown
30
- msg = String.new("Feature *#{feature.name}* was #{action_taken}.")
30
+ msg = "Feature *#{feature.name}* was #{action_taken}."
31
31
 
32
32
  if include_state?
33
33
  msg << " The feature is now *fully enabled.*" if feature.on?
@@ -7,10 +7,10 @@ module Flipper
7
7
  module Notifications
8
8
  class FeaturesSubscriber
9
9
 
10
- def call(*args)
10
+ def call(*)
11
11
  return unless enabled?
12
12
 
13
- event = FeatureEvent.from_active_support(event: ActiveSupport::Notifications::Event.new(*args))
13
+ event = FeatureEvent.from_active_support(event: ActiveSupport::Notifications::Event.new(*))
14
14
  Flipper::Notifications.notify(event: event) if event.noteworthy?
15
15
  end
16
16
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Flipper
4
4
  module Notifications
5
- VERSION = "0.1.10"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper-notifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Lubrano
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-06-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -196,7 +195,6 @@ dependencies:
196
195
  - - "<"
197
196
  - !ruby/object:Gem::Version
198
197
  version: '8.2'
199
- description:
200
198
  email:
201
199
  - jlubrano@wrapbook.com
202
200
  executables: []
@@ -241,7 +239,6 @@ metadata:
241
239
  homepage_uri: https://github.com/wrapbook/flipper-notifications
242
240
  source_code_uri: https://github.com/wrapbook/flipper-notifications
243
241
  changelog_uri: https://github.com/wrapbook/flipper-notifications/releases
244
- post_install_message:
245
242
  rdoc_options: []
246
243
  require_paths:
247
244
  - lib
@@ -249,15 +246,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
249
246
  requirements:
250
247
  - - ">="
251
248
  - !ruby/object:Gem::Version
252
- version: '0'
249
+ version: '3.3'
253
250
  required_rubygems_version: !ruby/object:Gem::Requirement
254
251
  requirements:
255
252
  - - ">="
256
253
  - !ruby/object:Gem::Version
257
254
  version: '0'
258
255
  requirements: []
259
- rubygems_version: 3.5.9
260
- signing_key:
256
+ rubygems_version: 3.6.9
261
257
  specification_version: 4
262
258
  summary: Rails-compatible Slack notifications for Flipper feature flags
263
259
  test_files: []