Sha256: c0d44352407acf94075f25206c04bcc7ef24b0902c1e7b3d2b91bdef4dd37cd4

Contents?: true

Size: 709 Bytes

Versions: 2

Compression:

Stored size: 709 Bytes

Contents

require 'ffi'
require 'ffi/library'

module FFI
  # Redefining #attach_function so we can avoid bombing out if a called method
  # is not defined.
  module Library
    alias old_attach_function attach_function

    def attach_function(*args)
      old_attach_function(*args)
    rescue FFI::NotFoundError
      @unsupported_gdal_functions ||= []

      if $VERBOSE || ENV['VERBOSE']
        warn "ffi-gdal warning: function '#{args.first}' is not available in this " \
          "build of GDAL/OGR (v#{FFI::GDAL.GDALVersionInfo('RELEASE_NAME')})"
      end

      @unsupported_gdal_functions << args.first
    end

    def unsupported_gdal_functions
      @unsupported_gdal_functions ||= []
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta7 lib/ext/ffi_library_function_checks.rb
ffi-gdal-1.0.0.beta6 lib/ext/ffi_library_function_checks.rb