universe_compiler 0.3.5 → 0.3.6

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
2
  SHA1:
3
- metadata.gz: 68f3d590258d656e0fa5e6d432f6311198b9012c
4
- data.tar.gz: adbcd0dbbe00ec7c6d01ee02783e2f80c93f7957
3
+ metadata.gz: c08e67162d84afd5f24048c2ae84f2dea74b74c2
4
+ data.tar.gz: 9e84f5154592ad5fba0515ad017629efa5a810b3
5
5
  SHA512:
6
- metadata.gz: fe3c6d9693b48a3a0518c265514280aacb0a410cefcca8589bf602e318121d31faf6e7393987414f8500b0522ea8560806b0ce7cba0e4a0cf20bd4de6a09ca31
7
- data.tar.gz: 6f4dfad75605f90f49cc0057ac68a08509ba82359bacb26328a8ece4c7827e9f8b7f6bd1550b6932a32f2cfb765148e0e6b9cec812d0bee33c5f0ea8af47d621
6
+ metadata.gz: cf1032c88e42ff577b22aa491f1a0d6f013758f11292e9b8e8e69101ab2df7023e5615457976919007076fa916e00f7a5b1a523fae80d31da516d7cbb7550849
7
+ data.tar.gz: f8b5e02483e215d7938d0063471ef959bd7d257308e425d721abcca091d7e5c9e1fc85e9922e116b62bc2e4e1625a7fd61f76eedc92305e0e93ea2360014b212
@@ -40,15 +40,15 @@ module UniverseCompiler
40
40
  if constraints.keys.include? :has_one
41
41
  if e[field_name] == entity
42
42
  e[field_name] = nil
43
- impacted_entities[e] ||= 0
44
- impacted_entities[e] += 1
43
+ impacted_entities[e] ||= []
44
+ impacted_entities[e] << field_name
45
45
  end
46
46
  end
47
47
  if constraints.keys.include? :has_many
48
48
  if e[field_name].include? entity
49
49
  e[field_name].delete entity
50
- impacted_entities[e] ||= 0
51
- impacted_entities[e] += 1
50
+ impacted_entities[e] ||= []
51
+ impacted_entities[e] << field_name unless impacted_entities[e].include? field_name
52
52
  end
53
53
  end
54
54
  end
@@ -56,7 +56,13 @@ module UniverseCompiler
56
56
  # Then delete the entity
57
57
  entities.delete entity
58
58
  reindex_all entities
59
- impacted_entities.keys
59
+ unless impacted_entities.empty?
60
+ UniverseCompiler.logger.warn "Impacts of '#{entity.as_path}' deletion:"
61
+ impacted_entities.each do |k, v|
62
+ UniverseCompiler.logger.warn " - '#{k.as_path}' fields : #{v.join ', '}"
63
+ end
64
+ end
65
+ impacted_entities
60
66
  end
61
67
 
62
68
  def replace(entity, by)
@@ -64,21 +70,21 @@ module UniverseCompiler
64
70
  raise UniverseCompiler::Error, "Cannot replace '#{entity.as_path}' with '#{by.as_path}' which is alreadyin the universe!" if entity.universe == by.universe
65
71
 
66
72
  # Change references to entity
67
- impacted_entities = {by => 1}
73
+ impacted_entities = {}
68
74
  entities.each do |e|
69
75
  e.class.fields_constraints.each do |field_name, constraints|
70
76
  if constraints.keys.include? :has_one
71
77
  if e[field_name] == entity
72
78
  e[field_name] = by
73
- impacted_entities[e] ||= 0
74
- impacted_entities[e] += 1
79
+ impacted_entities[e] ||= []
80
+ impacted_entities[e] << field_name
75
81
  end
76
82
  end
77
83
  if constraints.keys.include? :has_many
78
84
  if e[field_name].map! do |entity_list_item|
79
85
  if (entity == entity_list_item)
80
- impacted_entities[e] ||= 0
81
- impacted_entities[e] += 1
86
+ impacted_entities[e] ||= []
87
+ impacted_entities[e] << field_name unless impacted_entities[e].include? field_name
82
88
  by
83
89
  else
84
90
  entity_list_item
@@ -91,7 +97,13 @@ module UniverseCompiler
91
97
  # Then replace the entity
92
98
  entities[entities.index(entity)] = by
93
99
  reindex_all entities
94
- impacted_entities.keys
100
+ unless impacted_entities.empty?
101
+ UniverseCompiler.logger.warn "Impacts of '#{entity.as_path}' deletion:"
102
+ impacted_entities.each do |k, v|
103
+ UniverseCompiler.logger.warn " - '#{k.as_path}' fields : #{v.join ', '}"
104
+ end
105
+ end
106
+ impacted_entities
95
107
  end
96
108
 
97
109
  def clear
@@ -1,3 +1,3 @@
1
1
  module UniverseCompiler
2
- VERSION = '0.3.5'.freeze
2
+ VERSION = '0.3.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: universe_compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent B.