Sha256: fcf8c1821744d09b053d620c45c9c6195bb37023fba739448ab94f28c38e4941

Contents?: true

Size: 447 Bytes

Versions: 2

Compression:

Stored size: 447 Bytes

Contents

module BuildMaster
class BuildNumberFile
  attr_reader :number
  
  def initialize(path)
    @path = path
    @number = load_content().chomp!.to_i
  end
  
  def increase_build
    @number = @number + 1
    save_content
  end
  
  private
  def load_content()
    content = nil
    File.open(@path, 'r') {|file| content = file.gets}
    return content
  end
  
  def save_content
    File.open(@path, 'w') {|file| file.puts @number}
  end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
BuildMaster-0.8.0 lib/buildmaster/build_number_file.rb
BuildMaster-0.8.1 lib/buildmaster/build_number_file.rb