Class: Bump::BumpInfoRepository
- Inherits:
-
Object
- Object
- Bump::BumpInfoRepository
- Defined in:
- lib/bump/domain/bump_info_repository.rb
Overview
The repository class for the bump info persistence in file as yaml string
Instance Method Summary collapse
-
#from_file ⇒ Bump::BumpInfo
Gets the bump info from the given file.
-
#initialize(file) ⇒ BumpInfoRepository
constructor
A new instance of BumpInfoRepository.
-
#save(bump_info) ⇒ void
Saves the bump info.
- #to_yaml(bump_info) ⇒ Hash
Constructor Details
#initialize(file) ⇒ BumpInfoRepository
Returns a new instance of BumpInfoRepository.
8 9 10 |
# File 'lib/bump/domain/bump_info_repository.rb', line 8 def initialize(file) @file = file end |
Instance Method Details
#from_file ⇒ Bump::BumpInfo
Gets the bump info from the given file
16 17 18 19 20 21 |
# File 'lib/bump/domain/bump_info_repository.rb', line 16 def from_file config = YAML.load_file @file version = VersionNumberFactory.from_string config['version'] BumpInfo.new version, config['files'], config['commit'] end |
#save(bump_info) ⇒ void
This method returns an undefined value.
Saves the bump info
27 28 29 |
# File 'lib/bump/domain/bump_info_repository.rb', line 27 def save(bump_info) File.write @file, to_yaml(bump_info) end |
#to_yaml(bump_info) ⇒ Hash
34 35 36 37 38 39 40 41 42 |
# File 'lib/bump/domain/bump_info_repository.rb', line 34 def to_yaml(bump_info) hash = { 'version' => bump_info.version.to_s } hash['commit'] = bump_info.commit if bump_info.commit hash['files'] = bump_info.files hash.to_yaml end |