Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add gemspec for github builds and clean up Rakefile a bit

  • Loading branch information...
commit ea74434c669998b2e2f801b22e09dc38cc70751f 1 parent daf7546
@rtomayko rtomayko authored
Showing with 109 additions and 54 deletions.
  1. +4 −0 .gitignore
  2. +49 −54 Rakefile
  3. +56 −0 rack-contrib.gemspec
View
4 .gitignore
@@ -0,0 +1,4 @@
+/pkg
+/doc
+/RDOX
+ChangeLog
View
103 Rakefile
@@ -5,60 +5,6 @@ require 'rake/testtask'
desc "Run all the tests"
task :default => [:test]
-desc "Do predistribution stuff"
-task :predist => [:changelog, :rdoc]
-
-desc "Make an archive as .tar.gz"
-task :dist => [:fulltest, :predist] do
- sh "git archive --format=tar --prefix=#{release}/ HEAD^{tree} >#{release}.tar"
- sh "pax -waf #{release}.tar -s ':^:#{release}/:' RDOX ChangeLog doc"
- sh "gzip -f -9 #{release}.tar"
-end
-
-# Helper to retrieve the "revision number" of the git tree.
-def git_tree_version
- if File.directory?(".git")
- @tree_version ||= `git describe`.strip.sub('-', '.')
- @tree_version << ".0" unless @tree_version.count('.') == 2
- else
- $: << "lib"
- require 'rack/contrib'
- @tree_version = Rack::Contrib.release
- end
- @tree_version
-end
-
-def gem_version
- git_tree_version.gsub(/-.*/, '')
-end
-
-def release
- "rack-contrib-#{git_tree_version}"
-end
-
-def manifest
- `git ls-files`.split("\n")
-end
-
-
-desc "Generate a ChangeLog"
-task :changelog do
- File.open("ChangeLog", "w") { |out|
- `git log -z`.split("\0").map { |chunk|
- author = chunk[/Author: (.*)/, 1].strip
- date = chunk[/Date: (.*)/, 1].strip
- desc, detail = $'.strip.split("\n", 2)
- detail ||= ""
- detail.rstrip!
- out.puts "#{date} #{author}"
- out.puts " * #{desc.strip}"
- out.puts detail unless detail.empty?
- out.puts
- }
- }
-end
-
-
desc "Generate RDox"
task "RDOX" do
sh "specrb -Ilib:test -a --rdox >RDOX"
@@ -87,3 +33,52 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/rack/*/*.rb')
end
task :rdoc => ["RDOX"]
+
+
+# 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='')
+ "pkg/rack-contrib-#{$spec.version}" + ext
+end
+
+desc 'Build packages'
+task :package => %w[.gem .tar.gz].map {|e| package(e)}
+
+desc 'Build and install as local gem'
+task :install => package('.gem') do
+ sh "gem install #{package('.gem')}"
+end
+
+directory 'pkg/'
+
+file package('.gem') => %w[pkg/ rack-contrib.gemspec] + $spec.files do |f|
+ sh "gem build rack-contrib.gemspec"
+ mv File.basename(f.name), f.name
+end
+
+file package('.tar.gz') => %w[pkg/] + $spec.files do |f|
+ sh "git archive --format=tar HEAD | gzip > #{f.name}"
+end
+
+# GEMSPEC ===================================================================
+
+file 'rack-contrib.gemspec' => FileList['{lib,test}/**','Rakefile', 'README'] do |f|
+ # read spec file and split out manifest section
+ spec = File.read(f.name)
+ parts = spec.split(" # = MANIFEST =\n")
+ fail 'bad spec' if parts.length != 3
+ # determine file list from git ls-files
+ files = `git ls-files`.
+ split("\n").sort.reject{ |file| file =~ /^\./ }.
+ map{ |file| " #{file}" }.join("\n")
+ # piece file back together and write...
+ parts[1] = " s.files = %w[\n#{files}\n ]\n"
+ spec = parts.join(" # = MANIFEST =\n")
+ spec.sub!(/s.date = '.*'/, "s.date = '#{Time.now.strftime("%Y-%m-%d")}'")
+ File.open(f.name, 'w') { |io| io.write(spec) }
+ puts "updated #{f.name}"
+end
View
56 rack-contrib.gemspec
@@ -0,0 +1,56 @@
+Gem::Specification.new do |s|
+ s.specification_version = 2 if s.respond_to? :specification_version=
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+
+ s.name = 'rack-contrib'
+ s.version = '0.4.0'
+ s.date = '2008-12-08'
+
+ s.description = "Contributed Rack Middleware and Utilities"
+ s.summary = "Contributed Rack Middleware and Utilities"
+
+ s.authors = ["rack-devel"]
+ s.email = "rack-devel@googlegroups.com"
+
+ # = MANIFEST =
+ s.files = %w[
+ COPYING
+ README
+ Rakefile
+ lib/rack/content_length.rb
+ lib/rack/contrib.rb
+ lib/rack/etag.rb
+ lib/rack/jsonp.rb
+ lib/rack/lighttpd_script_name_fix.rb
+ lib/rack/locale.rb
+ lib/rack/mailexceptions.rb
+ lib/rack/post_body_content_type_parser.rb
+ lib/rack/profiler.rb
+ lib/rack/sendfile.rb
+ lib/rack/time_zone.rb
+ rack-contrib.gemspec
+ test/mail_settings.rb
+ test/spec_rack_content_length.rb
+ test/spec_rack_contrib.rb
+ test/spec_rack_etag.rb
+ test/spec_rack_jsonp.rb
+ test/spec_rack_lighttpd_script_name_fix.rb
+ test/spec_rack_mailexceptions.rb
+ test/spec_rack_post_body_content_type_parser.rb
+ test/spec_rack_sendfile.rb
+ ]
+ # = MANIFEST =
+
+ s.test_files = s.files.select {|path| path =~ /^test\/spec_.*\.rb/}
+
+ s.extra_rdoc_files = %w[README COPYING RDOX]
+ s.add_dependency 'rack', '~> 0.4'
+ s.add_dependency 'tmail', '>= 1.2'
+ s.add_dependency 'json', '>= 1.1'
+
+ s.has_rdoc = true
+ s.homepage = "http://github.com/rtomayko/rack-contrib/"
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "rack-contrib", "--main", "README"]
+ s.require_paths = %w[lib]
+ s.rubygems_version = '1.1.1'
+end
Please sign in to comment.
Something went wrong with that request. Please try again.