-
Notifications
You must be signed in to change notification settings - Fork 14
/
Rakefile
163 lines (133 loc) · 4.64 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rubygems/package_task'
require 'rake/clean'
require './lib/cerberus/constants'
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
PKG_NAME = 'cerberus'
PKG_VERSION = Cerberus::VERSION + PKG_BUILD
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
RELEASE_NAME = "REL #{PKG_VERSION}"
RUBYFORGE_PROJECT = "cerberus"
RUBYFORGE_USER = ENV['RUBYFORGE_USER'] || "cpjolicoeur"
task :default => [:test, :clean]
desc "Run the tests in the test/ directory"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.pattern = 'test/*_test.rb'
t.verbose = true
end
CLEAN.include %w(**/*~)
desc "Clean all generated files"
task :clean => :clobber_package do
root = File.dirname(__FILE__)
rm_rf "#{root}/test/__workdir"
rm_rf "#{root}/coverage"
rm_rf "#{root}/doc/site/out"
rm_rf "#{root}/doc/site/webgen.cache"
end
GEM_SPEC = Gem::Specification.new do |s|
s.name = PKG_NAME
s.version = PKG_VERSION
s.platform = Gem::Platform::RUBY
s.required_ruby_version = ">=1.8.2"
s.summary = "Cerberus is a Continuous Integration tool that could be easily run from Cron."
s.description = <<-DESC.strip.gsub(/\n\s+/, " ")
Cerberus is a Continuous Integration software for Ruby projects. CI helps you keep your project
in a good shape.
Cerberus could be easily invoked from Cron (for Unix) or nnCron (for Windows) utilities.
DESC
s.add_dependency 'actionmailer'
s.add_dependency 'activesupport'
s.add_dependency 'rake'
s.files = Dir.glob("{bin,lib,test}/**/*").delete_if { |item| item.include?('__workdir') }
s.files += %w(License.txt Readme.markdown Changelog.txt Authors.txt Copyright.txt Rakefile)
s.bindir = "bin"
s.executables = ["cerberus"]
s.default_executable = "cerberus"
s.require_path = 'lib'
s.has_rdoc = false
s.test_files = Dir.glob('test/*_test.rb')
s.author = "Craig P Jolicoeur"
s.email = "[email protected]"
s.homepage = "http://rubyforge.org/projects/cerberus"
s.rubyforge_project = RUBYFORGE_PROJECT
end
Gem::PackageTask.new(GEM_SPEC) do |p|
p.gem_spec = GEM_SPEC
p.need_tar = true
p.need_zip = true
end
desc "install gem from pkg/ directory after running clean and test"
task :install => [:clean, :test, :package] do
system "gem install pkg/#{PKG_NAME}-#{PKG_VERSION}.gem"
end
desc "uninstall gem"
task :uninstall => [:clean] do
system "gem uninstall #{PKG_NAME}"
end
desc "Look for TODO and FIXME tags in the code"
task :todo do
FileList.new(File.dirname(__FILE__) + '/lib/cerberus/**/*.rb').egrep(/#.*(FIXME|TODO|TBD|DEPRECATED)/i)
end
desc "uninstall and reinstall gem"
task :reinstall => [:uninstall, :install]
begin
require 'rcov/rcovtask'
Rcov::RcovTask.new do |t|
t.test_files = FileList['test/*_test.rb']
t.output_dir = File.join(File.dirname(__FILE__), 'coverage')
t.verbose = true
end
rescue Object
end
desc "copy coverage directory to RubyForge site"
task :site_coverage => [:rcov] do
sh %{ scp -r coverage/* #{RUBYFORGE_USER}@rubyforge.org:/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/coverage/ }
end
desc "Release files to RubyForge"
task :release_files => [:clean, :package] do
require 'meta_project'
project = MetaProject::Project::XForge::RubyForge.new(RUBYFORGE_PROJECT)
release_files = FileList[
"pkg/#{PKG_FILE_NAME}.gem",
"pkg/#{PKG_FILE_NAME}.zip",
"pkg/#{PKG_FILE_NAME}.tgz"
]
Rake::XForge::Release.new(project) do |release|
release.user_name = RUBYFORGE_USER
release.password = ENV['RUBYFORGE_PASSWORD']
release.files = release_files.to_a
release.package_name = PKG_NAME
release.release_name = "Cerberus #{PKG_VERSION}"
end
end
desc "Publish news update to RubyForge"
task :publish_news do
require 'meta_project'
project = MetaProject::Project::XForge::RubyForge.new(RUBYFORGE_PROJECT)
Rake::XForge::NewsPublisher.new(project) do |publisher|
publisher.user_name = RUBYFORGE_USER
publisher.password = ENV['RUBYFORGE_PASSWORD']
publisher.subject = "[ANN] Cerberus #{PKG_VERSION} Released"
publisher.details = IO.read(File.dirname(__FILE__) + '/Changelog.txt')
end
end
begin
gem 'webgen'
require 'webgen/rake_task'
Webgen::RakeTask.new do |t|
t.directory = File.join(File.dirname(__FILE__), 'doc/site')
t.clobber_outdir = true
end
rescue Gem::LoadError
puts "webgen gem is required to build website output"
end
desc "Update cerberus.rubyforge.org website"
task :publish_site => :webgen do
sh %{scp -r -q doc/site/out/* #{RUBYFORGE_USER}@rubyforge.org:/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/}
end
desc "Run release_files, publish_news, publish_site"
task :release => [:release_files, :publish_news, :publish_site]