Skip to content

Commit

Permalink
Remove 1.8 support code from Fluent::Registry
Browse files Browse the repository at this point in the history
  • Loading branch information
repeatedly committed Dec 1, 2014
1 parent 61fbdb7 commit 50a90ac
Showing 1 changed file with 9 additions and 27 deletions.
36 changes: 9 additions & 27 deletions lib/fluent/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 50a90ac

Please sign in to comment.