Sha256: adc552475a0b000492c8f3b6612419702b3a3333fb5d4dabe9cb8144b47c657d

Contents?: true

Size: 1.66 KB

Versions: 22

Compression:

Stored size: 1.66 KB

Contents

require "uri"
require "rubygems/spec_fetcher"

module Bundler
  class LazySpecification
    include MatchPlatform

    attr_reader :name, :version, :dependencies, :platform
    attr_accessor :source

    def initialize(name, version, platform, source = nil)
      @name          = name
      @version       = version
      @dependencies  = []
      @platform      = platform
      @source        = source
      @specification = nil
    end

    def full_name
      if platform == Gem::Platform::RUBY or platform.nil? then
        "#{@name}-#{@version}"
      else
        "#{@name}-#{@version}-#{platform}"
      end
    end

    def satisfies?(dependency)
      @name == dependency.name && dependency.requirement.satisfied_by?(Gem::Version.new(@version))
    end

    def to_lock
      if platform == Gem::Platform::RUBY or platform.nil?
        out = "    #{name} (#{version})\n"
      else
        out = "    #{name} (#{version}-#{platform})\n"
      end

      dependencies.sort_by {|d| d.to_s }.each do |dep|
        next if dep.type == :development
        out << "    #{dep.to_lock}\n"
      end

      out
    end

    def __materialize__
      @specification = source.specs.search(Gem::Dependency.new(name, version)).last
    end

    def respond_to?(*args)
      super || @specification.respond_to?(*args)
    end

    def to_s
      "#{name} (#{version})"
    end

  private

    def to_ary
      nil
    end

    def method_missing(method, *args, &blk)
      raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification

      return super unless respond_to?(method)

      @specification.send(method, *args, &blk)
    end

  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
bundler-1.1.rc.8 lib/bundler/lazy_specification.rb
bundler-1.0.22 lib/bundler/lazy_specification.rb
bundler-1.1.rc.7 lib/bundler/lazy_specification.rb
bundler-1.1.rc.6 lib/bundler/lazy_specification.rb
bundler-1.1.rc.5 lib/bundler/lazy_specification.rb
bundler-1.1.rc.3 lib/bundler/lazy_specification.rb
bundler-1.1.rc.2 lib/bundler/lazy_specification.rb
mpapis-bundler-1.0.21.1 lib/bundler/lazy_specification.rb
mpapis-bundler-1.0.21 lib/bundler/lazy_specification.rb
bundler-maglev--1.0.21 lib/bundler/lazy_specification.rb
bundler-1.1.rc lib/bundler/lazy_specification.rb
bundler-1.0.21 lib/bundler/lazy_specification.rb
bundler-1.0.21.rc lib/bundler/lazy_specification.rb
bundler-1.0.20 lib/bundler/lazy_specification.rb
bundler-1.1.pre.10 lib/bundler/lazy_specification.rb
bundler-1.1.pre.9 lib/bundler/lazy_specification.rb
bundler-1.0.20.rc lib/bundler/lazy_specification.rb
bundler-1.0.19.rc lib/bundler/lazy_specification.rb
bundler-1.0.18 lib/bundler/lazy_specification.rb
bundler-1.1.pre.8 lib/bundler/lazy_specification.rb