2021-10-18 12:40:01 -04:00
|
|
|
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
2011-08-18 04:10:22 -04:00
|
|
|
require 'open-uri'
|
|
|
|
require 'yaml'
|
2011-09-30 21:35:14 -04:00
|
|
|
require 'sinatra/contrib/version'
|
2011-04-22 07:44:32 -04:00
|
|
|
|
2011-03-29 13:40:46 -04:00
|
|
|
desc "run specs"
|
2022-02-05 07:10:04 -05:00
|
|
|
task(:spec) { ruby '-S rspec' }
|
2011-03-29 13:40:46 -04:00
|
|
|
task(:test => :spec)
|
2011-08-18 04:13:18 -04:00
|
|
|
task(:default => :spec)
|
2011-03-29 13:40:46 -04:00
|
|
|
|
|
|
|
namespace :doc do
|
|
|
|
task :readmes do
|
|
|
|
Dir.glob 'lib/sinatra/*.rb' do |file|
|
2017-05-15 20:20:50 -04:00
|
|
|
puts "Trying file... #{file}"
|
|
|
|
excluded_files = %w[lib/sinatra/contrib.rb lib/sinatra/decompile.rb]
|
2011-07-02 15:38:24 -04:00
|
|
|
next if excluded_files.include?(file)
|
2011-07-02 15:48:15 -04:00
|
|
|
doc = File.read(file)[/^module Sinatra(\n)+( #[^\n]*\n)*/m].scan(/^ *#(?!#) ?(.*)\n/).join("\n")
|
2011-03-29 13:40:46 -04:00
|
|
|
file = "doc/#{file[4..-4].tr("/_", "-")}.rdoc"
|
2011-07-02 15:21:29 -04:00
|
|
|
Dir.mkdir "doc" unless File.directory? "doc"
|
2011-03-29 13:40:46 -04:00
|
|
|
puts "writing #{file}"
|
|
|
|
File.open(file, "w") { |f| f << doc }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-05-07 19:59:12 -04:00
|
|
|
task :index do
|
|
|
|
doc = File.read("README.md")
|
|
|
|
file = "doc/sinatra-contrib-readme.md"
|
|
|
|
Dir.mkdir "doc" unless File.directory? "doc"
|
|
|
|
puts "writing #{file}"
|
|
|
|
File.open(file, "w") { |f| f << doc }
|
|
|
|
end
|
|
|
|
|
|
|
|
task :all => [:readmes, :index]
|
2011-03-29 13:40:46 -04:00
|
|
|
end
|
|
|
|
|
2011-04-22 07:44:32 -04:00
|
|
|
desc "generate documentation"
|
2011-03-29 13:40:46 -04:00
|
|
|
task :doc => 'doc:all'
|
2011-04-22 07:44:32 -04:00
|
|
|
|
|
|
|
desc "generate gemspec"
|
|
|
|
task 'sinatra-contrib.gemspec' do
|
|
|
|
content = File.read 'sinatra-contrib.gemspec'
|
|
|
|
|
|
|
|
fields = {
|
|
|
|
:authors => `git shortlog -sn`.scan(/[^\d\s].*/),
|
|
|
|
:email => `git shortlog -sne`.scan(/[^<]+@[^>]+/),
|
2011-04-22 07:48:20 -04:00
|
|
|
:files => `git ls-files`.split("\n").reject { |f| f =~ /^(\.|Gemfile)/ }
|
2011-04-22 07:44:32 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
File.open('sinatra-contrib.gemspec', 'w') { |f| f << content }
|
|
|
|
end
|
|
|
|
|
2011-07-02 15:21:29 -04:00
|
|
|
task :gemspec => 'sinatra-contrib.gemspec'
|
2011-08-18 04:10:22 -04:00
|
|
|
|
2011-09-30 21:35:14 -04:00
|
|
|
task :release => :gemspec do
|
|
|
|
sh <<-SH
|
|
|
|
rm -Rf sinatra-contrib*.gem &&
|
|
|
|
gem build sinatra-contrib.gemspec &&
|
|
|
|
gem install sinatra-contrib*.gem --local &&
|
|
|
|
gem push sinatra-contrib*.gem &&
|
|
|
|
git commit --allow-empty -a -m '#{Sinatra::Contrib::VERSION} release' &&
|
|
|
|
git tag -s v#{Sinatra::Contrib::VERSION} -m '#{Sinatra::Contrib::VERSION} release' &&
|
2015-06-30 23:07:51 -04:00
|
|
|
git push && (git push origin master || true) &&
|
|
|
|
git push --tags && (git push origin --tags || true)
|
2011-09-30 21:35:14 -04:00
|
|
|
SH
|
|
|
|
end
|
|
|
|
|