abraham 2.5.0 → 2.5.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: 025f51bb1380ebbd7c172d43d66b79ca4b68fdb4eb4af6940364fff44b282176
4
- data.tar.gz: a791c10896b5f002e1aa5daa8edccd2ec810a4479aeccac4a5d8b28a52795c5d
3
+ metadata.gz: 3f58e765abccdc1ca54c84235af22089873e9d3a5de2b4e862a85273f58d56a9
4
+ data.tar.gz: a8e6aafc28d11ebbb4c593c010d0d5eb5a9b204897394286bd1cdc3a5b4e67ef
5
5
  SHA512:
6
- metadata.gz: 4e6f5e3fae2acca16748c5ace7c7fde3436e3aab72604c3e35030d5488ec389fd4903ff53a63dbdc4fe473a554853860a6d6f05e8a126bd49d7ae15f71c573b4
7
- data.tar.gz: 816fb772c290eb0504885b2e93f21d952e7322bf87c05ca3332d57c6ff81fb1e5062a93824d5d087b142c05e4efab6af2f01fdbbc12623b9b3740acb82cc4a7d
6
+ metadata.gz: 05f6395978a18eb6cdfec2acae497620fdeee810e63fc3c78a314424b5d5f613017627bbad83182e8e42bb6fb0c0fe945f12cb6e28ee56794dc180014883267e
7
+ data.tar.gz: cc2846b357694af6e720cdc87d081968625f76870090116d056a7d5ace468bb6077231f5fb8e061b650a4c1fed6ee6e6d14d19c9ffe999d42ec5348d3fc4c3b3
data/README.md CHANGED
@@ -207,6 +207,29 @@ my_tour:
207
207
  * `action` is one of the Shepherd tour method names, i.e. `cancel`, `next`, or `complete`
208
208
  * `classes` are the CSS class names you want applied to the button
209
209
 
210
+ ### Flipper integration
211
+
212
+ If you have [Flipper](https://github.com/jnunemaker/flipper) installed as a dependency in your project you will be able to enable or disable tours based on a flipper using the `flipper_key` option. This will automatically enable a tour when this flipper is active and disable it when it's inactive.
213
+
214
+ ```yml
215
+ walkthrough:
216
+ flipper_key: "name_of_flipper"
217
+ steps:
218
+ 1:
219
+ text: "This walkthrough will show you how to..."
220
+ ```
221
+
222
+ If you would like to disable a tour when a flipper is active you may couple the `flipper_key` option with the `flipper_activation` option. `flipper_activation` supports "enabled" or "disabled" as options. If you enter something other than "enabled" or "disabled" it will use the default, which is "enabled".
223
+
224
+ ```yml
225
+ walkthrough:
226
+ flipper_key: "name_of_flipper"
227
+ flipper_activation: "disabled"
228
+ steps:
229
+ 1:
230
+ text: "This walkthrough will show you how to..."
231
+ ```
232
+
210
233
  ### Testing your tours
211
234
 
212
235
  Abraham loads tour definitions once when you start your server. Restart your server to see tour changes.
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AbrahamHelper
4
+ include FlipperHelper
5
+
4
6
  def abraham_tour
5
7
  # Do we have tours for this controller/action in the user's locale?
6
8
  tours = Rails.configuration.abraham.tours["#{controller_path}.#{action_name}.#{I18n.locale}"]
@@ -21,11 +23,16 @@ module AbrahamHelper
21
23
  tour_html = ''
22
24
 
23
25
  tour_keys.each do |key|
24
- tour_html += render(partial: "application/abraham",
25
- locals: { tour_name: key,
26
- tour_completed: tour_keys_completed.include?(key),
27
- trigger: tours[key]["trigger"],
28
- steps: tours[key]["steps"] })
26
+ flipper_key = tours[key]["flipper_key"]
27
+ flipper_activation = tours[key]["flipper_activation"]
28
+
29
+ if should_add_tour(flipper_key, flipper_activation)
30
+ tour_html += render(partial: "application/abraham",
31
+ locals: { tour_name: key,
32
+ tour_completed: tour_keys_completed.include?(key),
33
+ trigger: tours[key]["trigger"],
34
+ steps: tours[key]["steps"] })
35
+ end
29
36
  end
30
37
 
31
38
  tour_html.html_safe
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FlipperHelper
4
+ def should_add_tour(flipper_key, flipper_activation)
5
+ return true if !flipper_defined?
6
+
7
+ case process_activation_option(flipper_activation)
8
+ when "enabled"
9
+ return (flipper_key && Flipper.enabled?(flipper_key.to_sym)) || flipper_key.nil?
10
+ when "disabled"
11
+ return (flipper_key && !Flipper.enabled?(flipper_key.to_sym)) || flipper_key.nil?
12
+ else
13
+ return false
14
+ end
15
+ end
16
+
17
+ private
18
+ def flipper_defined?
19
+ Object.const_defined?("Flipper")
20
+ end
21
+
22
+ def process_activation_option(flipper_activation)
23
+ return "disabled" if flipper_activation == "disabled"
24
+ "enabled"
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Abraham
4
- VERSION = "2.5.0"
4
+ VERSION = "2.5.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abraham
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Abbett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-17 00:00:00.000000000 Z
11
+ date: 2022-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sassc-rails
@@ -96,6 +96,7 @@ files:
96
96
  - app/assets/stylesheets/abraham/theme-default.scss
97
97
  - app/controllers/abraham_histories_controller.rb
98
98
  - app/helpers/abraham_helper.rb
99
+ - app/helpers/flipper_helper.rb
99
100
  - app/models/abraham_history.rb
100
101
  - app/models/application_record.rb
101
102
  - app/views/application/_abraham.html.erb