2010-03-26 02:37:03 +03:00
|
|
|
require 'rubygems'
|
|
|
|
require 'rake'
|
|
|
|
|
2010-10-14 19:27:33 +04:00
|
|
|
begin
|
|
|
|
require 'term/ansicolor'
|
|
|
|
include Term::ANSIColor
|
|
|
|
rescue LoadError
|
|
|
|
def cyan; '' end
|
|
|
|
def blue; '' end
|
|
|
|
def clear; '' end
|
|
|
|
end
|
2010-03-26 02:37:03 +03:00
|
|
|
|
2010-08-11 00:04:19 +04:00
|
|
|
OMNIAUTH_GEMS = %w(oa-basic oa-core oa-oauth oa-openid oa-enterprise omniauth)
|
2010-05-01 23:07:56 +04:00
|
|
|
|
|
|
|
def each_gem(action, &block)
|
|
|
|
OMNIAUTH_GEMS.each_with_index do |dir, i|
|
|
|
|
print blue, "\n\n== ", cyan, dir, blue, " ", action, clear, "\n\n"
|
|
|
|
Dir.chdir(dir, &block)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def version_file
|
|
|
|
File.dirname(__FILE__) + '/VERSION'
|
|
|
|
end
|
|
|
|
|
|
|
|
def version
|
|
|
|
File.open(version_file, 'r').read.strip
|
|
|
|
end
|
|
|
|
|
|
|
|
def bump_version(position)
|
|
|
|
v = version
|
|
|
|
v = v.split('.').map{|s| s.to_i}
|
|
|
|
v[position] += 1
|
|
|
|
write_version(*v)
|
|
|
|
end
|
|
|
|
|
|
|
|
def write_version(major, minor, patch)
|
|
|
|
major = nil if major == ''
|
|
|
|
minor = nil if minor == ''
|
|
|
|
patch = nil if patch == ''
|
|
|
|
|
|
|
|
v = version
|
|
|
|
v = v.split('.').map{|s| s.to_i}
|
|
|
|
|
|
|
|
v[0] = major || v[0]
|
|
|
|
v[1] = minor || v[1]
|
|
|
|
v[2] = patch || v[2]
|
|
|
|
|
|
|
|
File.open(version_file, 'w'){ |f| f.write v.map{|i| i.to_s}.join('.') }
|
|
|
|
puts "Version is now: #{version}"
|
|
|
|
end
|
2010-03-26 02:37:03 +03:00
|
|
|
|
2010-04-05 07:30:40 +04:00
|
|
|
desc 'Run specs for all of the gems.'
|
|
|
|
task :spec do
|
2010-05-01 23:07:56 +04:00
|
|
|
each_gem('specs are running...') do
|
|
|
|
system('rake spec')
|
2010-04-05 07:30:40 +04:00
|
|
|
end
|
2010-03-26 02:37:03 +03:00
|
|
|
end
|
2010-04-10 05:30:16 +04:00
|
|
|
|
2010-06-14 01:00:03 +04:00
|
|
|
namespace :dependencies do
|
|
|
|
desc 'Install all dependencies via Bundler'
|
|
|
|
task :install do
|
|
|
|
each_gem('is installing dependencies...') do
|
|
|
|
system('bundle install')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-10-14 19:27:33 +04:00
|
|
|
task :release => ['release:tag', 'gems:publish', 'doc:pages:publish']
|
|
|
|
|
|
|
|
namespace :release do
|
|
|
|
task :tag do
|
|
|
|
system("git tag v#{version}")
|
|
|
|
system('git push origin --tags')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-06-13 23:19:53 +04:00
|
|
|
namespace :gems do
|
2010-05-01 23:07:56 +04:00
|
|
|
|
2010-06-13 23:19:53 +04:00
|
|
|
desc 'Build all gems'
|
|
|
|
task :build do
|
|
|
|
each_gem('is building gems...') do
|
|
|
|
system('rake gem')
|
2010-06-14 00:36:59 +04:00
|
|
|
end
|
2010-06-13 23:19:53 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Push all gems to Gemcutter'
|
2010-10-14 19:27:33 +04:00
|
|
|
task :push do
|
2010-06-13 23:19:53 +04:00
|
|
|
each_gem('is releasing to Gemcutter...') do
|
2010-08-16 19:21:46 +04:00
|
|
|
system('rake gem:publish')
|
2010-06-14 00:36:59 +04:00
|
|
|
end
|
2010-06-13 23:19:53 +04:00
|
|
|
end
|
2010-05-01 22:14:46 +04:00
|
|
|
|
2010-06-13 23:19:53 +04:00
|
|
|
desc 'Install all gems'
|
|
|
|
task :install do
|
|
|
|
each_gem('is installing gems...') do
|
|
|
|
system('rake gem:install')
|
|
|
|
end
|
2010-06-13 21:20:52 +04:00
|
|
|
end
|
2010-06-13 23:19:53 +04:00
|
|
|
|
|
|
|
desc "Uninstall gems"
|
|
|
|
task :uninstall do
|
|
|
|
sh "sudo gem uninstall #{OMNIAUTH_GEMS.join(" ")} -a"
|
|
|
|
end
|
|
|
|
|
2010-06-13 21:20:52 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Clean pkg and other stuff"
|
|
|
|
task :clean do
|
|
|
|
OMNIAUTH_GEMS.each do |dir|
|
|
|
|
Dir.chdir(dir) do
|
2010-06-13 23:21:11 +04:00
|
|
|
%w(tmp pkg coverage dist).each { |d| FileUtils.rm_rf d }
|
2010-06-13 21:20:52 +04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
Dir["**/*.gem"].each { |gem| FileUtils.rm_rf gem }
|
|
|
|
end
|
|
|
|
|
2010-05-01 23:07:56 +04:00
|
|
|
desc 'Display the current version.'
|
|
|
|
task :version do
|
|
|
|
puts "Current Version: #{version}"
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :version do
|
|
|
|
desc "Write version with MAJOR, MINOR, and PATCH level env variables."
|
|
|
|
task :write do
|
|
|
|
write_version(ENV['MAJOR'], ENV['MINOR'], ENV['PATCH'])
|
|
|
|
end
|
|
|
|
|
|
|
|
namespace :bump do
|
|
|
|
task(:major){ bump_version(0) }
|
|
|
|
task(:minor){ bump_version(1) }
|
|
|
|
task(:patch){ bump_version(2) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-06-13 05:29:31 +04:00
|
|
|
task :default => :spec
|
2010-10-14 19:27:33 +04:00
|
|
|
|
|
|
|
begin
|
2010-10-15 01:21:08 +04:00
|
|
|
YARD_OPTS = ['-m', 'markdown', '-M', 'maruku']
|
2010-10-14 19:27:33 +04:00
|
|
|
require 'yard'
|
|
|
|
YARD::Rake::YardocTask.new(:doc) do |t|
|
|
|
|
t.files = OMNIAUTH_GEMS.inject([]){|a,g| a = a + ["#{g}/lib/**/*.rb"]; a} + ['README.markdown']
|
2010-10-15 01:21:08 +04:00
|
|
|
t.options = YARD_OPTS
|
2010-10-14 19:27:33 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
namespace :doc do
|
|
|
|
YARD::Rake::YardocTask.new(:pages) do |t|
|
|
|
|
t.files = OMNIAUTH_GEMS.inject([]){|a,g| a = a + ["#{g}/lib/**/*.rb"]; a} + ['README.markdown']
|
2010-10-15 01:21:08 +04:00
|
|
|
t.options = YARD_OPTS + ['-o', '../omniauth.doc']
|
2010-10-14 19:27:33 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
namespace :pages do
|
|
|
|
desc 'Generate and publish YARD docs to GitHub pages.'
|
|
|
|
task :publish => ['doc:pages'] do
|
|
|
|
Dir.chdir(File.dirname(__FILE__) + '/../omniauth.doc') do
|
|
|
|
system("git add .")
|
|
|
|
system("git add -u")
|
|
|
|
system("git commit -m 'Generating docs for version #{version}.'")
|
|
|
|
system("git push origin gh-pages")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue LoadError
|
|
|
|
puts "You need to install YARD."
|
|
|
|
end
|