lib/haml/version.rb in haml-edge-2.3.181 vs lib/haml/version.rb in haml-edge-2.3.182

- old
+ new

@@ -21,22 +21,45 @@ # :rev => "9616393b8924ef36639c7e82aa88a51a24d16949", # :number => "2.1.0", # :major => 2, :minor => 1, :teeny => 0 # } # + # If a prerelease version of Haml is being used, + # the `:string` and `:number` fields will reflect the full version + # (e.g. `"2.2.beta.1"`), and the `:tiny` field will be `-1`. + # A `:prerelease` key will contain the name of the prerelease (e.g. `"beta"`), + # and a `:prerelease_number` key will contain the rerelease number. + # For example: + # + # { + # :string => "3.0.beta.1", + # :number => "3.0.beta.1", + # :major => 3, :minor => 0, :tiny => -1, + # :prerelease => "beta", + # :prerelease_number => 1 + # } + # # @return [{Symbol => String/Fixnum}] The version hash def version return @@version if defined?(@@version) - numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i } + numbers = File.read(scope('VERSION')).strip.split('.'). + map {|n| n =~ /^[0-9]+$/ ? n.to_i : n} name = File.read(scope('VERSION_NAME')).strip @@version = { :major => numbers[0], :minor => numbers[1], :teeny => numbers[2], :name => name } - @@version[:number] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.') + + if numbers[3].is_a?(String) + @@version[:teeny] = -1 + @@version[:prerelease] = numbers[3] + @@version[:prerelease_number] = numbers[4] + end + + @@version[:number] = numbers.join('.') @@version[:string] = @@version[:number].dup if rev = revision_number @@version[:rev] = rev unless rev[0] == ?(