Sha256: 3b8b5f82b60e8ee4789b41579e7568d62bbb486a4134f32c2cb90da0f05b3231

Contents?: true

Size: 852 Bytes

Versions: 44

Compression:

Stored size: 852 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

44 entries across 44 versions & 3 rubygems

Version Path
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/activesupport-3.0.0/lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.20 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.19 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.18 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.17 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.16 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.15 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.14 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.13 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.13.rc1 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.12 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.12.rc1 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.11 lib/active_support/core_ext/kernel/requires.rb
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/core_ext/kernel/requires.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/activesupport-3.0.9/lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.10 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.10.rc1 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.9 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.9.rc5 lib/active_support/core_ext/kernel/requires.rb
activesupport-3.0.9.rc4 lib/active_support/core_ext/kernel/requires.rb