class Bump::BumpInfoRepository

The repository class for the bump info persistence in file as yaml string

Public Class Methods

new(file) click to toggle source

@param [String] file

# File lib/bump/domain/bump_info_repository.rb, line 8
def initialize(file)
  @file = file
end

Public Instance Methods

from_file() click to toggle source

Gets the bump info from the given file

@param [String] file @return [Bump::BumpInfo]

# 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) click to toggle source

Saves the bump info

@param [Bump::BumpInfo] bumpInfo @return [void]

# 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) click to toggle source

@private @param [Bump::BumpInfo] bumpInfo @return [Hash]

# 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