aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/vendor.rb
blob: ca70beb0a88565800854053e68ab98b91e48ebea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require 'pathname'

def ActiveSupport.requirable?(file)
  $LOAD_PATH.any? { |p| Dir.glob("#{p}/#{file}.*").any? }
end

[%w(builder 2.1.2), %w(memcache-client 1.7.5), %w(tzinfo 0.3.16)].each do |lib, version|
  # If the lib is not already requirable
  unless ActiveSupport.requirable? lib
    # Try to activate a gem ~> satisfying the requested version first.
    begin
      gem lib, ">= #{version}"
      # Use the vendored lib if the gem's missing or we aren't using RubyGems.
    rescue LoadError, NoMethodError
      # There could be symlinks
      $LOAD_PATH.unshift Pathname.new(__FILE__).dirname.join("vendor/#{lib}-#{version}/lib").realpath.to_s
    end
  end
end