abraham 1.3 → 1.4

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
- SHA1:
3
- metadata.gz: b64ecd0b2e348f910b5fa5f84e0e28643359bbbb
4
- data.tar.gz: 5ee3ad828fc7d5181c15673a04f7092d110fb236
2
+ SHA256:
3
+ metadata.gz: ca52c3a0aa0f4083eef1a33a1099d4e38daeab9356d7a4b627431c4946fc3909
4
+ data.tar.gz: cf910c06b3e50bd1a99e33caac9521da5483f521cf31aa2521e499d3b9868e8a
5
5
  SHA512:
6
- metadata.gz: 037376d74be78e2262aad9fc1f0a6fe2b757097c4d9a6300863eb37f723b83c2e334f9277cf6233295ef1085e11d096f2ab0c56cfd1dfca43ffbedf59983b114
7
- data.tar.gz: 075ef3d394aa0b30112e310f35663b3a6a701fee01f531a189f580e8120f7d0171ab0e66801555043da8f330bef91fd2e1f363326916508056a629b83f785fec
6
+ metadata.gz: 8982797ad163a2cd6e06d65ce1beacb97817ab2da56805bac8d39812f3c791777e0c079e8b61d3835e4f94dc13d88b23f1adc2b1ba8d9b972d574819c0f56d89
7
+ data.tar.gz: fa2b12411cde48ab87068e9cf5c038f9630777520bf23f9876a68a9c38ef55ed2c0136a845cb5f89a59cba68e489e102fbf85ad660ace22315b971da7b4f8c5d
data/README.md CHANGED
@@ -16,22 +16,25 @@ Abraham needs to know the current user to track tour views, e.g. `current_user`
16
16
 
17
17
  ## Installation
18
18
 
19
- Add `abraham` and its JavaScript dependencies to your Gemfile:
19
+ Add `abraham` to your Gemfile:
20
20
 
21
21
  ```
22
22
  gem 'abraham'
23
23
 
24
- source 'https://rails-assets.org' do
25
- gem 'rails-assets-shepherd.js', '~> 1.8'
26
- gem 'rails-assets-js-cookie', '~> 2.1'
27
- end
28
24
  ```
29
25
 
30
- Then run:
26
+ Install the gem and run the installer:
31
27
 
32
28
  ```
33
29
  $ bundle install
34
30
  $ rails generate abraham:install
31
+ $ rails db:migrate
32
+ ```
33
+
34
+ Install the JavaScript dependencies:
35
+
36
+ ```
37
+ $ yarn add jquery js-cookie shepherd.js
35
38
  ```
36
39
 
37
40
  Require `abraham` in `app/assets/javascripts/application.js`
data/Rakefile CHANGED
@@ -1,33 +1,34 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  begin
3
- require 'bundler/setup'
4
+ require "bundler/setup"
4
5
  rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
6
7
  end
7
8
 
8
- require 'rdoc/task'
9
+ require "rdoc/task"
9
10
 
10
11
  RDoc::Task.new(:rdoc) do |rdoc|
11
- rdoc.rdoc_dir = 'rdoc'
12
- rdoc.title = 'Abraham'
13
- rdoc.options << '--line-numbers'
14
- rdoc.rdoc_files.include('README.md')
15
- rdoc.rdoc_files.include('lib/**/*.rb')
12
+ rdoc.rdoc_dir = "rdoc"
13
+ rdoc.title = "Abraham"
14
+ rdoc.options << "--line-numbers"
15
+ rdoc.rdoc_files.include("README.md")
16
+ rdoc.rdoc_files.include("lib/**/*.rb")
16
17
  end
17
18
 
18
- APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
19
- load 'rails/tasks/engine.rake'
19
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
20
+ load "rails/tasks/engine.rake"
20
21
 
21
- load 'rails/tasks/statistics.rake'
22
+ load "rails/tasks/statistics.rake"
22
23
 
23
- require 'bundler/gem_tasks'
24
+ require "bundler/gem_tasks"
24
25
 
25
- require 'rake/testtask'
26
+ require "rake/testtask"
26
27
 
27
28
  Rake::TestTask.new(:test) do |t|
28
- t.libs << 'lib'
29
- t.libs << 'test'
30
- t.pattern = 'test/**/*_test.rb'
29
+ t.libs << "lib"
30
+ t.libs << "test"
31
+ t.pattern = "test/**/*_test.rb"
31
32
  t.verbose = false
32
33
  end
33
34
 
@@ -1,8 +1,6 @@
1
1
  //= require jquery
2
- //= require jquery_ujs
3
- //= require js-cookie
4
- //= require tether
5
- //= require shepherd.js.js
2
+ //= require js-cookie/src/js.cookie
3
+ //= require shepherd.js/dist/js/shepherd
6
4
 
7
5
  $(document).on('turbolinks:before-cache', function() {
8
6
  // Remove visible product tours
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class AbrahamHistoriesController < ApplicationController
3
4
  def create
4
5
  @abraham_history = AbrahamHistory.new(abraham_history_params)
@@ -14,8 +15,8 @@ class AbrahamHistoriesController < ApplicationController
14
15
 
15
16
  private
16
17
 
17
- # Never trust parameters from the scary internet, only allow the white list through.
18
- def abraham_history_params
19
- params.require(:abraham_history).permit(:controller_name, :action_name, :tour_name)
20
- end
18
+ # Never trust parameters from the scary internet, only allow the white list through.
19
+ def abraham_history_params
20
+ params.require(:abraham_history).permit(:controller_name, :action_name, :tour_name)
21
+ end
21
22
  end
@@ -1,13 +1,11 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module AbrahamHelper
3
4
  def abraham_tour
4
5
  # Do we have tours for this controller/action in the user's locale?
5
6
  tours = Rails.configuration.abraham.tours["#{controller_name}.#{action_name}.#{I18n.locale}"]
6
7
 
7
- unless tours
8
- # How about the default locale?
9
- tours = Rails.configuration.abraham.tours["#{controller_name}.#{action_name}.#{I18n.default_locale}"]
10
- end
8
+ tours ||= Rails.configuration.abraham.tours["#{controller_name}.#{action_name}.#{I18n.default_locale}"]
11
9
 
12
10
  if tours
13
11
  completed = AbrahamHistory.where(
@@ -19,10 +17,18 @@ module AbrahamHelper
19
17
 
20
18
  if remaining.any?
21
19
  # Generate the javascript snippet for the next remaining tour
22
- render(partial: 'application/abraham',
20
+ render(partial: "application/abraham",
23
21
  locals: { tour_name: remaining.first,
24
- steps: tours[remaining.first]['steps'] })
22
+ steps: tours[remaining.first]["steps"] })
25
23
  end
26
24
  end
27
25
  end
26
+
27
+ def abraham_cookie_prefix
28
+ "abraham-#{Rails.application.class.parent.to_s.underscore}-#{current_user.id}-#{controller_name}-#{action_name}"
29
+ end
30
+
31
+ def abraham_domain
32
+ request.host
33
+ end
28
34
  end
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class AbrahamHistory < ActiveRecord::Base
3
4
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class ApplicationRecord < ActiveRecord::Base
3
4
  self.abstract_class = true
4
5
  end
@@ -13,6 +13,7 @@
13
13
  dataType: "json",
14
14
  contentType: "application/json",
15
15
  data: JSON.stringify({
16
+ authenticity_token: '<%= form_authenticity_token %>',
16
17
  controller_name: '<%= controller_name %>',
17
18
  action_name: '<%= action_name %>',
18
19
  tour_name: '<%= tour_name %>'
@@ -21,7 +22,7 @@
21
22
  });
22
23
 
23
24
  tour.on("cancel", function() {
24
- Cookies.set('abraham-<%= controller_name %>-<%= action_name %>-<%= tour_name %>', 'later');
25
+ Cookies.set('<%= abraham_cookie_prefix %>-<%= tour_name %>', 'later', { domain: '<%= abraham_domain %>' });
25
26
  });
26
27
 
27
28
  <% steps.each_with_index do |(key, step), index| %>
@@ -54,7 +55,7 @@
54
55
  <% end %>
55
56
 
56
57
  // Don't start the tour if the user dismissed it once this session
57
- if (!Cookies.get('abraham-<%= controller_name %>-<%= action_name %>-<%= tour_name %>')) {
58
+ if (!Cookies.get('<%= abraham_cookie_prefix %>-<%= tour_name %>', { domain: '<%= abraham_domain %>' })) {
58
59
  tour.start();
59
60
  }
60
61
  </script>
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Rails.application.routes.draw do
3
4
  resources :abraham_histories, only: :create
4
5
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
- require 'abraham/engine'
2
+
3
+ require "abraham/engine"
3
4
 
4
5
  module Abraham
5
6
  end
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
- require 'rubygems'
2
+
3
+ require "rubygems"
3
4
 
4
5
  module Abraham
5
6
  class Engine < ::Rails::Engine
6
- require 'rails-assets-shepherd.js'
7
- require 'jquery-rails'
8
- require 'rails-assets-js-cookie'
9
7
  end
10
8
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Abraham
3
- VERSION = '1.3'
4
+ VERSION = "1.4"
4
5
  end
@@ -1,27 +1,30 @@
1
1
  # frozen_string_literal: true
2
- require 'rails/generators'
3
- require 'rails/generators/active_record'
2
+
3
+ require "rails/generators"
4
+ require "rails/generators/active_record"
4
5
 
5
6
  module Abraham
6
7
  module Generators
7
8
  class InstallGenerator < ActiveRecord::Generators::Base
8
- argument :name, type: :string, default: 'random_name'
9
+ argument :name, type: :string, default: "random_name"
9
10
 
10
11
  class_option :'skip-migration', type: :boolean, desc: "Don't generate a migration for the histories table"
11
12
  class_option :'skip-initializer', type: :boolean, desc: "Don't generate an initializer"
12
13
 
13
- source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
14
+ source_root File.expand_path(File.join(File.dirname(__FILE__), "templates"))
14
15
 
15
16
  # Copies the migration template to db/migrate.
16
17
  def copy_files
17
- return if options['skip-migration']
18
- migration_template 'migration.rb', 'db/migrate/create_abraham_histories.rb'
18
+ return if options["skip-migration"]
19
+
20
+ migration_template "migration.rb", "db/migrate/create_abraham_histories.rb"
19
21
  end
20
22
 
21
23
  def create_initializer
22
- return if options['skip-initializer']
23
- copy_file 'initializer.rb', 'config/initializers/abraham.rb'
24
- copy_file 'abraham.yml', 'config/abraham.yml'
24
+ return if options["skip-initializer"]
25
+
26
+ copy_file "initializer.rb", "config/initializers/abraham.rb"
27
+ copy_file "abraham.yml", "config/abraham.yml"
25
28
  end
26
29
  end
27
30
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  Rails.application.configure do
3
4
  tours = {}
4
5
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class CreateAbrahamHistories < ActiveRecord::Migration[5.0]
3
4
  def change
4
5
  create_table :abraham_histories do |t|
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: '1.3'
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Abbett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-20 00:00:00.000000000 Z
11
+ date: 2019-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,42 +16,22 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 5.0.0.1
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '5.0'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 5.0.0.1
33
- - !ruby/object:Gem::Dependency
34
- name: sass-rails
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '5.0'
19
+ version: '5.1'
40
20
  type: :runtime
41
21
  prerelease: false
42
22
  version_requirements: !ruby/object:Gem::Requirement
43
23
  requirements:
44
24
  - - "~>"
45
25
  - !ruby/object:Gem::Version
46
- version: '5.0'
26
+ version: '5.1'
47
27
  - !ruby/object:Gem::Dependency
48
- name: jquery-rails
28
+ name: sassc-rails
49
29
  requirement: !ruby/object:Gem::Requirement
50
30
  requirements:
51
31
  - - ">="
52
32
  - !ruby/object:Gem::Version
53
33
  version: '0'
54
- type: :runtime
34
+ type: :development
55
35
  prerelease: false
56
36
  version_requirements: !ruby/object:Gem::Requirement
57
37
  requirements:
@@ -59,35 +39,21 @@ dependencies:
59
39
  - !ruby/object:Gem::Version
60
40
  version: '0'
61
41
  - !ruby/object:Gem::Dependency
62
- name: rails-assets-shepherd.js
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '1.8'
68
- type: :runtime
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '1.8'
75
- - !ruby/object:Gem::Dependency
76
- name: rails-assets-js-cookie
42
+ name: sqlite3
77
43
  requirement: !ruby/object:Gem::Requirement
78
44
  requirements:
79
- - - "~>"
45
+ - - ">="
80
46
  - !ruby/object:Gem::Version
81
- version: '2.1'
82
- type: :runtime
47
+ version: '0'
48
+ type: :development
83
49
  prerelease: false
84
50
  version_requirements: !ruby/object:Gem::Requirement
85
51
  requirements:
86
- - - "~>"
52
+ - - ">="
87
53
  - !ruby/object:Gem::Version
88
- version: '2.1'
54
+ version: '0'
89
55
  - !ruby/object:Gem::Dependency
90
- name: sqlite3
56
+ name: rubocop
91
57
  requirement: !ruby/object:Gem::Requirement
92
58
  requirements:
93
59
  - - ">="
@@ -101,7 +67,7 @@ dependencies:
101
67
  - !ruby/object:Gem::Version
102
68
  version: '0'
103
69
  - !ruby/object:Gem::Dependency
104
- name: rubocop
70
+ name: listen
105
71
  requirement: !ruby/object:Gem::Requirement
106
72
  requirements:
107
73
  - - ">="
@@ -161,8 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
127
  - !ruby/object:Gem::Version
162
128
  version: '0'
163
129
  requirements: []
164
- rubyforge_project:
165
- rubygems_version: 2.6.14
130
+ rubygems_version: 3.0.2
166
131
  signing_key:
167
132
  specification_version: 4
168
133
  summary: Trackable application tours for Rails with i18n support, based on Shepherd.js.