Permalink
Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
131 lines (114 sloc) 3.88 KB
require "rubygems"
require "rubygems/package_task"
require "rdoc/task"
<% if using_rspec? %>
require "rspec"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new do |t|
t.rspec_opts = %w(--format documentation --colour)
end
<% elsif using_test_unit? %>
require "rake/testtask"
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList["test/**/*_test.rb"]
t.verbose = true
end
<% end %>
<% if using_cucumber? %>
require 'cucumber'
require 'cucumber/rake/task'
Cucumber::Rake::Task.new('features') do |t|
t.cucumber_opts = %w{--format pretty}
end
<% end %>
<% if default_tasks.empty? %>
task :default => :package do
puts "Don't forget to write some tests!"
end
<% else %>
task :default => <%= default_tasks.inspect %>
<% 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 = "<%= name %>"
s.version = "0.1.0"
s.summary = "What this thing does"
s.author = "<%= author_name %>"
s.email = "<%= author_email %>"
s.homepage = "<%= author_url %>"
s.has_rdoc = true
<% if readme %>
s.extra_rdoc_files = %w(<%= readme %>)
s.rdoc_options = %w(--main <%= readme %>)
# Add any extra files to include in the gem
<% else %>
# You should probably have a README of some kind. Change the filename
# as appropriate
# s.extra_rdoc_files = %w(README)
# s.rdoc_options = %w(--main README)
# Add any extra files to include in the gem (like your README)
<% end %>
s.files = %w(<%= files_in_root %>) + Dir.glob(<%= dirs_to_include_glob.inspect %>)
<% if has_executables? %>
s.executables = FileList["bin/**"].map { |f| File.basename(f) }
<% end %>
<% if has_lib_directory? %>
s.require_paths = ["lib"]
<% else %>
# You need to put your code in a directory which can then be added to
# the $LOAD_PATH by rubygems. Typically this is lib, but you don't seem
# to have that directory. You'll need to set the line below to whatever
# directory your code is in. Rubygems is going to assume lib if you leave
# this blank.
#
# s.require_paths = ["lib"]
<% end %>
# 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
<% if development_dependencies.any? %>
<% development_dependencies.each do |dependency| %>
s.add_development_dependency("<%= dependency %>")
<% end %>
<% else %>
# s.add_development_dependency("mocha") # for example
<% end %>
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.
#
# To publish your gem online, install the 'gemcutter' gem; Read more
# about that here: http://gemcutter.org/pages/gem_docs
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
# If you don't want to generate the .gemspec file, just remove this line. Reasons
# why you might want to generate a gemspec:
# - using bundler with a git source
# - building the gem without rake (i.e. gem build blah.gemspec)
# - maybe others?
task :package => :gemspec
# Generate documentation
RDoc::Task.new do |rd|
<% if readme %>rd.main = "<%= readme %>"<% end %>
rd.rdoc_files.include(<%= %{"#{readme}", } if readme %>"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