lib/rubygems/source_index.rb in rubygems-update-1.7.2 vs lib/rubygems/source_index.rb in rubygems-update-1.8.0

- old
+ new

@@ -71,58 +71,56 @@ # Loads a ruby-format specification from +file_name+ and returns the # loaded spec. def self.load_specification(file_name) Deprecate.skip_during do - Gem::Specification.load file_name + Gem::Specification.load Gem::Path.new(file_name) end end ## # Constructs a source index instance from the provided specifications, which # is a Hash of gem full names and Gem::Specifications. - #-- - # TODO merge @gems and @prerelease_gems and provide a separate method - # #prerelease_gems def initialize specs_or_dirs = [] @gems = {} @spec_dirs = nil case specs_or_dirs when Hash then - warn "NOTE: SourceIndex.new(hash) is deprecated; From #{caller.first}." - specs_or_dirs.each{ |full_name, spec| add_spec spec } + specs_or_dirs.each do |full_name, spec| + add_spec spec + end when Array, String then self.spec_dirs = Array(specs_or_dirs) refresh! else arg = specs_or_dirs.inspect warn "NOTE: SourceIndex.new(#{arg}) is deprecated; From #{caller.first}." end end def all_gems - @gems + gems end def prerelease_gems - @gems.reject{ |name, gem| !gem.version.prerelease? } + @gems.reject { |name, gem| !gem.version.prerelease? } end def released_gems - @gems.reject{ |name, gem| gem.version.prerelease? } + @gems.reject { |name, gem| gem.version.prerelease? } end ## # Reconstruct the source index from the specifications in +spec_dirs+. def load_gems_in(*spec_dirs) @gems.clear spec_dirs.reverse_each do |spec_dir| - spec_files = Dir.glob File.join(spec_dir, '*.gemspec') + spec_files = Dir[File.join(spec_dir, "*.gemspec")] spec_files.each do |spec_file| gemspec = Deprecate.skip_during do Gem::Specification.load spec_file end @@ -163,12 +161,10 @@ end result[name] << spec end - # TODO: why is this a hash while @gems is an array? Seems like - # structural similarity would be good. result.values.flatten end ## # An array including only the prerelease gemspecs @@ -250,11 +246,14 @@ ## # Find a gem by an exact match on the short name. def find_name(gem_name, requirement = Gem::Requirement.default) dep = Gem::Dependency.new gem_name, requirement - search dep + + Deprecate.skip_during do + search dep + end end ## # Search for a gem by Gem::Dependency +gem_pattern+. If +only_platform+ # is true, only gems matching Gem::Platform.local will be returned. An @@ -262,35 +261,35 @@ # # For backwards compatibility, a String or Regexp pattern may be passed as # +gem_pattern+, and a Gem::Requirement for +platform_only+. This # behavior is deprecated and will be removed. - def search(gem_pattern, platform_only = false) + def search(gem_pattern, platform_or_requirement = false) requirement = nil - only_platform = false + only_platform = false # FIX: WTF is this?!? # TODO - Remove support and warning for legacy arguments after 2008/11 unless Gem::Dependency === gem_pattern warn "#{Gem.location_of_caller.join ':'}:Warning: Gem::SourceIndex#search support for #{gem_pattern.class} patterns is deprecated, use #find_name" end case gem_pattern when Regexp then - requirement = platform_only || Gem::Requirement.default + requirement = platform_or_requirement || Gem::Requirement.default when Gem::Dependency then - only_platform = platform_only + only_platform = platform_or_requirement requirement = gem_pattern.requirement gem_pattern = if Regexp === gem_pattern.name then gem_pattern.name elsif gem_pattern.name.empty? then // else /^#{Regexp.escape gem_pattern.name}$/ end else - requirement = platform_only || Gem::Requirement.default + requirement = platform_or_requirement || Gem::Requirement.default gem_pattern = /#{gem_pattern}/i end unless Gem::Requirement === requirement then requirement = Gem::Requirement.create requirement @@ -347,20 +346,10 @@ end def dump Marshal.dump(self) end - - extend Deprecate - deprecate :all_gems, :none, 2011, 10 - - class << self - extend Deprecate - deprecate :from_installed_gems, :none, 2011, 10 - deprecate :from_gems_in, :none, 2011, 10 - deprecate :load_specification, :none, 2011, 10 - end end # :stopdoc: module Gem @@ -369,7 +358,47 @@ # objects to load properly. Cache = SourceIndex end -# :startdoc: +class Gem::SourceIndex + extend Deprecate + + deprecate :all_gems, :none, 2011, 10 + + deprecate :==, :none, 2011, 11 # noisy + deprecate :add_specs, :none, 2011, 11 # noisy + deprecate :each, :none, 2011, 11 + deprecate :gems, :none, 2011, 11 + deprecate :load_gems_in, :none, 2011, 11 + deprecate :refresh!, :none, 2011, 11 + deprecate :spec_dirs=, "Specification.dirs=", 2011, 11 # noisy + deprecate :add_spec, "Specification.add_spec", 2011, 11 + deprecate :find_name, "Specification.find_by_name", 2011, 11 + deprecate :gem_signature, :none, 2011, 11 + deprecate :index_signature, :none, 2011, 11 + deprecate :initialize, :none, 2011, 11 + deprecate :latest_specs, "Specification.latest_specs", 2011, 11 + deprecate :length, "Specification.all.length", 2011, 11 + deprecate :outdated, :none, 2011, 11 + deprecate :prerelease_gems, :none, 2011, 11 + deprecate :prerelease_specs, :none, 2011, 11 + deprecate :released_gems, :none, 2011, 11 + deprecate :released_specs, :none, 2011, 11 + deprecate :remove_spec, "Specification.remove_spec", 2011, 11 + deprecate :search, :none, 2011, 11 + deprecate :size, "Specification.all.size", 2011, 11 + deprecate :spec_dirs, "Specification.dirs", 2011, 11 + deprecate :specification, "Specification.find", 2011, 11 + + class << self + extend Deprecate + + deprecate :from_gems_in, :none, 2011, 10 + deprecate :from_installed_gems, :none, 2011, 10 + deprecate :installed_spec_directories, "Specification.dirs", 2011, 11 + deprecate :load_specification, :none, 2011, 10 + end +end + +# :startdoc: