-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
79 lines (66 loc) · 1.99 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
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'yaml'
# tasks
desc 'Default: Run tests.'
task :default => :test
desc 'Run tests.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = File.join('test', ENV['subset'] || '', ENV['pattern'] || '**/*_test.rb')
t.verbose = true
t.warning = true
end
#
# admin tasks
#
def gemspec
data = File.read("molecules.gemspec")
spec = nil
Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
spec
end
Rake::GemPackageTask.new(gemspec) do |pkg|
pkg.need_tar = true
end
task :print_manifest do
# collect files from the gemspec, labeling
# with true or false corresponding to the
# file existing or not
files = gemspec.files.inject({}) do |files, file|
files[File.expand_path(file)] = [File.exists?(file), file]
files
end
# gather non-rdoc/pkg files for the project
# and add to the files list if they are not
# included already (marking by the absence
# of a label)
Dir.glob("**/*").each do |file|
next if file =~ /^(rdoc|pkg)/ || File.directory?(file)
path = File.expand_path(file)
files[path] = ["", file] unless files.has_key?(path)
end
# sort and output the results
files.values.sort_by {|exists, file| file }.each do |entry|
puts "%-5s : %s" % entry
end
end
desc 'Generate documentation.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "molecules"
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include(["README", 'MIT-LICENSE'])
rdoc.rdoc_files.include(gemspec.files.select {|file| file =~ /^lib/})
end
desc "Publish RDoc to RubyForge"
task :publish_rdoc => [:rdoc] do
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
host = "#{config["username"]}@rubyforge.org"
rsync_args = "-v -c -r"
remote_dir = "/var/www/gforge-projects/bioactive/molecules"
local_dir = "rdoc"
sh %{rsync #{rsync_args} #{local_dir}/ #{host}:#{remote_dir}}
end