Class: Semverve::VersionFile

Inherits:
Object
  • Object
show all
Defined in:
lib/semverve/version_file.rb

Overview

Reads and updates an existing version file.

Defined Under Namespace

Classes: UpdateResult

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Semverve::VersionFile

Initializes a version-file reader and writer.

Parameters:



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

#currentSemverve::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.

Parameters:

  • level (Symbol, String)

Returns:



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