Class | NiceFFI::PathSet |
In: |
lib/nice-ffi/pathset.rb
|
Parent: | Object |
PathSet is a collection of directory paths and file name templates, used to help NiceFFI find library files. It allows per-operating system paths and file name templates, using regular expressions to match the OS name.
Each PathSet holds two hashes, @paths and @files.
systems that match the regular expression /linux|bsd/ (e.g. ‘linux’, ‘freebsd’, and ‘openbsd’), look for libraries first in the directory ’/usr/local/lib/’, then in ’/usr/lib/’."
There are several methods to modify @paths and/or @files. See append, prepend, replace, remove, and delete.
Once @paths and @files are set up, use find to look for a file with a matching name.
NiceFFI::PathSet::DEFAULT is a pre-made PathSet with paths and file name templates for Linux/BSD, Mac (Darwin), and Windows. It is the default PathSet used by NiceFFI::Library.load_library, and you can also use it as a base for custom PathSets.
files | [R] | |
paths | [R] |
Create a copy of this PathSet and append the new paths and/or files. If the copy already has entries for a given regexp, the new entries will be added after the current entries.
option: | You can optionally give either :paths or :files as the first argument to this method. If :paths, only @paths will be modified, @files will never be modified. If :files, only @files will be modified, @paths will never be modified. |
entries: | One or more PathSets, Hashes, Arrays, or Strings, or any assortment of these types. |
See also append! for a version of this method which modifies self instead of making a copy.
Like append, but modifies self instead of making a copy.
Creates a copy of this PathSet and delete all entries from the copy for the given regexp(s) from @paths and/or @files. Has no effect on entries for regexps that are not given.
option: | You can optionally give either :paths or :files as the first argument to this method. If :paths, only @paths will be modified, @files will never be modified. If :files, only @files will be modified, @paths will never be modified. |
regexps: | One or more Regexps to remove entries for. |
See also delete! for a version of this method which modifies self instead of making a copy.
Like delete, but modifies self instead of making a copy.
Try to find a file based on the paths in this PathSet.
*names: | Strings to try substituting for [NAME] in the paths. |
Returns an Array of the paths of matching files, or [] if there were no matches.
Raises LoadError if the current operating system did not match any of the regular expressions in the PathSet.
Creates a copy of this PathSet and prepends the new paths and/or files. If the copy already has entries for a given regexp, the new entries will be added before the current entries.
option: | You can optionally give either :paths or :files as the first argument to this method. If :paths, only @paths will be modified, @files will never be modified. If :files, only @files will be modified, @paths will never be modified. |
entries: | One or more PathSets, Hashes, Arrays, or Strings, or any assortment of these types. |
See also prepend! for a version of this method which modifies self instead of making a copy.
Like prepend, but modifies self instead of making a copy.
Creates a copy of this PathSet and removes the given entries from the copy, if it has them. This only removes the entries that are given, other entries for the same regexp are kept. Regexps with no entries left afterwards are removed from the PathSet.
option: | You can optionally give either :paths or :files as the first argument to this method. If :paths, only @paths will be modified, @files will never be modified. If :files, only @files will be modified, @paths will never be modified. |
entries: | One or more PathSets, Hashes, Arrays, or Strings, or any assortment of these types. |
See also remove! for a version of this method which modifies self instead of making a copy.
Like remove, but modifies self instead of making a copy.
Creates a copy of this PathSet and overrides existing entries with the new entries. If the copy already has entries for a regexp in the new entries, the old entries will be discarded and the new entries used instead.
option: | You can optionally give either :paths or :files as the first argument to this method. If :paths, only @paths will be modified, @files will never be modified. If :files, only @files will be modified, @paths will never be modified. |
entries: | One or more PathSets, Hashes, Arrays, or Strings, or any assortment of these types. |
See also replace! for a version of this method which modifies self instead of making a copy.
Like replace, but modifies self instead of making a copy.