Class: FastCov::ConnectedDependencies
- Inherits:
-
Object
- Object
- FastCov::ConnectedDependencies
- Defined in:
- lib/fast_cov/connected_dependencies.rb
Instance Method Summary collapse
- #connect(from:, to:) ⇒ Object
- #expand(paths) ⇒ Object
-
#initialize ⇒ ConnectedDependencies
constructor
A new instance of ConnectedDependencies.
Constructor Details
#initialize ⇒ ConnectedDependencies
Returns a new instance of ConnectedDependencies.
5 6 7 8 |
# File 'lib/fast_cov/connected_dependencies.rb', line 5 def initialize @connections = {} @mutex = Mutex.new end |
Instance Method Details
#connect(from:, to:) ⇒ Object
10 11 12 13 14 |
# File 'lib/fast_cov/connected_dependencies.rb', line 10 def connect(from:, to:) @mutex.synchronize do (@connections[from] ||= {})[to] = true end end |
#expand(paths) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fast_cov/connected_dependencies.rb', line 16 def (paths) raise ArgumentError, "paths must be a Set" unless paths.is_a?(Set) pending_paths = paths.to_a until pending_paths.empty? path = pending_paths.pop connections = @connections[path] next unless connections connections.each_key do |dependency| next unless paths.add?(dependency) pending_paths << dependency end end paths end |