lib/rubygems/dependent.rb in gem-dependent-0.2.2 vs lib/rubygems/dependent.rb in gem-dependent-0.2.3

- old
+ new

@@ -30,20 +30,28 @@ def self.fetch_all_dependencies(specs_and_sources, options={}) parallel = (options[:parallel] || 15) Gem::Dependent::Parallel.map(specs_and_sources, :in_processes => parallel) do |spec, source| yield if block_given? - name, version = spec[0,2] + name, version = if RUBY_VERSION > "2" + [spec.name, spec.version] + else + spec[0,2] + end dependencies = fetch_dependencies(spec, source, options) [name, version, dependencies] end end def self.fetch_dependencies(spec, source, options={}) begin fetcher = Gem::SpecFetcher.fetcher - fetcher.fetch_spec(spec, URI.parse(source)).dependencies + if RUBY_VERSION > "2" + source.fetch_spec(spec).dependencies + else + fetcher.fetch_spec(spec, URI.parse(source)).dependencies + end rescue Object => e $stderr.puts e unless options[:all_versions] [] end end @@ -65,15 +73,19 @@ fetcher = Gem::SpecFetcher.fetcher all = true matching_platform = false prerelease = false matcher = without_deprecation_warning { Gem::Dependency.new(//, Gem::Requirement.default) } # any name, any version - specs_and_sources = fetcher.find_matching matcher, all, matching_platform, prerelease + specs_and_sources = if RUBY_VERSION > "2" + fetcher.search_for_dependency(matcher, matching_platform).first + else + fetcher.find_matching matcher, all, matching_platform, prerelease + end if options[:all_versions] specs_and_sources else - uniq_by(specs_and_sources){|a| a.first.first } + uniq_by(specs_and_sources){|a| RUBY_VERSION > "2" ? a.first.name : a.first.first } end end def self.without_deprecation_warning(&block) previous = Gem::Deprecate.skip