Class Sprout::VersionFile
In: sprout/lib/sprout/version_file.rb
Parent: Object

Used by the GitTask to load, parse and persist Version information related to a project. Expects a file with a 3 digit number, separated by periods like:

  3.4.2

Create with a path to the file like:

  version = VersionFile.new('path/Version.txt')

Methods

Public Class methods

[Source]

# File sprout/lib/sprout/version_file.rb, line 15
    def initialize(file_path)
      @file_path = file_path
      read_value
    end

Public Instance methods

[Source]

# File sprout/lib/sprout/version_file.rb, line 41
    def increment_revision
      self.revision = self.revision + 1
    end

[Source]

# File sprout/lib/sprout/version_file.rb, line 29
    def major_version
      @value.split('.').shift.to_i
    end

[Source]

# File sprout/lib/sprout/version_file.rb, line 33
    def minor_version
      @value.split('.')[1].to_i
    end

[Source]

# File sprout/lib/sprout/version_file.rb, line 37
    def revision
      @value.split('.').pop.to_i
    end

[Source]

# File sprout/lib/sprout/version_file.rb, line 45
    def to_s
      @value
    end

[Source]

# File sprout/lib/sprout/version_file.rb, line 49
    def to_str
      @value
    end

[Source]

# File sprout/lib/sprout/version_file.rb, line 53
    def to_tag
      parts = value.split('.')
      parts[0] = add_leading_zeros(parts[0], 2)
      parts[1] = add_leading_zeros(parts[1], 2)
      parts[2] = add_leading_zeros(parts[2], 3)
      return parts.join('.')
    end

[Source]

# File sprout/lib/sprout/version_file.rb, line 25
    def value
      @value
    end

[Source]

# File sprout/lib/sprout/version_file.rb, line 20
    def value=(value)
      @value = value
      write_value
    end

[Validate]