Sha256: 89e8620a35cad91b8f1d9d9c7ce4a2d3b60ebd1dfa7adfe9202bc751c138765a

Contents?: true

Size: 848 Bytes

Versions: 13

Compression:

Stored size: 848 Bytes

Contents

require 'active_support/core_ext/kernel/reporting'

module Kernel
  # Require a library with fallback to RubyGems.  Warnings during library
  # loading are silenced to increase signal/noise for application warnings.
  def require_library_or_gem(library_name)
    silence_warnings do
      begin
        require library_name
      rescue LoadError => cannot_require
        # 1. Requiring the module is unsuccessful, maybe it's a gem and nobody required rubygems yet. Try.
        begin
          require 'rubygems'
        rescue LoadError => rubygems_not_installed
          raise cannot_require
        end
        # 2. Rubygems is installed and loaded. Try to load the library again
        begin
          require library_name
        rescue LoadError => gem_not_installed
          raise cannot_require
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
csd-0.1.5 lib/active_support/core_ext/kernel/requires.rb
csd-0.1.4 lib/active_support/core_ext/kernel/requires.rb
csd-0.1.3 lib/active_support/core_ext/kernel/requires.rb
csd-0.1.2 lib/active_support/core_ext/kernel/requires.rb
csd-0.1.1 lib/active_support/core_ext/kernel/requires.rb
csd-0.1.0 lib/active_support/core_ext/kernel/requires.rb
csd-0.0.16 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.0.beta4 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.0.beta3 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.0.beta2 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.0.beta lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.pre lib/active_support/core_ext/kernel/requires.rb
recliner-0.0.1 vendor/activesupport/lib/active_support/core_ext/kernel/requires.rb