abraham 2.5.0 → 2.6.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: 025f51bb1380ebbd7c172d43d66b79ca4b68fdb4eb4af6940364fff44b282176
4
- data.tar.gz: a791c10896b5f002e1aa5daa8edccd2ec810a4479aeccac4a5d8b28a52795c5d
3
+ metadata.gz: 3928683d3a3d69dc8a8d252bf34a4093527d958f66e992120895d9287f329aa2
4
+ data.tar.gz: ec22961e9019b4329fce70ae9db31b43cc5ae284c6255d3db3beacecba74fa6e
5
5
  SHA512:
6
- metadata.gz: 4e6f5e3fae2acca16748c5ace7c7fde3436e3aab72604c3e35030d5488ec389fd4903ff53a63dbdc4fe473a554853860a6d6f05e8a126bd49d7ae15f71c573b4
7
- data.tar.gz: 816fb772c290eb0504885b2e93f21d952e7322bf87c05ca3332d57c6ff81fb1e5062a93824d5d087b142c05e4efab6af2f01fdbbc12623b9b3740acb82cc4a7d
6
+ metadata.gz: 0b9236210c526f1ae9874b13892bf68da1099058c503a065af63b65f2ac61b1af03b69c391725ef227dc3c105c434d68d430e8e9c4e9ffd19654c2e774a786e9
7
+ data.tar.gz: 12a8fd782dd8d2b0c8414fd7fbff006106ceb48b44e8450458c2a808ccf4f5987b498fdc8420e4ca699e9cf6c0d1dc4e3ea90451866bd342e0099c972c74b62d
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,5 +1,5 @@
1
- //= require js-cookie/src/js.cookie
2
- //= require shepherd.js/dist/js/shepherd
1
+ //= require js.cookie
2
+ //= require shepherd.min
3
3
 
4
4
  var Abraham = new Object();
5
5
 
@@ -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.6.0"
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.6.0
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: 2023-10-26 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
@@ -130,7 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
131
  - !ruby/object:Gem::Version
131
132
  version: '0'
132
133
  requirements: []
133
- rubygems_version: 3.0.8
134
+ rubyforge_project:
135
+ rubygems_version: 2.7.6
134
136
  signing_key:
135
137
  specification_version: 4
136
138
  summary: Trackable application tours for Rails with i18n support, based on Shepherd.js.