Module Buildr::Util
In: lib/buildr/core/util.rb  (CVS)

Methods

Public Instance methods

Just like File.expand_path, but for windows systems it capitalizes the drive name and ensures backslashes are used

Generally speaking, it‘s not a good idea to operate on dot files (files starting with dot). These are considered invisible files (.svn, .hg, .irbrc, etc). Dir.glob/FileList ignore them on purpose. There are few cases where we do have to work with them (filter, zip), a better solution is welcome, maybe being more explicit with include. For now, this will do.

Return the path to the first argument, starting from the path provided by the second argument.

For example:

  relative_path('foo/bar', 'foo')
  => 'bar'
  relative_path('foo/bar', 'baz')
  => '../foo/bar'
  relative_path('foo/bar')
  => 'foo/bar'
  relative_path('/foo/bar', 'baz')
  => '/foo/bar'

Replace the file extension, e.g.,

  replace_extension("foo.zip", "txt") => "foo.txt"

Runs Ruby with these command line arguments. The last argument may be a hash, supporting the following keys:

  :command  -- Runs the specified script (e.g., :command=>'gem')
  :sudo     -- Run as sudo on operating systems that require it.
  :verbose  -- Override Rake's verbose flag.

Return the timestamp of file, without having to create a file task

In order to determine if we are running on a windows OS, prefer this function instead of using Gem.win_platform?.

Gem.win_platform? only checks these RUBY_PLATFORM global, that in some cases like when running on JRuby is not succifient for our purpose:

For JRuby, the value for RUBY_PLATFORM will always be ‘java’ That‘s why this function checks on Config::CONFIG[‘host_os’]

[Validate]