Sha256: edfb3390be4a30ffbf8e8183b062fb1a2f0778b81e0e5427a3e0a660eee56e26

Contents?: true

Size: 795 Bytes

Versions: 282

Compression:

Stored size: 795 Bytes

Contents

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

282 entries across 249 versions & 30 rubygems

Version Path
depengine-0.0.31 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.31 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.30 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.30 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.29 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.29 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.28 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.28 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.27 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.27 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.26 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.26 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.25 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.25 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.24 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.24 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.23 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.23 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.22 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb
depengine-0.0.22 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/kernel/requires.rb