summaryrefslogtreecommitdiff
path: root/lib/oxidized/version.rb
blob: c44884ab00ecff3f56c853c64cc7cc0ea815b167 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Oxidized
  VERSION = '0.23.0'
  VERSION_FULL = '0.23.0-19-g4690521'
  def self.version_set
    version_full = %x(git describe --tags).chop rescue ""
    version      = %x(git describe --tags --abbrev=0).chop rescue ""

    return false unless [version, version_full].none?(&:empty?)

    Oxidized.send(:remove_const, :VERSION)
    Oxidized.send(:remove_const, :VERSION_FULL)
    const_set(:VERSION, version)
    const_set(:VERSION_FULL, version_full)
    file = File.readlines(__FILE__)
    file[1] = "  VERSION = '%s'\n" % VERSION
    file[2] = "  VERSION_FULL = '%s'\n" % VERSION_FULL
    File.write(__FILE__, file.join)
  end
end