class Ore::Versions::VersionFile
Represents a version loaded from a ‘VERSION` file.
Public Class Methods
find(project)
click to toggle source
Finds the ‘VERSION` file.
@param [Project] project
The Ore project.
@return [VersionFile, nil]
The version file of the project.
# File lib/ore/versions/version_file.rb, line 25 def self.find(project) @@files.each do |name| return load(project.path(name)) if project.file?(name) end return nil end
load(path)
click to toggle source
Loads the version file of the project.
@param [String] path
The path to the version file.
@return [VersionFile]
The loaded version file.
@raise [InvalidVersion]
The `VERSION` file must contain either a `Hash` or a `String`.
# File lib/ore/versions/version_file.rb, line 45 def self.load(path) data = YAML.load_file(path) case data when Hash self.new( (data[:major] || data['major']), (data[:minor] || data['minor']), (data[:patch] || data['patch']), (data[:build] || data['build']) ) when String self.parse(data) else file = File.basename(@path) raise(InvalidVersion,"invalid version data in #{file.dump}") end end