module Buildr::Util
Public Instance Methods
recursive_with_dot_files(*dirs)
click to toggle source
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.
# File lib/buildr/core/util.rb, line 45 def recursive_with_dot_files(*dirs) FileList[dirs.map { |dir| File.join(dir, '/**/{*,.*}') }].reject { |file| File.basename(file) =~ /^[.]{1,2}$/ } end
relative_path(to, from = '.')
click to toggle source
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'
# File lib/buildr/core/util.rb, line 33 def relative_path(to, from = '.') to = Pathname.new(to).cleanpath return to.to_s if from.nil? to_path = Pathname.new(File.expand_path(to.to_s, "/")) from_path = Pathname.new(File.expand_path(from.to_s, "/")) to_path.relative_path_from(from_path).to_s end