This repository has been archived by the owner on Aug 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
/
Rakefile
94 lines (80 loc) · 2.43 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
require "rake/testtask"
spec = Gem::Specification.load(Dir["*.gemspec"].first)
GEMFILE_MAP = {"gemfiles/Rails2" => "Rails 2.3", "gemfiles/Rails3" => "Rails 3.x", "gemfiles/Sinatra1.1" => "Sinatra 1.1", "gemfiles/Sinatra1.2" => "Sinatra 1.2", "gemfiles/Sinatra1.3" => "Sinatra 1.3"}
desc "Install dependencies"
task :setup do
GEMFILE_MAP.each do |gemfile, name|
puts "Installing gems for testing with #{name} ..."
sh "env BUNDLE_GEMFILE=#{File.dirname(__FILE__) + '/' + gemfile} bundle install"
end
end
desc "Run all tests"
Rake::TestTask.new do |task|
task.test_files = FileList['test/**/*_test.rb']
if Rake.application.options.trace
#task.warning = true
task.verbose = true
elsif Rake.application.options.silent
task.ruby_opts << "-W0"
else
task.verbose = true
end
task.ruby_opts << "-I."
end
namespace :test do
GEMFILE_MAP.each do |gemfile, name|
desc "Run all tests against #{name}"
task gemfile.downcase.gsub(/\./, "_") do
sh "env BUNDLE_GEMFILE=#{gemfile} bundle exec rake"
end
end
task :all=>GEMFILE_MAP.map {|gemfile, name| "test:#{gemfile.downcase.gsub(/\./, "_")}"}
end
desc "Run this in development mode when updating the CoffeeScript file"
task :coffee do
sh "coffee -w -o lib/rack/oauth2/admin/js/ lib/rack/oauth2/admin/js/application.coffee"
end
task :compile do
sh "coffee -c -l -o lib/rack/oauth2/admin/js/ lib/rack/oauth2/admin/js/application.coffee"
end
desc "Build the Gem"
task :build=>:compile do
sh "gem build #{spec.name}.gemspec"
end
desc "Install #{spec.name} locally"
task :install=>:build do
sudo = "sudo" unless File.writable?( Gem::ConfigMap[:bindir])
sh "#{sudo} gem install #{spec.name}-#{spec.version}.gem"
end
desc "Push new release to gemcutter and git tag"
task :push=>["test:all", "build"] do
puts "Tagging version #{spec.version} .."
sh "git push"
sh "git tag -a v#{spec.version} -m \"Tagging v#{spec.version}\""
sh "git push --tags"
puts "Publishing gem.."
sh "gem push #{spec.name}-#{spec.version}.gem"
end
task :default do
ENV["FRAMEWORK"] = "rails"
begin
require "rails" # check for Rails3
rescue LoadError
begin
require "initializer" # check for Rails2
rescue LoadError
ENV["FRAMEWORK"] = "sinatra"
end
end
task("test").invoke
end
begin
require "yard"
YARD::Rake::YardocTask.new do |doc|
doc.files = FileList["lib/**/*.rb"]
end
rescue LoadError
end
task :clean do
rm_rf %w{doc .yardoc *.gem}
end