Class: VersionManager::VersionStorage
- Inherits:
-
Object
- Object
- VersionManager::VersionStorage
- Defined in:
- lib/version-manager/version_storage.rb
Defined Under Namespace
Classes: WrongLatestVersionError
Instance Method Summary collapse
-
#initialize(vcs, storage_options) ⇒ VersionStorage
constructor
A new instance of VersionStorage.
- #latest_version ⇒ Object
- #store(version) ⇒ Object
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, ) @filename = [:filename] @filepath = [:filepath] @vcs = vcs end |
Instance Method Details
#latest_version ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/version-manager/version_storage.rb', line 23 def latest_version versions = vcs.remote_branch_names.map do |name| name = name.split('/').last ReleaseVersion.new(name) if name.include?('release-') && ReleaseVersion.valid?(name) end version = select_appropriate_version(versions) file_content = vcs.show_file(version.branch, relative_path) if version version = ReleaseVersion.new(file_content) if file_content && ReleaseVersion.valid?(file_content) 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 |