summaryrefslogtreecommitdiff
path: root/lib/bundler/rubygems_ext.rb
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2010-07-24 11:15:04 -0700
committerCarl Lerche <carllerche@mac.com>2010-07-24 11:16:32 -0700
commitb2e678bdb6e2baa8cd85952a4e5d4a76e4485ae9 (patch)
treeddb7fca2785cf769ec5f548ced615e6c093bbf34 /lib/bundler/rubygems_ext.rb
parente6c3bebfbd6d3ec0490aea8d184b81d8cf0eb0fb (diff)
downloadbundler-b2e678bdb6e2baa8cd85952a4e5d4a76e4485ae9.tar.gz
Remove the #to_generic monkey patch to Gem::Platform
Diffstat (limited to 'lib/bundler/rubygems_ext.rb')
-rw-r--r--lib/bundler/rubygems_ext.rb121
1 files changed, 67 insertions, 54 deletions
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 8429d439a3..5c62c1c772 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -8,61 +8,15 @@ end
require 'rubygems'
require 'rubygems/specification'
-module Bundler
- class DepProxy
-
- attr_reader :required_by, :__platform, :dep
-
- def initialize(dep, platform)
- @dep, @__platform, @required_by = dep, platform, []
- end
-
- def hash
- @hash ||= dep.hash
- end
-
- def ==(o)
- dep == o.dep && __platform == o.__platform
- end
-
- alias eql? ==
-
- def type
- @dep.type
- end
-
- def to_s
- @dep.to_s
- end
-
- private
-
- def method_missing(*args)
- @dep.send(*args)
- end
-
- end
-end
-
module Gem
@loaded_stacks = Hash.new { |h,k| h[k] = [] }
- module MatchPlatform
- def match_platform(p)
- Gem::Platform::RUBY == platform or
- platform.nil? or p == platform or
- Gem::Platform.new(platform).to_generic == p
- end
- end
-
class Specification
attr_accessor :source, :location, :relative_loaded_from
alias_method :rg_full_gem_path, :full_gem_path
alias_method :rg_loaded_from, :loaded_from
- include MatchPlatform
-
def full_gem_path
source.respond_to?(:path) ?
Pathname.new(loaded_from).dirname.expand_path.to_s :
@@ -169,22 +123,81 @@ module Gem
MSWIN = Gem::Platform.new('mswin32')
MING = Gem::Platform.new('x86-mingw32')
- GENERIC_CACHE = {}
-
- class << RUBY
- def to_generic ; self ; end
+ def hash
+ @cpu.hash + @os.hash + @version.hash
end
- GENERICS = [JAVA, MSWIN, MING, RUBY]
+ alias eql? ==
+ end
+end
+
+module Bundler
+ class DepProxy
+
+ attr_reader :required_by, :__platform, :dep
+
+ def initialize(dep, platform)
+ @dep, @__platform, @required_by = dep, platform, []
+ end
def hash
- @cpu.hash + @os.hash + @version.hash
+ @hash ||= dep.hash
+ end
+
+ def ==(o)
+ dep == o.dep && __platform == o.__platform
end
alias eql? ==
- def to_generic
- GENERIC_CACHE[self] ||= GENERICS.find { |p| self =~ p } || RUBY
+ def type
+ @dep.type
+ end
+
+ def to_s
+ @dep.to_s
end
+
+ private
+
+ def method_missing(*args)
+ @dep.send(*args)
+ end
+
+ end
+
+ module GemHelpers
+
+ GENERIC_CACHE = {}
+ GENERICS = [
+ Gem::Platform::JAVA,
+ Gem::Platform::MSWIN,
+ Gem::Platform::MING,
+ Gem::Platform::RUBY
+ ]
+
+ def generic(p)
+ if p == Gem::Platform::RUBY
+ return p
+ end
+
+ GENERIC_CACHE[p] ||= GENERICS.find { |p2| p =~ p2 } || Gem::Platform::RUBY
+ end
+ end
+
+ module MatchPlatform
+ include GemHelpers
+
+ def match_platform(p)
+ Gem::Platform::RUBY == platform or
+ platform.nil? or p == platform or
+ generic(Gem::Platform.new(platform)) == p
+ end
+ end
+end
+
+module Gem
+ class Specification
+ include Bundler::MatchPlatform
end
end