Class: VersionManager::VersionWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/version_manager/version_writer.rb

Instance Method Summary collapse

Instance Method Details

#call(version) ⇒ Object



6
7
8
9
10
# File 'lib/version_manager/version_writer.rb', line 6

def call version
  File.write version_file, updated_version_file(version)
  File.write history_file, updated_history_file(version) if File.exist?(history_file)
  VersionTagger.new.call version
end

#updated_history_file(new_version) ⇒ Object



16
17
18
19
20
# File 'lib/version_manager/version_writer.rb', line 16

def updated_history_file new_version
  current_history = File.read history_file
  date = Date.today.strftime("%d %B %Y")
  "== #{new_version.to_tag} (#{date})\n\n#{current_history}"
end

#updated_version_file(new_version) ⇒ Object



12
13
14
# File 'lib/version_manager/version_writer.rb', line 12

def updated_version_file new_version
  File.read(version_file).gsub(new_version.starting_version, new_version.to_s)
end