Class: Semverve::VersionFile
- Inherits:
-
Object
- Object
- Semverve::VersionFile
- Defined in:
- lib/semverve/version_file.rb
Overview
Reads and updates an existing version file.
Defined Under Namespace
Classes: UpdateResult
Instance Method Summary collapse
-
#current ⇒ Semverve::SemanticVersion
Current semantic version parsed from the version file.
-
#increment(level) ⇒ Semverve::VersionFile::UpdateResult
Increments one semantic-version level and writes the result.
-
#initialize(configuration) ⇒ Semverve::VersionFile
constructor
Initializes a version-file reader and writer.
-
#set(version) ⇒ Semverve::VersionFile::UpdateResult
Sets the version file to an explicit semantic version.
Constructor Details
#initialize(configuration) ⇒ Semverve::VersionFile
Initializes a version-file reader and writer.
54 55 56 57 |
# File 'lib/semverve/version_file.rb', line 54 def initialize(configuration) @configuration = configuration @format = Formats.fetch(configuration.format) end |
Instance Method Details
#current ⇒ Semverve::SemanticVersion
Current semantic version parsed from the version file.
63 64 65 |
# File 'lib/semverve/version_file.rb', line 63 def current format.parse(read, path: path) end |
#increment(level) ⇒ Semverve::VersionFile::UpdateResult
Increments one semantic-version level and writes the result.
73 74 75 |
# File 'lib/semverve/version_file.rb', line 73 def increment(level) update { |version| version.increment(level) } end |
#set(version) ⇒ Semverve::VersionFile::UpdateResult
Sets the version file to an explicit semantic version.
83 84 85 |
# File 'lib/semverve/version_file.rb', line 83 def set(version) update { version } end |