Sha256: 80850774a6e5ade0b73db11cc7a65aeb2bd73080b48d8b0a05d0850d6472b94f

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 KB

Contents

#
# This file was ported to ruby from Composer php source code.
# Original Source: Composer\Repository\WritableArrayRepository.php
#
# (c) Nils Adermann <naderman@naderman.de>
#     Jordi Boggiano <j.boggiano@seld.be>
#
# For the full copyright and license information, please view the LICENSE
# file that was distributed with this source code.
#

module Composer
  module Repository
    # Writable array repository.
    #
    # PHP Authors:
    # Jordi Boggiano <j.boggiano@seld.be>
    #
    # Ruby Authors:
    # Ioannis Kappas <ikappas@devworks.gr>
    class WritableHashRepository < Composer::Repository::HashRepository

      def initialize(packages = [])
        super
      end

      def write
        # implement inside child
      end

      def reload
        # implement inside child
      end

      def canonical_packages
        packages_uncanonicalized = packages

        # get at most one package of each name, preferring non-aliased ones
        packages_by_name = {}
        packages_uncanonicalized.each do |package|
          if !packages_by_name.key?(package.name) ||
            packages_by_name[package.name].instance_of?(Composer::Package::AliasPackage)
            packages_by_name[package.name] = package
          end
        end

        # unfold aliased packages
        results = []
        packages_by_name.each do |name, package|
          while package.instance_of?(Composer::Package::AliasPackage)
            package = package.alias_of
          end
          results.push(package)
        end

        results
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
php-composer-0.4.5 lib/composer/repository/writeable_hash_repository.rb
php-composer-0.4.4 lib/composer/repository/writeable_hash_repository.rb
php-composer-0.4.3 lib/composer/repository/writeable_hash_repository.rb
php-composer-0.4.2 lib/composer/repository/writeable_hash_repository.rb
php-composer-0.4.1 lib/composer/repository/writeable_hash_repository.rb
php-composer-0.4.0 lib/composer/repository/writeable_hash_repository.rb