diff options
author | Carl Lerche <carllerche@mac.com> | 2010-07-24 11:15:04 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-07-24 11:16:32 -0700 |
commit | b2e678bdb6e2baa8cd85952a4e5d4a76e4485ae9 (patch) | |
tree | ddb7fca2785cf769ec5f548ced615e6c093bbf34 /lib/bundler | |
parent | e6c3bebfbd6d3ec0490aea8d184b81d8cf0eb0fb (diff) | |
download | bundler-b2e678bdb6e2baa8cd85952a4e5d4a76e4485ae9.tar.gz |
Remove the #to_generic monkey patch to Gem::Platform
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/definition.rb | 6 | ||||
-rw-r--r-- | lib/bundler/lazy_specification.rb | 4 | ||||
-rw-r--r-- | lib/bundler/remote_specification.rb | 4 | ||||
-rw-r--r-- | lib/bundler/resolver.rb | 4 | ||||
-rw-r--r-- | lib/bundler/rubygems_ext.rb | 121 |
5 files changed, 78 insertions, 61 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index b456075663..1c8334674d 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -2,6 +2,8 @@ require "digest/sha1" module Bundler class Definition + include GemHelpers + attr_reader :dependencies, :platforms, :sources def self.build(gemfile, lockfile, unlock) @@ -52,7 +54,7 @@ module Bundler @unlock[:gems] ||= [] @unlock[:sources] ||= [] - current_platform = Gem.platforms.map { |p| p.to_generic }.compact.last + current_platform = Gem.platforms.map { |p| generic(p) }.compact.last @platforms |= [current_platform] converge @@ -267,7 +269,7 @@ module Bundler deps = [] dependencies.each do |dep| dep.gem_platforms(@platforms).each do |p| - deps << DepProxy.new(dep, p) if remote || p == Gem::Platform.local.to_generic + deps << DepProxy.new(dep, p) if remote || p == generic(Gem::Platform.local) end end deps diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb index 4015752cf6..9db9b0edce 100644 --- a/lib/bundler/lazy_specification.rb +++ b/lib/bundler/lazy_specification.rb @@ -3,7 +3,7 @@ require "rubygems/spec_fetcher" module Bundler class LazySpecification - include Gem::MatchPlatform + include MatchPlatform attr_reader :name, :version, :dependencies, :platform attr_accessor :source @@ -68,4 +68,4 @@ module Bundler end end -end
\ No newline at end of file +end diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb index cde4a73356..3851014cf4 100644 --- a/lib/bundler/remote_specification.rb +++ b/lib/bundler/remote_specification.rb @@ -7,7 +7,7 @@ module Bundler # be seeded with what we're given from the source's abbreviated index - the # full specification will only be fetched when necesary. class RemoteSpecification - include Gem::MatchPlatform + include MatchPlatform attr_reader :name, :version, :platform attr_accessor :source @@ -56,4 +56,4 @@ module Bundler end end end -end
\ No newline at end of file +end diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index 5852d87e23..82e2e2827b 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -27,6 +27,8 @@ module Bundler Gem::Platform::MING] class SpecGroup < Array + include GemHelpers + attr_reader :activated, :required_by def initialize(a) @@ -52,7 +54,7 @@ module Bundler @activated.each do |p| if s = @specs[p] - platform = Gem::Platform.new(s.platform).to_generic + platform = generic(Gem::Platform.new(s.platform)) next if specs[platform] lazy_spec = LazySpecification.new(name, version, platform, source) 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 |