sinatra/sinatra-contrib/Rakefile

61 lines
1.9 KiB
Ruby
Raw Normal View History

$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
2011-08-18 08:10:22 +00:00
require 'open-uri'
require 'yaml'
2011-03-29 17:40:46 +00:00
desc "run specs"
task(:spec) { ruby '-S rspec spec' }
task(:test => :spec)
namespace :doc do
task :readmes do
Dir.glob 'lib/sinatra/*.rb' do |file|
2011-07-02 19:38:24 +00:00
excluded_files = %w[lib/sinatra/contrib.rb lib/sinatra/capture.rb lib/sinatra/engine_tracking.rb]
next if excluded_files.include?(file)
doc = File.read(file)[/^module Sinatra(\n)+( #[^\n]*\n)*/m].scan(/^ *#(?!#) ?(.*)\n/).join("\n")
2011-03-29 17:40:46 +00:00
file = "doc/#{file[4..-4].tr("/_", "-")}.rdoc"
Dir.mkdir "doc" unless File.directory? "doc"
2011-03-29 17:40:46 +00:00
puts "writing #{file}"
File.open(file, "w") { |f| f << doc }
end
end
task :all => [:readmes]
end
desc "generate documentation"
2011-03-29 17:40:46 +00:00
task :doc => 'doc:all'
desc "generate gemspec"
task 'sinatra-contrib.gemspec' do
require 'sinatra/contrib/version'
content = File.read 'sinatra-contrib.gemspec'
fields = {
:authors => `git shortlog -sn`.scan(/[^\d\s].*/),
:email => `git shortlog -sne`.scan(/[^<]+@[^>]+/),
:files => `git ls-files`.split("\n").reject { |f| f =~ /^(\.|Gemfile)/ }
}
fields.each do |field, values|
updated = " s.#{field} = ["
updated << values.map { |v| "\n %p" % v }.join(',')
updated << "\n ]"
content.sub!(/ s\.#{field} = \[\n( .*\n)* \]/, updated)
end
content.sub! /(s\.version.*=\s+).*/, "\\1\"#{Sinatra::Contrib::VERSION}\""
File.open('sinatra-contrib.gemspec', 'w') { |f| f << content }
end
task :gemspec => 'sinatra-contrib.gemspec'
2011-08-18 08:10:22 +00:00
desc 'update travis config to correspond to sinatra'
task :travis, [:branch] do |t, a|
a.with_defaults :branch => :master
data = YAML.load open("https://raw.github.com/sinatra/sinatra/#{a.branch}/.travis.yml")
data["notifications"]["recipients"] << "ohhgabriel@gmail.com"
File.open('.travis.yml', 'w') { |f| f << data.to_yaml }
system 'git add .travis.yml && git diff --cached .travis.yml'
end