rails_onboarding 0.8.12 → 0.8.13
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 593e5e47988a8b3f81d6ea034f186669a099d98b09707723ed723128bcdad01d
|
|
4
|
+
data.tar.gz: 790f85934b3f9573cc6421488b882fcf3ac80340e27a0b6b587cc2de93bcdcab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f9bc4b4bd26ace6d84e153b906a0b687035e6d0ccb1b81d13ed15f6219bcc1e7be6c02ae30aa85658fc3c79933c5a7c374243bdffc9bf0197b923172ce1c2a36
|
|
7
|
+
data.tar.gz: 1d1bed61cc8462db8e23fe1e92a114d7df9be93cc7254e6f0cecfe8d56a8fcae765ffe072769c768044f5315795510c0c9533339f9835ac57fc48213a6f83e77
|
|
@@ -7,6 +7,45 @@ module RailsOnboarding
|
|
|
7
7
|
MAX_MILESTONES_ACHIEVED = 500
|
|
8
8
|
MAX_JSON_SIZE_BYTES = 65_535 # ~64KB for TEXT columns
|
|
9
9
|
|
|
10
|
+
# Whether the host model's table can be inspected right now.
|
|
11
|
+
#
|
|
12
|
+
# `columns_hash` and `column_names` both query the database, and the
|
|
13
|
+
# `included do` block below runs the moment the host model is loaded --
|
|
14
|
+
# which can be long before that table exists. A host that references its
|
|
15
|
+
# user model from an initializer hits this immediately: the common OmniAuth
|
|
16
|
+
# `:identity` setup passes `model: User`, so the model loads during boot,
|
|
17
|
+
# the include queries `columns_hash`, and against an empty database the
|
|
18
|
+
# whole process dies with "Table 'users' doesn't exist".
|
|
19
|
+
#
|
|
20
|
+
# That is circular and unrecoverable: loading the schema requires booting
|
|
21
|
+
# the app, and booting the app requires the schema. It stops `db:prepare`
|
|
22
|
+
# bootstrapping a genuinely new database, a restore into an empty schema,
|
|
23
|
+
# and CI against a fresh database service.
|
|
24
|
+
#
|
|
25
|
+
# A missing table, a missing database and an absent connection all mean the
|
|
26
|
+
# same thing here -- the column types cannot be known yet -- so degrade
|
|
27
|
+
# instead of raising. Nothing is lost: a process that boots against an empty
|
|
28
|
+
# database is bootstrapping it, not serving from it, and the next process
|
|
29
|
+
# configures everything normally once the schema is in place.
|
|
30
|
+
#
|
|
31
|
+
# Only ever answers false when the table is positively known to be absent.
|
|
32
|
+
# This concern is deliberately includable into plain classes that are not
|
|
33
|
+
# ActiveRecord models -- hence the `respond_to?(:has_many)` and
|
|
34
|
+
# `respond_to?(:validate)` guards below -- and such a class has no
|
|
35
|
+
# `table_exists?` while still answering `columns_hash`. Saying "not
|
|
36
|
+
# available" for those would silently stop configuring them, so anything
|
|
37
|
+
# that cannot be asked is treated as queryable and left to the callers'
|
|
38
|
+
# own guards, exactly as before this check existed.
|
|
39
|
+
def self.columns_queryable?(model)
|
|
40
|
+
return true unless model.respond_to?(:table_exists?)
|
|
41
|
+
|
|
42
|
+
model.table_exists?
|
|
43
|
+
rescue ActiveRecord::NoDatabaseError,
|
|
44
|
+
ActiveRecord::ConnectionNotEstablished,
|
|
45
|
+
ActiveRecord::StatementInvalid
|
|
46
|
+
false
|
|
47
|
+
end
|
|
48
|
+
|
|
10
49
|
included do
|
|
11
50
|
# Add fields via migration or expect them in the host model
|
|
12
51
|
# The host app should have these columns:
|
|
@@ -21,17 +60,21 @@ module RailsOnboarding
|
|
|
21
60
|
# - onboarding_replay_started_at: datetime
|
|
22
61
|
# - onboarding_replay_steps: text (serialized JSON array)
|
|
23
62
|
|
|
24
|
-
# Fix for Rails 8: Use the new serialize syntax
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
63
|
+
# Fix for Rails 8: Use the new serialize syntax.
|
|
64
|
+
# Guarded because columns_hash queries the database -- see
|
|
65
|
+
# Onboardable.columns_queryable? above.
|
|
66
|
+
if RailsOnboarding::Onboardable.columns_queryable?(self)
|
|
67
|
+
if columns_hash["feature_tooltips_shown"]&.type == :text
|
|
68
|
+
serialize :feature_tooltips_shown, coder: JSON
|
|
69
|
+
end
|
|
28
70
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
71
|
+
if columns_hash["milestones_achieved"]&.type == :text
|
|
72
|
+
serialize :milestones_achieved, coder: JSON
|
|
73
|
+
end
|
|
32
74
|
|
|
33
|
-
|
|
34
|
-
|
|
75
|
+
if columns_hash["onboarding_replay_steps"]&.type == :text
|
|
76
|
+
serialize :onboarding_replay_steps, coder: JSON
|
|
77
|
+
end
|
|
35
78
|
end
|
|
36
79
|
|
|
37
80
|
# Association with analytics events (only if ActiveRecord is available)
|
|
@@ -56,6 +99,7 @@ module RailsOnboarding
|
|
|
56
99
|
# than raising on a column that isn't there.
|
|
57
100
|
def onboarding_replay_supported?
|
|
58
101
|
return false unless respond_to?(:column_names)
|
|
102
|
+
return false unless RailsOnboarding::Onboardable.columns_queryable?(self)
|
|
59
103
|
|
|
60
104
|
column_names.include?("onboarding_replay_started_at") &&
|
|
61
105
|
column_names.include?("onboarding_replay_steps")
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_onboarding
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.13
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Lewis
|
|
@@ -282,7 +282,7 @@ licenses:
|
|
|
282
282
|
metadata:
|
|
283
283
|
allowed_push_host: https://rubygems.org
|
|
284
284
|
homepage_uri: https://github.com/bunnahabhain/rails_onboarding
|
|
285
|
-
source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.
|
|
285
|
+
source_code_uri: https://github.com/bunnahabhain/rails_onboarding/tree/v0.8.13
|
|
286
286
|
changelog_uri: https://github.com/bunnahabhain/rails_onboarding/blob/master/docs/CHANGELOG.md
|
|
287
287
|
rdoc_options: []
|
|
288
288
|
require_paths:
|