2018-11-02 19:07:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Bundler
|
|
|
|
class DepProxy
|
|
|
|
attr_reader :__platform, :dep
|
|
|
|
|
2021-02-01 10:17:16 -05:00
|
|
|
@proxies = {}
|
|
|
|
|
|
|
|
def self.get_proxy(dep, platform)
|
|
|
|
@proxies[[dep, platform]] ||= new(dep, platform).freeze
|
|
|
|
end
|
|
|
|
|
2018-11-02 19:07:56 -04:00
|
|
|
def initialize(dep, platform)
|
|
|
|
@dep = dep
|
|
|
|
@__platform = platform
|
|
|
|
end
|
|
|
|
|
2021-02-01 10:17:16 -05:00
|
|
|
private_class_method :new
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
alias_method :eql?, :==
|
|
|
|
|
|
|
|
def type
|
|
|
|
@dep.type
|
|
|
|
end
|
|
|
|
|
|
|
|
def name
|
|
|
|
@dep.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def requirement
|
|
|
|
@dep.requirement
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
s = name.dup
|
|
|
|
s << " (#{requirement})" unless requirement == Gem::Requirement.default
|
|
|
|
s << " #{__platform}" unless __platform == Gem::Platform::RUBY
|
|
|
|
s
|
|
|
|
end
|
|
|
|
|
2021-02-01 10:17:16 -05:00
|
|
|
def dup
|
|
|
|
raise NoMethodError.new("DepProxy cannot be duplicated")
|
|
|
|
end
|
|
|
|
|
|
|
|
def clone
|
|
|
|
raise NoMethodError.new("DepProxy cannot be cloned")
|
|
|
|
end
|
|
|
|
|
2020-10-15 00:20:25 -04:00
|
|
|
private
|
2018-11-02 19:07:56 -04:00
|
|
|
|
|
|
|
def method_missing(*args, &blk)
|
|
|
|
@dep.send(*args, &blk)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|