Sha256: cad524f642b0d7520489eadcb8df8dfa60bb975dc569486fc69c6e9ef8b18b41

Contents?: true

Size: 1.86 KB

Versions: 1

Compression:

Stored size: 1.86 KB

Contents

require "faster_path/version"
require 'pathname'
require 'faster_path/platform'
require 'faster_path/asset_resolution'
require 'fiddle'
require 'fiddle/import'

module FasterPath
  FFI_LIBRARY = FasterPath::Platform.ffi_library()

  Fiddle::Function.
    new(Fiddle.dlopen(FFI_LIBRARY)['Init_faster_pathname'], [], Fiddle::TYPE_VOIDP).
    call

  Public.class_eval do
    private_class_method :basename
    private_class_method :children
    private_class_method :children_compat
    private_class_method :chop_basename
    private_class_method :entries
    private_class_method :entries_compat
  end

  def self.rust_arch_bits
    Rust.rust_arch_bits
  end

  def self.ruby_arch_bits
    1.size * 8
  end

  def self.blank?(str)
    "#{str}".strip.empty?
  end

  def self.basename(pth, ext="")
    Public.send(:basename, pth, ext)
  end

  def self.children(pth, with_directory=true)
    result = Public.send(:children, pth, with_directory)
    return result if result
    raise Errno::NOENT, "No such file or directory @ dir_initialize - #{pth}"
  end

  def self.children_compat(pth, with_directory=true)
    result = Public.send(:children_compat, pth, with_directory)
    return result if result
    raise Errno::NOENT, "No such file or directory @ dir_initialize - #{pth}"
  end

  def self.chop_basename(pth)
    result = Public.send(:chop_basename, pth)
    result unless result.empty?
  end

  def self.entries(pth)
    result = Public.send(:entries, pth)
    return result if result
    raise Errno::NOENT, "No such file or directory @ dir_initialize - #{pth}"
  end

  def self.entries_compat(pth)
    result = Public.send(:entries_compat, pth)
    return result if result
    raise Errno::NOENT, "No such file or directory @ dir_initialize - #{pth}"
  end

  module Rust
    extend Fiddle::Importer
    dlload FFI_LIBRARY
    extern 'int rust_arch_bits()'
  end
  private_constant :Rust
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faster_path-0.2.4 lib/faster_path.rb