Sha256: f96b8b14dec0d8fbcfccb5e4516e713e353519d0e522277e5480048be1eda69b

Contents?: true

Size: 916 Bytes

Versions: 2

Compression:

Stored size: 916 Bytes

Contents

# frozen_string_literal: true

module CobraCommander
  # An umbrella application
  class Umbrella
    attr_reader :name, :path

    def initialize(name, path)
      @root_component = Component.new(self, name)
      @path = path
      @components = {}
    end

    def find(name)
      @components[name]
    end

    def root
      @root_component
    end

    def resolve(component_root_path)
      return root if root.root_paths.include?(component_root_path)

      components.find do |component|
        component.root_paths.include?(component_root_path)
      end
    end

    def add_source(key, source)
      @root_component.add_package key, source.root
      source.packages.each do |packages|
        @components[packages.name] ||= Component.new(self, packages.name)
        @components[packages.name].add_package key, packages
      end
    end

    def components
      @components.values
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cobra_commander-0.15.1 lib/cobra_commander/umbrella.rb
cobra_commander-0.15.0 lib/cobra_commander/umbrella.rb