Class: Ore::Versions::VersionFile
- Defined in:
- lib/ore/versions/version_file.rb
Overview
Represents a version loaded from a VERSION
file.
Constant Summary collapse
- @@files =
Common
VERSION
file-names. %w[VERSION VERSION.yml]
Instance Attribute Summary
Attributes inherited from Version
#build, #major, #minor, #patch
Class Method Summary collapse
-
.find(project) ⇒ VersionFile?
Finds the
VERSION
file. -
.load(path) ⇒ VersionFile
Loads the version file of the project.
Methods inherited from Version
Constructor Details
This class inherits a constructor from Ore::Versions::Version
Class Method Details
.find(project) ⇒ VersionFile?
Finds the VERSION
file.
25 26 27 28 29 30 31 |
# 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) ⇒ VersionFile
Loads the version file of the project.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# 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 |