universe_compiler 0.2.15 → 0.2.16

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: e41acc6b69fb756a2ac583b57af1b7304df96c35
4
- data.tar.gz: c51a3309d154d952904abf533f262460fc7f17b0
3
+ metadata.gz: 5c53fdf41edd21c2f42d95cbe571ad2144e3024d
4
+ data.tar.gz: dd8f70ce2b215aa1210f8f57c59597979822e03d
5
5
  SHA512:
6
- metadata.gz: ded3473b85f0c40c275b5d6496c40ab1b554c0b9e8064d362ee20946ded04887324ddc9033d62d82459e8107b1817ce5fbbd70eac589db0a9c5939e021e4bf7e
7
- data.tar.gz: 4fe888273f547f04777baae2b43ae4168a785346e1982a23b0192f0455cba9915707edf3d478ae431accde81dee3f221486fba9c1af22256f312844e5fa1f9f4
6
+ metadata.gz: 48bddacf5d26a8a0dda4d7763a2ca57f7d591131964bae3951a4ba1c9242028bae7d0907612040f7795122c6f5269f7cca685c9131d52b9a7a2d200c17b39670
7
+ data.tar.gz: 18552dc3147935c98001999f901e7c7e46ead0e9f00c1f5fc9e3e2f0fba02a1a87e3b363bc1de9f10e5dd186d2a27d3a5736d9be7198c0149bff5b9ac1d70a8c
@@ -20,9 +20,17 @@ module UniverseCompiler
20
20
  @auto_named_entity_type
21
21
  end
22
22
 
23
- def get_unique_name
24
- @entity_type_counter += 1
25
- '%s_%u' % [auto_named_entity_type_seed, @entity_type_counter]
23
+ def get_unique_name(universe)
24
+ return SecureRandom.uuid if universe.nil?
25
+
26
+ uniq_name = nil
27
+ loop do
28
+ @entity_type_counter += 1
29
+ raise UniverseCompiler::Error, "Too many '#{entity_type}' (> 999999) in universe '#{universe.name}'" if @entity_type_counter >= 1000000
30
+ uniq_name = '%s_%06u' % [auto_named_entity_type_seed, @entity_type_counter]
31
+ break if universe.get_entity(entity_type, uniq_name).nil?
32
+ end
33
+ uniq_name
26
34
  end
27
35
 
28
36
  end
@@ -29,10 +29,10 @@ module UniverseCompiler
29
29
  self.universe = universe
30
30
  self.fully_resolved = true
31
31
  if universe.nil?
32
- self.name = self.class.get_unique_name if self.class.auto_named_entity_type?
32
+ self.name = self.class.get_unique_name(nil) if self.class.auto_named_entity_type?
33
33
  else
34
34
  unless universe.compiled?
35
- self.name = self.class.get_unique_name if self.class.auto_named_entity_type?
35
+ self.name = self.class.get_unique_name(universe) if self.class.auto_named_entity_type?
36
36
  end
37
37
  end
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module UniverseCompiler
2
- VERSION = '0.2.15'.freeze
2
+ VERSION = '0.2.16'.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.2.15
4
+ version: 0.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent B.