shepherd-rails 0.0.2 → 0.0.4

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: 6bafe26b63e37606b54d3893f6ee8d1a48dd843293b53b1cbbc2aba6bdd2cc2b
4
- data.tar.gz: 4c02327f39a5ff6cd418680071c5787b2a4633d6855c8d41765c79738d07d354
3
+ metadata.gz: d863f2b6d490cf748b5a78fbfbda547d0c829b706f689c41b42325427f40b760
4
+ data.tar.gz: 5e69af20b3a81ac0c600ea0bd35863d82a4603c474505a29ea22a2d6d750d97f
5
5
  SHA512:
6
- metadata.gz: ac5b8037f51f7f79684b2d715214694674e8b341299f4699e95c1162ce1b3218c6f4421a0c6d6b678af3ab4d57f097c28154aaa5f9dededb38b05519d75a28b4
7
- data.tar.gz: c7b74234dc1d462c989ff22a1a336049ea87c11253b681ed7aa2b8bac860734eb81d414a894757aa76db5425309a856c48aa6e01f947b801f9098ac6a2286dfb
6
+ metadata.gz: 40937cbdd4726100f5164042d816dbc5b9b04d9e1962104a717a702ce0bd0a445e2ffdc8dcb8d90be1e50d324566cb8c2c4f5d06ec045ccc8efd8d7c508e8ae9
7
+ data.tar.gz: fdb9cd09216b475a3ff74a8402c37b39c994ae6839a928558e72085805cea69fd6dfa8945885db109191a804694b1e8e278b4d9282e830e801660d545441c91a
@@ -1,10 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ShepherdRails
2
4
  class TourStatusesController < ShepherdRails.configuration.base_controller.constantize
5
+ protect_from_forgery with: :null_session
6
+
3
7
  def create
4
8
  tour_name = params.require(:tour)
9
+ context = params.to_unsafe_h[:context].to_h.with_indifferent_access
5
10
  case params.require(:event)
6
11
  when 'complete'
7
- ShepherdRails.configuration.on_tour_complete.call(self, tour_name)
12
+ ShepherdRails.configuration.on_tour_complete.call(context, tour_name)
8
13
  end
9
14
 
10
15
  head :ok
@@ -2,12 +2,13 @@
2
2
 
3
3
  module ShepherdRails
4
4
  module ApplicationHelper
5
- def shepherd_tour tour:
5
+ def shepherd_tour tour:, context: {}
6
6
  tag.div nil, data: {
7
7
  controller: 'shepherd-rails',
8
8
  'shepherd-rails-tour-name-value' => tour,
9
9
  'shepherd-rails-endpoint-value' => shepherd_rails.tour_statuses_path,
10
- 'shepherd-rails-config-value' => I18n.t(tour, scope: 'shepherd_rails')
10
+ 'shepherd-rails-config-value' => I18n.t(tour, scope: 'shepherd_rails'),
11
+ 'shepherd-rails-context-value' => context
11
12
  }
12
13
  end
13
14
  end
@@ -1,4 +1,4 @@
1
1
  ShepherdRails.configure do |config|
2
- # config.on_tour_complete = ->(controller, tour_name) { controller.do_something tour_name }
2
+ # config.on_tour_complete = ->(context, tour_name) { Model.find(context[:model_id].do_something tour_name }
3
3
  # config.base_controller = 'ApplicationController'
4
4
  end
@@ -1,6 +1,6 @@
1
1
  module ShepherdRails
2
2
  class Config
3
- cattr_accessor :on_tour_complete, default: ->(_ctx) { puts 'Here' }
3
+ cattr_accessor :on_tour_complete, default: ->(context, tour_name) { puts "Completed tour #{tour_name} - context: #{context.inspect}" }
4
4
  cattr_accessor :base_controller, default: 'ActionController::Base'
5
5
  end
6
6
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ShepherdRails
2
- VERSION = '0.0.2'
4
+ VERSION = '0.0.4'
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shepherd-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Catalin Ionescu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-15 00:00:00.000000000 Z
11
+ date: 2023-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails