Sha256: 7beee506369b3dd3f8b8d0393a207442d99c62d563c186d693a3080fa6c49fc6

Contents?: true

Size: 758 Bytes

Versions: 1

Compression:

Stored size: 758 Bytes

Contents

#--
# (c) Copyright 2007-2008 Sun Microsystems, Inc.
# See the file LICENSES.txt included with the distribution for
# software license details.
#++

module Warbler
  # A set of gems. This only exists to allow expected operations
  # to be used to add gems, and for backwards compatibility.
  # It would be easier to just use a hash.
  class Gems < Hash
    ANY_VERSION = nil
    
    def initialize(gems = nil)
      if gems.is_a?(Hash)
        self.merge!(gems)
      elsif gems.is_a?(Array)
        gems.each {|gem| self << gem }
      end
    end
    
    def <<(gem)
      self[gem] ||= ANY_VERSION
    end

    def +(other)
      other.each {|g| self[g] ||= ANY_VERSION }
    end

    def -(other)
      other.each {|g| self.delete(g)}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
warbler-0.9.11 lib/warbler/gems.rb