#!/usr/bin/env ruby require 'pathname' gempath = Pathname.new(File.expand_path('../../', __FILE__)) files = %w( Gemfile *.md **/**/{*,.rspec,.gitignore,.yardopts} ).map { |file| Pathname.glob(file) }.flatten rejection_patterns = [ "^public/system", "^config/(application|boot|environment).rb$", "^config/initializers(\/.*\.rb)?$", "^config/(database|i18n\-js).yml$", "^lib\/gemspec\.rb", ".*\/cache\/", "^script\/*", "^vendor\/plugins\/?$", "(^log|\.log)$", "\.rbc$", "^tmp(|/.+?)$", ".gem$", "^doc($|\/)" ] files.reject! do |f| !f.exist? or (f.directory? and f.children.empty?) =~ %r{(#{rejection_patterns.join(')|(')})} end gemspec = < 0.9.9.10' s.files = [ '#{files.sort.join("',\n '")}' ] end EOF (gemfile = gempath.join("#{gemname}.gemspec")).open('w') {|f| f.puts(gemspec)} puts `cd #{gempath} && gem build #{gemfile}` if ARGV.any?{|a| a == "BUILD=true"}