Find file
Fetching contributors…
Cannot retrieve contributors at this time
104 lines (86 sloc) 3.27 KB
require "rubygems"
require "rubygems/package_task"
require "rdoc/task"
task :default => :test
require "rake/testtask"
Rake::TestTask.new do |t|
t.libs = [File.expand_path("lib"), "test"]
t.test_files = FileList["test/**/*_test.rb"]
t.verbose = true
end
# This builds the actual gem. For details of what all these options
# mean, and other ones you can add, check the documentation here:
#
# http://rubygems.org/read/chapter/20
#
spec = Gem::Specification.new do |s|
# Change these as appropriate
s.name = "gem-this"
s.version = "0.3.7"
s.summary = "Make existing code into a gem, without any fuss."
s.author = "James Adam"
s.email = "james@lazyatom.com"
s.homepage = "http://github.com/lazyatom/gem-this"
s.has_rdoc = true
# s.extra_rdoc_files = %w(Readme.markdown)
# s.rdoc_options = %w(--main Readme.markdown)
# Add any extra files to include in the gem
s.files = %w(Rakefile Readme.markdown Rakefile.erb) + Dir.glob("{bin,lib,test}/**/*")
s.executables = FileList["bin/**"].map { |f| File.basename(f) }
s.require_paths = ["bin", "lib"]
# If you want to depend on other gems, add them here, along with any
# relevant versions
# s.add_dependency("some_other_gem", "~> 0.1.0")
# If your tests use any gems, include them here
s.add_development_dependency("shoulda")
s.add_development_dependency("rspec")
s.add_development_dependency("cucumber")
# If you want to publish automatically to rubyforge, you'll may need
# to tweak this, and the publishing task below too.
s.rubyforge_project = "gem-this"
s.required_rubygems_version = Gem::Requirement.new(">= 1.3")
end
# This task actually builds the gem. We also regenerate a static
# .gemspec file, which is useful if something (i.e. GitHub) will
# be automatically building a gem for this project. If you're not
# using GitHub, edit as appropriate.
Gem::PackageTask.new(spec) do |pkg|
pkg.gem_spec = spec
end
desc "Build the gemspec file #{spec.name}.gemspec"
task :gemspec do
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
File.open(file, "w") {|f| f << spec.to_ruby }
end
task :package => :gemspec
# Generate documentation
RDoc::Task.new do |rd|
rd.main = "Readme.markdown"
rd.rdoc_files.include("Readme.markdown", "lib/**/*.rb")
rd.rdoc_dir = "rdoc"
end
desc 'Clear out RDoc and generated packages'
task :clean => [:clobber_rdoc, :clobber_package] do
rm "#{spec.name}.gemspec"
end
desc 'Tag the repository in git with gem version number'
task :tag do
changed_files = `git diff --cached --name-only`.split("\n") + `git diff --name-only`.split("\n")
if changed_files.empty? || changed_files == ['Rakefile']
Rake::Task["package"].invoke
if `git tag`.split("\n").include?("v#{spec.version}")
raise "Version #{spec.version} has already been released"
end
`git add #{File.expand_path("../#{spec.name}.gemspec", __FILE__)} Rakefile`
`git commit -m "Released version #{spec.version}"`
`git tag v#{spec.version}`
`git push --tags`
`git push`
else
raise "Repository contains uncommitted changes; either commit or stash."
end
end
desc "Tag and publish the gem to rubygems.org"
task :publish => :tag do
`gem push pkg/#{spec.name}-#{spec.version}.gem`
end