Class: Foobara::RemoteGenerator::Services::DependencyGroup
- Inherits:
-
Object
- Object
- Foobara::RemoteGenerator::Services::DependencyGroup
- Defined in:
- foobara-typescript-remote-command-generator-1.2.0/src/remote_generator/services/dependency_group.rb
Defined Under Namespace
Classes: CollisionData
Instance Attribute Summary collapse
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #collision_data ⇒ Object
- #collision_data_for(dep) ⇒ Object
-
#initialize(dependencies, name:) ⇒ DependencyGroup
constructor
A new instance of DependencyGroup.
- #non_colliding_dependency_roots ⇒ Object
- #non_colliding_root(dep) ⇒ Object
- #non_colliding_type(dep, points = points_for(dep)) ⇒ Object
- #non_colliding_type_name(dep, points = points_for(dep)) ⇒ Object
- #non_colliding_type_path(dep, points = points_for(dep)) ⇒ Object
- #points_for(dep) ⇒ Object
- #set_collision_data_for(dep, collision_data) ⇒ Object
- #to_key(dep) ⇒ Object
Constructor Details
#initialize(dependencies, name:) ⇒ DependencyGroup
Returns a new instance of DependencyGroup.
15 16 17 18 19 20 |
# File 'src/remote_generator/services/dependency_group.rb', line 15 def initialize(dependencies, name:) self.name = name self.dependencies = dependencies.to_set find_collisions end |
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
13 14 15 |
# File 'src/remote_generator/services/dependency_group.rb', line 13 def dependencies @dependencies end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'src/remote_generator/services/dependency_group.rb', line 13 def name @name end |
Instance Method Details
#collision_data ⇒ Object
43 44 45 |
# File 'src/remote_generator/services/dependency_group.rb', line 43 def collision_data @collision_data ||= {} end |
#collision_data_for(dep) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'src/remote_generator/services/dependency_group.rb', line 22 def collision_data_for(dep) key = to_key(dep) collision_data[key].tap do |cd| unless cd # :nocov: raise "Dependency #{dep} is not part of this dependency group" # :nocov: end end end |
#non_colliding_dependency_roots ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'src/remote_generator/services/dependency_group.rb', line 47 def non_colliding_dependency_roots roots = Set.new dependencies.each do |dep| roots << non_colliding_root(dep) end roots end |
#non_colliding_root(dep) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'src/remote_generator/services/dependency_group.rb', line 57 def non_colliding_root(dep) root = dep points = points_for(dep) points_climbed = 0 until points_climbed >= points # TODO: can't use scoped_path because sometimes we want UnloadedUser instead of User. How to fix?? points_climbed += dep.scoped_path.size root = root.parent end root end |
#non_colliding_type(dep, points = points_for(dep)) ⇒ Object
87 88 89 |
# File 'src/remote_generator/services/dependency_group.rb', line 87 def non_colliding_type(dep, points = points_for(dep)) non_colliding_type_name(dep, points) end |
#non_colliding_type_name(dep, points = points_for(dep)) ⇒ Object
83 84 85 |
# File 'src/remote_generator/services/dependency_group.rb', line 83 def non_colliding_type_name(dep, points = points_for(dep)) non_colliding_type_path(dep, points).join(".") end |
#non_colliding_type_path(dep, points = points_for(dep)) ⇒ Object
91 92 93 94 95 96 |
# File 'src/remote_generator/services/dependency_group.rb', line 91 def non_colliding_type_path(dep, points = points_for(dep)) start_at = dep.ts_type_full_path.size - points - 1 path = dep.ts_type_full_path[start_at..] || [] path.map(&:to_s) end |
#points_for(dep) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'src/remote_generator/services/dependency_group.rb', line 71 def points_for(dep) points = collision_data_for(dep).points unless points # :nocov: raise "Dependency #{dep} has no collision data" # :nocov: end points end |
#set_collision_data_for(dep, collision_data) ⇒ Object
34 35 36 37 |
# File 'src/remote_generator/services/dependency_group.rb', line 34 def set_collision_data_for(dep, collision_data) key = to_key(dep) self.collision_data[key] = collision_data end |
#to_key(dep) ⇒ Object
39 40 41 |
# File 'src/remote_generator/services/dependency_group.rb', line 39 def to_key(dep) [dep.scoped_category, *dep.ts_instance_full_path].map(&:to_s) end |