From 50a90ac1cdc92860411be52280d5e1d0ec8bbbdb Mon Sep 17 00:00:00 2001 From: Masahiro Nakagawa Date: Mon, 1 Dec 2014 18:01:08 +0900 Subject: [PATCH] Remove 1.8 support code from Fluent::Registry --- lib/fluent/registry.rb | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/lib/fluent/registry.rb b/lib/fluent/registry.rb index 0492c3400b..e5e1c87188 100644 --- a/lib/fluent/registry.rb +++ b/lib/fluent/registry.rb @@ -57,34 +57,16 @@ def search(type) return end - # search gems - if defined?(::Gem::Specification) && ::Gem::Specification.respond_to?(:find_all) - specs = Gem::Specification.find_all { |spec| - spec.contains_requirable_file? path - } - - # prefer newer version - specs = specs.sort_by { |spec| spec.version } - if spec = specs.last - spec.require_paths.each { |lib| - file = "#{spec.full_gem_path}/#{lib}/#{path}" - require file - } - end + specs = Gem::Specification.find_all { |spec| + spec.contains_requirable_file? path + } - # backward compatibility for rubygems < 1.8 - elsif defined?(::Gem) && ::Gem.respond_to?(:searcher) - #files = Gem.find_files(path).sort - specs = Gem.searcher.find_all(path) - - # prefer newer version - specs = specs.sort_by { |spec| spec.version } - specs.reverse_each { |spec| - files = Gem.searcher.matching_files(spec, path) - unless files.empty? - require files.first - break - end + # prefer newer version + specs = specs.sort_by { |spec| spec.version } + if spec = specs.last + spec.require_paths.each { |lib| + file = "#{spec.full_gem_path}/#{lib}/#{path}" + require file } end end