Sha256: 43c42a8f82b16e7f2d9aa39aa15eb36b143b60ee82179ebddbab9d357e7f0fcc

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 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.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] + repo.dependencies }.flatten.uniq)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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