<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
    <added>
      <filename>rack-contrib.gemspec</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -5,60 +5,6 @@ require 'rake/testtask'
 desc &quot;Run all the tests&quot;
 task :default =&gt; [:test]
 
-desc &quot;Do predistribution stuff&quot;
-task :predist =&gt; [:changelog, :rdoc]
-
-desc &quot;Make an archive as .tar.gz&quot;
-task :dist =&gt; [:fulltest, :predist] do
-  sh &quot;git archive --format=tar --prefix=#{release}/ HEAD^{tree} &gt;#{release}.tar&quot;
-  sh &quot;pax -waf #{release}.tar -s ':^:#{release}/:' RDOX ChangeLog doc&quot;
-  sh &quot;gzip -f -9 #{release}.tar&quot;
-end
-
-# Helper to retrieve the &quot;revision number&quot; of the git tree.
-def git_tree_version
-  if File.directory?(&quot;.git&quot;)
-    @tree_version ||= `git describe`.strip.sub('-', '.')
-    @tree_version &lt;&lt; &quot;.0&quot;  unless @tree_version.count('.') == 2
-  else
-    $: &lt;&lt; &quot;lib&quot;
-    require 'rack/contrib'
-    @tree_version = Rack::Contrib.release
-  end
-  @tree_version
-end
-
-def gem_version
-  git_tree_version.gsub(/-.*/, '')
-end
-
-def release
-  &quot;rack-contrib-#{git_tree_version}&quot;
-end
-
-def manifest
-  `git ls-files`.split(&quot;\n&quot;)
-end
-
-
-desc &quot;Generate a ChangeLog&quot;
-task :changelog do
-  File.open(&quot;ChangeLog&quot;, &quot;w&quot;) { |out|
-    `git log -z`.split(&quot;\0&quot;).map { |chunk|
-      author = chunk[/Author: (.*)/, 1].strip
-      date = chunk[/Date: (.*)/, 1].strip
-      desc, detail = $'.strip.split(&quot;\n&quot;, 2)
-      detail ||= &quot;&quot;
-      detail.rstrip!
-      out.puts &quot;#{date}  #{author}&quot;
-      out.puts &quot;  * #{desc.strip}&quot;
-      out.puts detail  unless detail.empty?
-      out.puts
-    }
-  }
-end
-
-
 desc &quot;Generate RDox&quot;
 task &quot;RDOX&quot; do
   sh &quot;specrb -Ilib:test -a --rdox &gt;RDOX&quot;
@@ -87,3 +33,52 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
   rdoc.rdoc_files.include('lib/rack/*/*.rb')
 end
 task :rdoc =&gt; [&quot;RDOX&quot;]
+
+
+# PACKAGING =================================================================
+
+# load gemspec like github's gem builder to surface any SAFE issues.
+require 'rubygems/specification'
+$spec = eval(File.read('rack-contrib.gemspec'))
+
+def package(ext='')
+  &quot;pkg/rack-contrib-#{$spec.version}&quot; + ext
+end
+
+desc 'Build packages'
+task :package =&gt; %w[.gem .tar.gz].map {|e| package(e)}
+
+desc 'Build and install as local gem'
+task :install =&gt; package('.gem') do
+  sh &quot;gem install #{package('.gem')}&quot;
+end
+
+directory 'pkg/'
+
+file package('.gem') =&gt; %w[pkg/ rack-contrib.gemspec] + $spec.files do |f|
+  sh &quot;gem build rack-contrib.gemspec&quot;
+  mv File.basename(f.name), f.name
+end
+
+file package('.tar.gz') =&gt; %w[pkg/] + $spec.files do |f|
+  sh &quot;git archive --format=tar HEAD | gzip &gt; #{f.name}&quot;
+end
+
+# GEMSPEC ===================================================================
+
+file 'rack-contrib.gemspec' =&gt; FileList['{lib,test}/**','Rakefile', 'README'] do |f|
+  # read spec file and split out manifest section
+  spec = File.read(f.name)
+  parts = spec.split(&quot;  # = MANIFEST =\n&quot;)
+  fail 'bad spec' if parts.length != 3
+  # determine file list from git ls-files
+  files = `git ls-files`.
+    split(&quot;\n&quot;).sort.reject{ |file| file =~ /^\./ }.
+    map{ |file| &quot;    #{file}&quot; }.join(&quot;\n&quot;)
+  # piece file back together and write...
+  parts[1] = &quot;  s.files = %w[\n#{files}\n  ]\n&quot;
+  spec = parts.join(&quot;  # = MANIFEST =\n&quot;)
+  spec.sub!(/s.date = '.*'/, &quot;s.date = '#{Time.now.strftime(&quot;%Y-%m-%d&quot;)}'&quot;)
+  File.open(f.name, 'w') { |io| io.write(spec) }
+  puts &quot;updated #{f.name}&quot;
+end</diff>
      <filename>Rakefile</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>daf75462c482e0e35786be25f6787440e5ed79e7</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Tomayko</name>
    <email>rtomayko@gmail.com</email>
  </author>
  <url>http://github.com/rtomayko/rack-contrib/commit/ea74434c669998b2e2f801b22e09dc38cc70751f</url>
  <id>ea74434c669998b2e2f801b22e09dc38cc70751f</id>
  <committed-date>2008-12-08T21:22:46-08:00</committed-date>
  <authored-date>2008-12-08T18:47:09-08:00</authored-date>
  <message>Add gemspec for github builds and clean up Rakefile a bit</message>
  <tree>e66750985b9238496ecc98fc1187dc05e71d08c2</tree>
  <committer>
    <name>Ryan Tomayko</name>
    <email>rtomayko@gmail.com</email>
  </committer>
</commit>
