1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Add a VERSION_NAME file.

This commit is contained in:
Nathan Weizenbaum 2009-06-29 21:46:59 -07:00
parent a6bfe3f8a2
commit 7518015a1b
3 changed files with 11 additions and 6 deletions

View file

@ -71,8 +71,9 @@ end
desc "Release a new Haml package to Rubyforge. Requires the NAME and VERSION flags." desc "Release a new Haml package to Rubyforge. Requires the NAME and VERSION flags."
task :release => [:package] do task :release => [:package] do
name, version = ENV['NAME'], ENV['VERSION'] name = File.read("VERSION_NAME").strip
raise "Must supply NAME and VERSION for release task." unless name && version version = File.read("VERSION").strip
raise "VERSION_NAME must not be 'Bleeding Edge'" if name == "Bleeding Edge"
sh %{rubyforge login} sh %{rubyforge login}
sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem} sh %{rubyforge add_release haml haml "#{name} (v#{version})" pkg/haml-#{version}.gem}
sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz} sh %{rubyforge add_file haml haml "#{name} (v#{version})" pkg/haml-#{version}.tar.gz}

1
VERSION_NAME Normal file
View file

@ -0,0 +1 @@
Bleeding Edge

View file

@ -10,6 +10,7 @@ module Haml
# Returns a hash representing the version of Haml. # Returns a hash representing the version of Haml.
# The `:major`, `:minor`, and `:teeny` keys have their respective numbers as Fixnums. # The `:major`, `:minor`, and `:teeny` keys have their respective numbers as Fixnums.
# The `:name` key has the name of the version.
# The `:string` key contains a human-readable string representation of the version. # The `:string` key contains a human-readable string representation of the version.
# If Haml is checked out from Git, the `:rev` key will have the revision hash. # If Haml is checked out from Git, the `:rev` key will have the revision hash.
# For example: # For example:
@ -20,15 +21,17 @@ module Haml
# :major => 2, :minor => 1, :teeny => 0 # :major => 2, :minor => 1, :teeny => 0
# } # }
# #
# @return [Hash<Symbol, String/Symbol>] The version hash # @return [Hash<Symbol, String/Fixnum>] The version hash
def version def version
return @@version if defined?(@@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.to_i }
name = File.read(scope('VERSION_NAME')).strip
@@version = { @@version = {
:major => numbers[0], :major => numbers[0],
:minor => numbers[1], :minor => numbers[1],
:teeny => numbers[2] :teeny => numbers[2],
:name => name
} }
@@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.') @@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
@ -47,9 +50,9 @@ module Haml
if rev if rev
@@version[:rev] = rev @@version[:rev] = rev
unless rev[0] == ?( unless rev[0] == ?(
@@version[:string] << "." @@version[:string] << "." << rev[0...7]
@@version[:string] << rev[0...7]
end end
@@version[:string] << " (#{name})"
end end
@@version @@version