Reset the dir
and path
values. The next time dir
or path
is requested, the values will be calculated from scratch. This is mainly used by the unit tests to provide test isolation.
Returns a list of paths matching glob
that can be used by a gem to pick up features from other gems. For example:
Gem.find_files('rdoc/discover').each do |path| load path end
if check_load_path
is true (the default), then find_files
also searches $LOAD_PATH for files as well as gems.
Note that find_files
will return all files even if they are from different versions of the same gem. See also find_latest_files
Open a file with given flags, and on Windows protect access with flock
An Array
of the default sources that come with RubyGems
Default home directory path to be used if an alternate value is not specified in the environment
The path to standard location of the user’s state file.
Default gem load path
The default directory for binaries
Default options for gem commands for Ruby implementers.
The options here should be structured as an array of string “gem” command names as keys and a string of the default options as values.
Example:
def self.platform_defaults
{ 'install' => '--no-rdoc --no-ri --env-shebang', 'update' => '--no-rdoc --no-ri --env-shebang' }
end
Removes server
from the list of registered servers.
Removes server
from the list of registered servers.
Copies file from src
to dest
, which should not be directories.
Arguments src
and dest
should be interpretable as paths.
Examples:
FileUtils.touch('src0.txt') FileUtils.copy_file('src0.txt', 'dest0.txt') File.file?('dest0.txt') # => true
Keyword arguments:
dereference: false
- if src
is a symbolic link, does not follow the link.
preserve: true
- preserves file times.
remove_destination: true
- removes dest
before copying files.
Related: methods for copying.
Copies file from src
to dest
, which should not be directories.
Arguments src
and dest
should be interpretable as paths.
Examples:
FileUtils.touch('src0.txt') FileUtils.copy_file('src0.txt', 'dest0.txt') File.file?('dest0.txt') # => true
Keyword arguments:
dereference: false
- if src
is a symbolic link, does not follow the link.
preserve: true
- preserves file times.
remove_destination: true
- removes dest
before copying files.
Related: methods for copying.
Removes the entry given by path
, which should be the entry for a regular file, a symbolic link, or a directory.
Argument path
should be interpretable as a path.
Optional argument force
specifies whether to ignore raised exceptions of StandardError
and its descendants.
Related: FileUtils.remove_entry_secure
.
Removes the entry given by path
, which should be the entry for a regular file, a symbolic link, or a directory.
Argument path
should be interpretable as a path.
Optional argument force
specifies whether to ignore raised exceptions of StandardError
and its descendants.
Related: FileUtils.remove_entry_secure
.
Recursively removes the directory entry given by path
, which should be the entry for a regular file, a symbolic link, or a directory.
Argument path
should be interpretable as a path.
Optional argument force
specifies whether to ignore raised exceptions of StandardError
and its descendants.
Related: methods for deleting.
Recursively removes the directory entry given by path
, which should be the entry for a regular file, a symbolic link, or a directory.
Argument path
should be interpretable as a path.
Optional argument force
specifies whether to ignore raised exceptions of StandardError
and its descendants.
Related: methods for deleting.
Returns true
if the contents of files a
and b
are identical, false
otherwise.
Arguments a
and b
should be interpretable as a path.
FileUtils.identical?
and FileUtils.cmp
are aliases for FileUtils.compare_file
.
Related: FileUtils.compare_stream
.
Returns true
if the contents of files a
and b
are identical, false
otherwise.
Arguments a
and b
should be interpretable as a path.
FileUtils.identical?
and FileUtils.cmp
are aliases for FileUtils.compare_file
.
Related: FileUtils.compare_stream
.
Searches for the executable bin
on path
. The default path is your PATH
environment variable. If that isn’t defined, it will resort to searching /usr/local/bin, /usr/ucb, /usr/bin and /bin.
If found, it will return the full path, including the executable name, of where it was found.
Note that this method does not actually affect the generated Makefile.
Generates the Makefile for your extension, passing along any options and preprocessor constants that you may have generated through other methods.
The target
name should correspond the name of the global function name defined within your C extension, minus the Init_
. For example, if your C extension is defined as Init_foo
, then your target would simply be “foo”.
If any “/” characters are present in the target name, only the last name is interpreted as the target name, and the rest are considered toplevel directory names, and the generated Makefile will be altered accordingly to follow that directory structure.
For example, if you pass “test/foo” as a target name, your extension will be installed under the “test” directory. This means that in order to load the file within a Ruby program later, that directory structure will have to be followed, e.g. require 'test/foo'
.
The srcprefix
should be used when your source files are not in the same directory as your build script. This will not only eliminate the need for you to manually copy the source files into the same directory as your build script, but it also sets the proper target_prefix
in the generated Makefile.
Setting the target_prefix
will, in turn, install the generated binary in a directory under your RbConfig::CONFIG['sitearchdir']
that mimics your local filesystem when you run make install
.
For example, given the following file tree:
ext/ extconf.rb test/ foo.c
And given the following code:
create_makefile('test/foo', 'test')
That will set the target_prefix
in the generated Makefile to “test”. That, in turn, will create the following file tree when installed via the make install
command:
/path/to/ruby/sitearchdir/test/foo.so
It is recommended that you use this approach to generate your makefiles, instead of copying files around manually, because some third party libraries may depend on the target_prefix
being set properly.
The srcprefix
argument can be used to override the default source directory, i.e. the current directory. It is included as part of the VPATH
and added to the list of INCFLAGS
.