GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Fork of nex3/haml
Description: HTML Abstraction Markup Language - A Markup Haiku
Homepage: http://haml.hamptoncatlin.com
Clone URL: git://github.com/chriseppstein/haml.git
Make sure revision version information is preserved when installing Haml 
as a gem.
nex3 (author)
Thu Apr 10 22:54:40 -0700 2008
commit  c0a88ed133f448fd897e9d71cac577c830c0591a
tree    8a9cab108065b3784ddc3100c7125b7d5696605d
parent  ad10edf9afc8a73679f75f37a60ad33f325e2412
...
51
52
53
 
 
 
 
 
 
 
 
54
55
56
...
74
75
76
 
77
78
79
...
95
96
97
 
 
 
 
 
 
 
 
 
98
99
100
...
51
52
53
54
55
56
57
58
59
60
61
62
63
64
...
82
83
84
85
86
87
88
...
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
0
@@ -51,6 +51,14 @@ END
0
   # ----- Packaging -----
0
 
0
   require 'rake/gempackagetask'
0
+ require 'lib/haml'
0
+
0
+ # Before we run the package task,
0
+ # we want to create a REVISION file
0
+ # if we've checked out Haml from git
0
+ # and we aren't building for a release.
0
+ create_revision = Haml.version[:rev] && !Rake.application.top_level_tasks.include?('release')
0
+ p create_revision
0
 
0
   spec = Gem::Specification.new do |spec|
0
     spec.name = 'haml'
0
@@ -74,6 +82,7 @@ END
0
       list.exclude('TODO')
0
     end.to_a
0
     spec.executables = ['haml', 'html2haml', 'sass', 'css2sass']
0
+ readmes << 'REVISION' if create_revision
0
     spec.files = FileList['lib/**/*', 'bin/*', 'test/**/*', 'Rakefile', 'init.rb'].to_a + readmes
0
     spec.autorequire = ['haml', 'sass']
0
     spec.homepage = 'http://haml.hamptoncatlin.com/'
0
@@ -95,6 +104,15 @@ END
0
     pkg.need_tar_bz2 = true
0
   end
0
 
0
+ desc "This is an internal task."
0
+ task :revision_file do
0
+ File.open('REVISION', 'w') { |f| f.puts Haml.version[:rev] } if create_revision
0
+ end
0
+ Rake::Task[:package].prerequisites.insert(0, :revision_file)
0
+
0
+ # We also need to get rid of this file after packaging.
0
+ Rake::Task[:package].enhance { File.delete('REVISION') if File.exists?('REVISION') }
0
+
0
   task :install => [:package] do
0
     sh %{gem install --no-ri pkg/haml-#{File.read('VERSION').strip}}
0
   end
...
895
896
897
898
 
 
 
899
900
901
902
 
903
 
904
905
906
...
895
896
897
 
898
899
900
901
902
903
904
905
906
907
908
909
910
0
@@ -895,12 +895,16 @@ module Haml
0
     }
0
     @@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
0
 
0
- if File.exists?(scope('.git/HEAD'))
0
+ if File.exists?(scope('REVISION'))
0
+ rev = File.read(scope('REVISION')).strip
0
+ elsif File.exists?(scope('.git/HEAD'))
0
       rev = File.read(scope('.git/HEAD')).strip
0
       if rev =~ /^ref: (.*)$/
0
         rev = File.read(scope(".git/#{$1}")).strip
0
       end
0
+ end
0
 
0
+ if rev
0
       @@version[:rev] = rev
0
       @@version[:string] << "." << rev[0...7]
0
     end

Comments

    No one has commented yet.