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



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

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



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

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



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

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