Sha256: b24d020124d7ae6750e7a012960e7fa078f6f2cb06931cedb926537ed446fc06

Contents?: true

Size: 754 Bytes

Versions: 3

Compression:

Stored size: 754 Bytes

Contents

# frozen_string_literal: true

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.fetch("VERBOSE", nil)
        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

3 entries across 3 versions & 1 rubygems

Version Path
ffi-gdal-1.1.0 lib/ext/ffi_library_function_checks.rb
ffi-gdal-1.0.4 lib/ext/ffi_library_function_checks.rb
ffi-gdal-1.0.3 lib/ext/ffi_library_function_checks.rb