toggly-rails 0.2.0 → 0.3.1
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/CHANGELOG.md +25 -0
- data/README.md +11 -1
- data/lib/toggly/rails/configuration.rb +7 -1
- data/lib/toggly/rails/generators/toggly/install/install_generator.rb +4 -1
- data/lib/toggly/rails/testing.rb +4 -4
- data/lib/toggly/rails/version.rb +1 -1
- data/lib/toggly/rails/view_helpers.rb +20 -8
- data/lib/toggly-rails.rb +3 -2
- 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: e875e3adc013c895862f6789a17d979de7536e1dea48170ab7eeb055b223b0d9
|
|
4
|
+
data.tar.gz: 7c6e86dcc19a82100149c96fe4f13b9b5b60277193175e767eb72e6eaa21bc28
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fd75cf0d95a8e4adb4464a6822f38faf004ef410f94912a62f58cb5fb0b3d56f08cb305390136b0a49ce253fe4b021ea98be842bfd052aea6ac7a714402ad222
|
|
7
|
+
data.tar.gz: 4d81b7d3132ec766130fddaa8b7a389481b92656bfee9ce4773caabf8cafb3c489fdf165a6049071273fbeaab3556002ce1a48e16d9aa8aee66d2c67814eb0ac
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.3.1] - 2026-09-16
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Forward telemetry options (`enable_usage_tracking`, `enable_metrics`,
|
|
13
|
+
flush intervals) onto core `Toggly::Config`. A live `app_key` with no
|
|
14
|
+
`TOGGLY_DISABLE_TELEMETRY=1` now enables usage with the core ~60s flush.
|
|
15
|
+
|
|
16
|
+
## [0.3.0] - 2026-09-12
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Add the canonical `feature(feature_key, context: nil, negate: false)` view helper, capturing only the selected ActionView block.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Keep `when_feature_enabled` and `when_feature_disabled` as deprecated compatibility adapters to `feature`.
|
|
25
|
+
|
|
26
|
+
## [0.2.1] - 2026-09-03
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
|
|
30
|
+
- Raise required Ruby version to 3.2+ (matches Gemfile.lock Bundler and CI).
|
|
31
|
+
- Use anonymous block forwarding in Rails testing and view helpers (RuboCop for Ruby 3.2+).
|
|
32
|
+
|
|
8
33
|
## [0.2.0] - 2026-08-21
|
|
9
34
|
|
|
10
35
|
### Added
|
data/README.md
CHANGED
|
@@ -40,11 +40,21 @@ end
|
|
|
40
40
|
### Views
|
|
41
41
|
|
|
42
42
|
```erb
|
|
43
|
-
|
|
43
|
+
<%= feature(:promo) do %>
|
|
44
44
|
<div class="promo">Special offer!</div>
|
|
45
45
|
<% end %>
|
|
46
|
+
|
|
47
|
+
<%= feature(:promo, negate: true) do %>
|
|
48
|
+
<div class="standard">Standard offer</div>
|
|
49
|
+
<% end %>
|
|
46
50
|
```
|
|
47
51
|
|
|
52
|
+
Use the same feature key and context for both blocks. `feature` captures only
|
|
53
|
+
the selected block, and `negate: true` selects the complementary branch.
|
|
54
|
+
`when_feature_enabled` and `when_feature_disabled` remain available as
|
|
55
|
+
deprecated compatibility adapters. Boolean helpers and `feature_switch` are
|
|
56
|
+
unchanged.
|
|
57
|
+
|
|
48
58
|
## Documentation
|
|
49
59
|
|
|
50
60
|
See the [main README](../README.md) for full documentation.
|
|
@@ -12,7 +12,9 @@ module Toggly
|
|
|
12
12
|
:refresh_interval, :http_timeout,
|
|
13
13
|
:enable_undefined_in_dev, :disable_background_refresh,
|
|
14
14
|
:app_version, :instance_name, :defaults,
|
|
15
|
-
:snapshot_provider, :use_signed_definitions, :allowed_key_ids
|
|
15
|
+
:snapshot_provider, :use_signed_definitions, :allowed_key_ids,
|
|
16
|
+
:enable_usage_tracking, :enable_metrics,
|
|
17
|
+
:usage_flush_interval, :metrics_flush_interval
|
|
16
18
|
|
|
17
19
|
# Rails-specific options
|
|
18
20
|
|
|
@@ -75,6 +77,10 @@ module Toggly
|
|
|
75
77
|
config.defaults = defaults
|
|
76
78
|
config.use_signed_definitions = use_signed_definitions
|
|
77
79
|
config.allowed_key_ids = allowed_key_ids
|
|
80
|
+
config.enable_usage_tracking = enable_usage_tracking unless enable_usage_tracking.nil?
|
|
81
|
+
config.enable_metrics = enable_metrics unless enable_metrics.nil?
|
|
82
|
+
config.usage_flush_interval = usage_flush_interval unless usage_flush_interval.nil?
|
|
83
|
+
config.metrics_flush_interval = metrics_flush_interval unless metrics_flush_interval.nil?
|
|
78
84
|
|
|
79
85
|
# Set up snapshot provider
|
|
80
86
|
config.snapshot_provider = build_snapshot_provider
|
|
@@ -37,9 +37,12 @@ module Toggly
|
|
|
37
37
|
say " end"
|
|
38
38
|
say ""
|
|
39
39
|
say "Usage in views:"
|
|
40
|
-
say "
|
|
40
|
+
say " <%= feature(:my_feature) do %>"
|
|
41
41
|
say " Feature content"
|
|
42
42
|
say " <% end %>"
|
|
43
|
+
say " <%= feature(:my_feature, negate: true) do %>"
|
|
44
|
+
say " Standard content"
|
|
45
|
+
say " <% end %>"
|
|
43
46
|
say ""
|
|
44
47
|
end
|
|
45
48
|
|
data/lib/toggly/rails/testing.rb
CHANGED
|
@@ -82,16 +82,16 @@ module Toggly
|
|
|
82
82
|
#
|
|
83
83
|
# @param feature_key [String, Symbol] Feature key
|
|
84
84
|
# @yield Block during which the feature is enabled
|
|
85
|
-
def enable_feature(feature_key, &
|
|
86
|
-
with_feature(feature_key, enabled: true, &
|
|
85
|
+
def enable_feature(feature_key, &)
|
|
86
|
+
with_feature(feature_key, enabled: true, &)
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# Disable a feature for the duration of a block
|
|
90
90
|
#
|
|
91
91
|
# @param feature_key [String, Symbol] Feature key
|
|
92
92
|
# @yield Block during which the feature is disabled
|
|
93
|
-
def disable_feature(feature_key, &
|
|
94
|
-
with_feature(feature_key, enabled: false, &
|
|
93
|
+
def disable_feature(feature_key, &)
|
|
94
|
+
with_feature(feature_key, enabled: false, &)
|
|
95
95
|
end
|
|
96
96
|
|
|
97
97
|
# RSpec helpers
|
data/lib/toggly/rails/version.rb
CHANGED
|
@@ -30,28 +30,40 @@ module Toggly
|
|
|
30
30
|
!feature_enabled?(feature_key, context: context)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
+
# Render content when the feature evaluation matches the requested branch
|
|
34
|
+
#
|
|
35
|
+
# @param feature_key [String, Symbol] Feature key
|
|
36
|
+
# @param context [Toggly::Context, nil] Optional override context
|
|
37
|
+
# @param negate [Boolean] Render when the feature is disabled
|
|
38
|
+
# @yield Content to render for the selected branch
|
|
39
|
+
# @return [String, nil]
|
|
40
|
+
def feature(feature_key, context: nil, negate: false, &)
|
|
41
|
+
enabled = feature_enabled?(feature_key, context: context)
|
|
42
|
+
return unless negate ? !enabled : enabled
|
|
43
|
+
|
|
44
|
+
capture(&) if block_given?
|
|
45
|
+
end
|
|
46
|
+
|
|
33
47
|
# Render content only if feature is enabled
|
|
34
48
|
#
|
|
49
|
+
# @deprecated Use {#feature}.
|
|
35
50
|
# @param feature_key [String, Symbol] Feature key
|
|
36
51
|
# @param context [Toggly::Context, nil] Optional override context
|
|
37
52
|
# @yield Content to render when enabled
|
|
38
53
|
# @return [String, nil]
|
|
39
|
-
def when_feature_enabled(feature_key, context: nil, &
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
capture(&block) if block_given?
|
|
54
|
+
def when_feature_enabled(feature_key, context: nil, &)
|
|
55
|
+
feature(feature_key, context: context, negate: false, &)
|
|
43
56
|
end
|
|
44
57
|
|
|
45
58
|
# Render content only if feature is disabled
|
|
46
59
|
#
|
|
60
|
+
# @deprecated Use {#feature} with +negate: true+.
|
|
47
61
|
# @param feature_key [String, Symbol] Feature key
|
|
48
62
|
# @param context [Toggly::Context, nil] Optional override context
|
|
49
63
|
# @yield Content to render when disabled
|
|
50
64
|
# @return [String, nil]
|
|
51
|
-
def when_feature_disabled(feature_key, context: nil, &
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
capture(&block) if block_given?
|
|
65
|
+
def when_feature_disabled(feature_key, context: nil, &)
|
|
66
|
+
feature(feature_key, context: context, negate: true, &)
|
|
55
67
|
end
|
|
56
68
|
|
|
57
69
|
# Render enabled or disabled content based on feature state
|
data/lib/toggly-rails.rb
CHANGED
|
@@ -32,9 +32,10 @@ module Toggly
|
|
|
32
32
|
# end
|
|
33
33
|
#
|
|
34
34
|
# @example View usage
|
|
35
|
-
#
|
|
35
|
+
# <%= feature(:new_header) do %>
|
|
36
36
|
# <%= render "new_header" %>
|
|
37
|
-
# <%
|
|
37
|
+
# <% end %>
|
|
38
|
+
# <%= feature(:new_header, negate: true) do %>
|
|
38
39
|
# <%= render "header" %>
|
|
39
40
|
# <% end %>
|
|
40
41
|
module Rails
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: toggly-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ops.ai
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: railties
|
|
@@ -79,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
79
79
|
requirements:
|
|
80
80
|
- - ">="
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 3.
|
|
82
|
+
version: 3.2.0
|
|
83
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
requirements:
|
|
85
85
|
- - ">="
|