alchemy_cms 6.0.4 → 6.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/alchemy/upgrader/tasks/ingredients_migrator.rb +35 -25
- data/lib/alchemy/version.rb +1 -1
- data/package.json +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5eb21e30df422e1b214dd34d5d6166d8aaf195d393590efdf1e6a16a1247910
|
4
|
+
data.tar.gz: aa579d8246cfc7952a2f2491c86a78e272733eb7c21d993d4302201ee2b1a3f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b92efbc92492ccbc49ff95249672d5083499898d6ce70644b68a44fdc49720a716986c138211c308c1e3cf3a7b614db6d04a9463399c81c8167b31622aa1f5c
|
7
|
+
data.tar.gz: 4d297aea832eeea8b51183b234bcad0cacc168283e07f1d83ca180e1a59fb02601756869e74c3348f10b14308a62e660d6dd2b0a04251da51b4c574435e4518a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 6.0.5 (2022-05-11)
|
2
|
+
|
3
|
+
- Extract element ingredient migrator [#2337](https://github.com/AlchemyCMS/alchemy_cms/pull/2337) ([tvdeyen](https://github.com/tvdeyen))
|
4
|
+
|
1
5
|
## 6.0.4 (2022-05-06)
|
2
6
|
|
3
7
|
- Add support for Rails' recycable cache keys [#2334](https://github.com/AlchemyCMS/alchemy_cms/pull/2334) ([tvdeyen](https://github.com/tvdeyen))
|
@@ -24,31 +24,8 @@ module Alchemy::Upgrader::Tasks
|
|
24
24
|
if elements.any?
|
25
25
|
puts "-- Creating ingredients for #{elements.count} #{element_definition[:name]}(s)"
|
26
26
|
elements.each do |element|
|
27
|
-
|
28
|
-
|
29
|
-
content = element.content_by_name(ingredient_definition[:role])
|
30
|
-
next unless content
|
31
|
-
|
32
|
-
essence = content.essence
|
33
|
-
ingredient = element.ingredients.build(
|
34
|
-
role: ingredient_definition[:role],
|
35
|
-
type: Alchemy::Ingredient.normalize_type(ingredient_definition[:type]),
|
36
|
-
)
|
37
|
-
belongs_to_associations = essence.class.reflect_on_all_associations(:belongs_to)
|
38
|
-
if belongs_to_associations.any?
|
39
|
-
ingredient.related_object = essence.public_send(belongs_to_associations.first.name)
|
40
|
-
else
|
41
|
-
ingredient.value = content.ingredient
|
42
|
-
end
|
43
|
-
data = ingredient.class.stored_attributes.fetch(:data, []).each_with_object({}) do |attr, d|
|
44
|
-
d[attr] = essence.public_send(attr)
|
45
|
-
end
|
46
|
-
ingredient.data = data
|
47
|
-
print "."
|
48
|
-
ingredient.save!
|
49
|
-
content.destroy!
|
50
|
-
end
|
51
|
-
end
|
27
|
+
MigrateElementIngredients.call(element)
|
28
|
+
print "."
|
52
29
|
end
|
53
30
|
puts "\n"
|
54
31
|
else
|
@@ -58,5 +35,38 @@ module Alchemy::Upgrader::Tasks
|
|
58
35
|
end
|
59
36
|
end
|
60
37
|
end
|
38
|
+
|
39
|
+
class MigrateElementIngredients
|
40
|
+
def self.call(element)
|
41
|
+
Alchemy::Element.transaction do
|
42
|
+
element.definition[:ingredients].each do |ingredient_definition|
|
43
|
+
ingredient = element.ingredients.build(
|
44
|
+
role: ingredient_definition[:role],
|
45
|
+
type: Alchemy::Ingredient.normalize_type(ingredient_definition[:type]),
|
46
|
+
)
|
47
|
+
|
48
|
+
content = element.content_by_name(ingredient_definition[:role])
|
49
|
+
if content
|
50
|
+
essence = content.essence
|
51
|
+
if essence
|
52
|
+
belongs_to_associations = essence.class.reflect_on_all_associations(:belongs_to)
|
53
|
+
if belongs_to_associations.any?
|
54
|
+
ingredient.related_object = essence.public_send(belongs_to_associations.first.name)
|
55
|
+
else
|
56
|
+
ingredient.value = content.ingredient
|
57
|
+
end
|
58
|
+
data = ingredient.class.stored_attributes.fetch(:data, []).each_with_object({}) do |attr, d|
|
59
|
+
d[attr] = essence.public_send(attr)
|
60
|
+
end
|
61
|
+
ingredient.data = data
|
62
|
+
end
|
63
|
+
content.destroy!
|
64
|
+
end
|
65
|
+
|
66
|
+
ingredient.save!
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
61
71
|
end
|
62
72
|
end
|
data/lib/alchemy/version.rb
CHANGED
data/package.json
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas von Deyen
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2022-05-
|
16
|
+
date: 2022-05-11 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: actionmailer
|