Method: Version.current

Defined in:
lib/asrake/version/version.rb

.current(path = nil) ⇒ Object

name as path to autodetect within a given directory



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/asrake/version/version.rb', line 39

def self.current(path = nil)
	# if path is nil, detect automatically; if path is a directory, detect
	# automatically in the directory; if path is a filename, use it directly
	path = path ? Pathname.new(path) : self.version_file(caller.first)
	path = self.version_file(path) unless path.nil? or path.file?
	
	return nil unless path
	
	case path.extname
		when ''		then Version.to_version(path.read.strip)
		when '.yml'	then Version.to_version(YAML::load(path.read))
	end
end