123456789_123456789_123456789_123456789_123456789_

Class: Gem::Resolver::ActivationRequest

Relationships & Source Files
Inherits: Object
Defined in: lib/rubygems/resolver/activation_request.rb

Overview

Specifies a Specification object that should be activated. Also contains a dependency that was used to introduce this activation.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(spec, request) ⇒ ActivationRequest

Creates a new ActivationRequest that will activate #spec. The parent #request is used to provide diagnostics in case of conflicts.

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 22

def initialize(spec, request)
  @spec = spec
  @request = request
end

Instance Attribute Details

#development?Boolean (readonly)

Is this activation request for a development dependency?

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 41

def development?
  @request.development?
end

#installed?Boolean (readonly)

True if the requested gem has already been installed.

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 97

def installed?
  case @spec
  when Gem::Resolver::VendorSpecification then
    true
  else
    this_spec = full_spec

    Gem::Specification.any? do |s|
      s == this_spec
    end
  end
end

#request (readonly)

The parent request for this activation request.

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 11

attr_reader :request

#spec (readonly)

The specification to be activated.

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 16

attr_reader :spec

Instance Method Details

#==(other)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 27

def ==(other) # :nodoc:
  case other
  when Gem::Specification
    @spec == other
  when Gem::Resolver::ActivationRequest
    @spec == other.spec && @request == other.request
  else
    false
  end
end

#download(path)

Downloads a gem at Gem.path and returns the file path.

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 48

def download(path)
  Gem.ensure_gem_subdirectories path

  if @spec.respond_to? :sources
    exception = nil
    path = @spec.sources.find do |source|
      begin
        source.download full_spec, path
      rescue exception
      end
    end
    return path      if path
    raise  exception if exception

  elsif @spec.respond_to? :source
    source = @spec.source
    source.download full_spec, path

  else
    source = Gem.sources.first
    source.download full_spec, path
  end
end

#full_name Also known as: #to_s

The full name of the specification to be activated.

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 75

def full_name
  name_tuple.full_name
end

#full_spec

The ::Gem::Specification for this activation request.

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 84

def full_spec
  Gem::Specification === @spec ? @spec : @spec.spec
end

#inspect

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 88

def inspect # :nodoc:
  '#<%s for %p from %s>' % [
    self.class, @spec, @request
  ]
end

#name

The name of this activation request’s specification

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 113

def name
  @spec.name
end

#name_tuple (private)

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 152

def name_tuple
  @name_tuple ||= Gem::NameTuple.new(name, version, platform)
end

#parent

Return the ActivationRequest that contained the dependency that we were activated for.

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 121

def parent
  @request.requester
end

#platform

The platform of this activation request’s specification

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 146

def platform
  @spec.platform
end

#pretty_print(q)

This method is for internal use only.
[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 125

def pretty_print(q) # :nodoc:
  q.group 2, '[Activation request', ']' do
    q.breakable
    q.pp @spec

    q.breakable
    q.text ' for '
    q.pp @request
  end
end

#to_s

Alias for #full_name.

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 79

alias_method :to_s, :full_name

#version

The version of this activation request’s specification

[ GitHub ]

  
# File 'lib/rubygems/resolver/activation_request.rb', line 139

def version
  @spec.version
end