This is the file class for handling VMLib version files
Default file name of 'Version'
Create a new file object with the specified filename. If the filename is not specified, it reverts to the default
# File lib/vmlib/file.rb, line 20 def initialize(filename = nil) @filename ||= FILE_NAME @dir = nil end
Search the current and all parent folders for a version file Raises an error if it cannot find any up to the root.
# File lib/vmlib/file.rb, line 27 def find_file(dir = nil) dir ||= ::Dir.pwd raise Errors::PathError unless ::File.directory?(dir) path = ::File.join(dir, @filename) ::Dir.chdir(dir) do while !::File.exists?(path) do if (::File.dirname(path).match(/^(\w:\/|\/)$/)) raise Errors::NoVersionError, "#{dir} is not versioned" end path = ::File.join(::File.dirname(path), '..') path = ::File.expand_path(path) #puts "vmlib: looking at path #{path}" path = ::File.join(path, @filename) end @dir = path return path end