Sha256: 1c9af2eb36f6fb44048f626061711064730e90f328acac3354c36a57329d0b3e

Contents?: true

Size: 880 Bytes

Versions: 1

Compression:

Stored size: 880 Bytes

Contents

module Space
  class Repos < Array
    class << self
      def all
        @all ||= create(App.config.paths)
      end

      def names
        @names ||= all.map(&:name)
      end

      def select(names)
        new(all.select { |repo| names.include?(repo.name) })
      end

      def find_by_name(name)
        all.find_by_name(name)
      end

      def create(paths)
        new(paths.map_with_index { |path, ix| Repo.new(ix + 1, path) })
      end
    end

    def names
      map(&:name)
    end

    def scoped?
      size != self.class.all.size
    end

    # def name
    #   "#{App.config.name}-(#{names.join('|').gsub("#{App.config.name}-", '')})"
    # end

    def find_by_name(name)
      detect { |repo| repo.name == name }
    end

    def self_and_dependencies
      self.class.new(map { |repo| [repo.name] + repo.dependencies }.flatten.uniq)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
space-0.0.2 lib/space/models/repos.rb