class Bundler::RemoteSpecification
表示一个延迟加载的 gem 规范,完整的规范位于 rubygems 的 “quick” 索引的源服务器上。代理对象使用从源的缩写索引中获得的信息进行初始化 - 只有在必要时才会获取完整的规范。
属性
dependencies[W]
locked_platform[RW]
name[R]
platform[R]
remote[RW]
source[RW]
version[R]
公共类方法
new(name, version, platform, spec_fetcher) 点击切换源代码
# File bundler/remote_specification.rb, line 17 def initialize(name, version, platform, spec_fetcher) @name = name @version = Gem::Version.create version @original_platform = platform || Gem::Platform::RUBY @platform = Gem::Platform.new(platform) @spec_fetcher = spec_fetcher @dependencies = nil @locked_platform = nil end
公共实例方法
<=>(other) 点击切换源代码
将此规范与另一个对象进行比较。使用 sort_obj
与 Gem::Specification
和其他 Bundler
或 RubyGems 对象兼容。否则,使用默认的 Object
比较。
调用父类方法
# File bundler/remote_specification.rb, line 48 def <=>(other) if other.respond_to?(:sort_obj) sort_obj <=> other.sort_obj else super end end
__swap__(spec) 点击切换源代码
因为在下载远程 gem 后,Rubyforge 不能被信任提供有效的规范,所以后端规范将被替换。
# File bundler/remote_specification.rb, line 59 def __swap__(spec) raise APIResponseInvalidDependenciesError unless spec.dependencies.all? {|d| d.is_a?(Gem::Dependency) } SharedHelpers.ensure_same_dependencies(self, dependencies, spec.dependencies) @_remote_specification = spec end
dependencies() 点击切换源代码
# File bundler/remote_specification.rb, line 83 def dependencies @dependencies ||= begin deps = method_missing(:dependencies) # allow us to handle when the specs dependencies are an array of array of string # in order to delay the crash to `#__swap__` where it results in a friendlier error # see https://github.com/rubygems/bundler/issues/5797 deps = deps.map {|d| d.is_a?(Gem::Dependency) ? d : Gem::Dependency.new(*d) } deps end end
fetch_platform() 点击切换源代码
在安装之前需要,因为体系结构很重要,并且快速规范不费心在平台字符串中包含体系结构
# File bundler/remote_specification.rb, line 33 def fetch_platform @platform = _remote_specification.platform end
full_name() 点击切换源代码
# File bundler/remote_specification.rb, line 37 def full_name @full_name ||= if @platform == Gem::Platform::RUBY "#{@name}-#{@version}" else "#{@name}-#{@version}-#{@platform}" end end
git_version() 点击切换源代码
# File bundler/remote_specification.rb, line 100 def git_version return unless loaded_from && source.is_a?(Bundler::Source::Git) " #{source.revision[0..6]}" end
insecurely_materialized?() 点击切换源代码
# File bundler/remote_specification.rb, line 27 def insecurely_materialized? @locked_platform.to_s != @platform.to_s end
respond_to?(method, include_all = false) 点击切换源代码
调用父类方法
# File bundler/remote_specification.rb, line 121 def respond_to?(method, include_all = false) super || _remote_specification.respond_to?(method, include_all) end
runtime_dependencies() 点击切换源代码
# File bundler/remote_specification.rb, line 96 def runtime_dependencies dependencies.select(&:runtime?) end
sort_obj() 点击切换源代码
创建一个用于排序的委托。此策略从 RubyGems 2.23 复制而来,并确保 Bundler 的规范可以与 RubyGems 自己的规范进行比较和排序。
@see #<=> @see Gem::Specification#sort_obj
@return [Array] 一个可用于比较和排序此对象的对象
specification against other specifications
# File bundler/remote_specification.rb, line 75 def sort_obj [@name, @version, @platform == Gem::Platform::RUBY ? -1 : 1] end
to_s() 点击切换源代码
# File bundler/remote_specification.rb, line 79 def to_s "#<#{self.class} name=#{name} version=#{version} platform=#{platform}>" end
私有实例方法
_remote_specification() 点击切换源代码
# File bundler/remote_specification.rb, line 111 def _remote_specification @_remote_specification ||= @spec_fetcher.fetch_spec([@name, @version, @original_platform]) @_remote_specification || raise(GemspecError, "Gemspec data for #{full_name} was" \ " missing from the server!") end
method_missing(method, *args, &blk) 点击切换源代码
# File bundler/remote_specification.rb, line 117 def method_missing(method, *args, &blk) _remote_specification.send(method, *args, &blk) end
to_ary() 点击切换源代码
# File bundler/remote_specification.rb, line 107 def to_ary nil end