From 7518015a1b67a76821d593c964fa0460b522395a Mon Sep 17 00:00:00 2001 From: Nathan Weizenbaum Date: Mon, 29 Jun 2009 21:46:59 -0700 Subject: [PATCH] Add a VERSION_NAME file. --- Rakefile | 5 +++-- VERSION_NAME | 1 + lib/haml/version.rb | 11 +++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 VERSION_NAME diff --git a/Rakefile b/Rakefile index 3f7c28d6..51e367b1 100644 --- a/Rakefile +++ b/Rakefile @@ -71,8 +71,9 @@ end desc "Release a new Haml package to Rubyforge. Requires the NAME and VERSION flags." task :release => [:package] do - name, version = ENV['NAME'], ENV['VERSION'] - raise "Must supply NAME and VERSION for release task." unless name && version + name = File.read("VERSION_NAME").strip + version = File.read("VERSION").strip + raise "VERSION_NAME must not be 'Bleeding Edge'" if name == "Bleeding Edge" sh %{rubyforge login} 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} diff --git a/VERSION_NAME b/VERSION_NAME new file mode 100644 index 00000000..ee5e396d --- /dev/null +++ b/VERSION_NAME @@ -0,0 +1 @@ +Bleeding Edge diff --git a/lib/haml/version.rb b/lib/haml/version.rb index 96dee314..c1db87f8 100644 --- a/lib/haml/version.rb +++ b/lib/haml/version.rb @@ -10,6 +10,7 @@ module Haml # Returns a hash representing the version of Haml. # 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. # If Haml is checked out from Git, the `:rev` key will have the revision hash. # For example: @@ -20,15 +21,17 @@ module Haml # :major => 2, :minor => 1, :teeny => 0 # } # - # @return [Hash] The version hash + # @return [Hash] The version hash def version return @@version if defined?(@@version) numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i } + name = File.read(scope('VERSION_NAME')).strip @@version = { :major => numbers[0], :minor => numbers[1], - :teeny => numbers[2] + :teeny => numbers[2], + :name => name } @@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.') @@ -47,9 +50,9 @@ module Haml if rev @@version[:rev] = rev unless rev[0] == ?( - @@version[:string] << "." - @@version[:string] << rev[0...7] + @@version[:string] << "." << rev[0...7] end + @@version[:string] << " (#{name})" end @@version