Class: VersionManager::VersionStorage
- Inherits:
-
Object
- Object
- VersionManager::VersionStorage
show all
- Defined in:
- lib/version-manager/version_storage.rb
Defined Under Namespace
Classes: WrongLatestVersionError
Instance Method Summary
collapse
Constructor Details
#initialize(vcs, storage_options) ⇒ VersionStorage
Returns a new instance of VersionStorage.
10
11
12
13
14
|
# File 'lib/version-manager/version_storage.rb', line 10
def initialize(vcs, storage_options)
@filename = storage_options[:filename]
@filepath = storage_options[:filepath]
@vcs = vcs
end
|
Instance Method Details
#current_version ⇒ Object
29
30
31
32
33
|
# File 'lib/version-manager/version_storage.rb', line 29
def current_version
version = version_from_branch_name(vcs.current_branch)
raise ArgumentError, 'Can not detect a current version' unless version
version_from_file(version)
end
|
#latest_version ⇒ Object
23
24
25
26
27
|
# File 'lib/version-manager/version_storage.rb', line 23
def latest_version
versions = vcs.remote_branch_names.map(&method(:version_from_branch_name))
version = select_appropriate_version(versions)
version_from_file(version)
end
|
#store(version) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/version-manager/version_storage.rb', line 16
def store(version)
File.open(full_path, 'w') do |file|
file << version
end
full_path
end
|