Sha256: 6e334d1e806686fcf15b5923240386bcef5166351ee4819431f58f7310480bc9

Contents?: true

Size: 824 Bytes

Versions: 8

Compression:

Stored size: 824 Bytes

Contents

#--
# Copyright (c) 2010 Engine Yard, Inc.
# Copyright (c) 2007-2009 Sun Microsystems, Inc.
# This source code is available under the MIT license.
# See the file LICENSE.txt for 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 }
      self
    end

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

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
warbler-1.2.1 lib/warbler/gems.rb
warbler-1.2.0 lib/warbler/gems.rb
rdmopensource-warbler-1.1.0 lib/warbler/gems.rb
warbler-1.1.0 lib/warbler/gems.rb
warbler-1.0.3 lib/warbler/gems.rb
warbler-1.0.2 lib/warbler/gems.rb
warbler-1.0.1 lib/warbler/gems.rb
warbler-1.0 lib/warbler/gems.rb