Paths contains helpful methods to determine paths of files inside the DirectoryWatcher library
Return a path relative to the 'lib' directory in this project
# File lib/directory_watcher/paths.rb, line 20 def lib_path(*args,&block) sub_path('lib', *args, &block) end
Return a path relative to the 'root' directory in the project
# File lib/directory_watcher/paths.rb, line 26 def path(*args,&block) sub_path('', *args, &block) end
The root directory of the project is considered the parent directory of the 'lib' directory.
Returns The full expanded path of the parent directory of 'lib' going up the path from the current file. Trailing File::SEPARATOR is guaranteed
# File lib/directory_watcher/paths.rb, line 12 def root_dir path_parts = ::File.expand_path(__FILE__).split(::File::SEPARATOR) lib_index = path_parts.rindex("lib") return path_parts[0...lib_index].join(::File::SEPARATOR) + ::File::SEPARATOR end
Calculate the full expanded path of the item with respect to a sub path of 'root_dir'
# File lib/directory_watcher/paths.rb, line 33 def sub_path(sub,*args,&block) rv = ::File.join(root_dir, sub) + ::File::SEPARATOR rv = ::File.join(rv, *args) if args if block with_load_path( rv ) do rv = block.call end end return rv end
Generated with the Darkfish Rdoc Generator 2.