Sha256: 13c2244073953d0d4dd7ed5949818cb6519cd58141851a066a53e817722b405e

Contents?: true

Size: 1.67 KB

Versions: 29

Compression:

Stored size: 1.67 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.name }.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 method_missing(method, *args, &blk)
      if Gem::Specification.new.respond_to?(method)
        raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification
        @specification.send(method, *args, &blk)
      else
        super
      end
    end

  end
end

Version data entries

29 entries across 29 versions & 4 rubygems

Version Path
bundler-1.0.11 lib/bundler/lazy_specification.rb
bundler_package_git-1.1.pre.1 lib/bundler/lazy_specification.rb
bundler-1.1.pre.1 lib/bundler/lazy_specification.rb
bundler-1.0.10 lib/bundler/lazy_specification.rb
bundler-1.1.pre lib/bundler/lazy_specification.rb
bundler-1.0.9 lib/bundler/lazy_specification.rb
bundler-1.0.7 lib/bundler/lazy_specification.rb
bundler-1.0.5 lib/bundler/lazy_specification.rb
honkster-bundler-1.1.pre lib/bundler/lazy_specification.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/bundler-1.0.3/lib/bundler/lazy_specification.rb
gemrage-0.4.1 vendor/ruby/1.8/gems/bundler-1.0.3/lib/bundler/lazy_specification.rb
gemrage-0.4.0 vendor/ruby/1.8/gems/bundler-1.0.3/lib/bundler/lazy_specification.rb
gemrage-0.3.2 vendor/ruby/1.8/gems/bundler-1.0.3/lib/bundler/lazy_specification.rb
gemrage-0.3.1 vendor/ruby/1.8/gems/bundler-1.0.3/lib/bundler/lazy_specification.rb
gemrage-0.3.0 vendor/ruby/1.8/gems/bundler-1.0.3/lib/bundler/lazy_specification.rb
gemrage-0.2.0 vendor/ruby/1.8/gems/bundler-1.0.3/lib/bundler/lazy_specification.rb
gemrage-0.1.2 vendor/ruby/1.8/gems/bundler-1.0.3/lib/bundler/lazy_specification.rb
gemrage-0.1.1 vendor/ruby/1.8/gems/bundler-1.0.3/lib/bundler/lazy_specification.rb
gemrage-0.1.0 vendor/ruby/1.8/gems/bundler-1.0.3/lib/bundler/lazy_specification.rb
gemrage-0.0.0 vendor/ruby/1.8/gems/bundler-1.0.3/lib/bundler/lazy_specification.rb