forked from bioruby/bioruby
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
143 lines (116 loc) · 3.81 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
#
# = Rakefile - helper of developement and packaging
#
# Copyright:: Copyright (C) 2009 Naohisa Goto <ng@bioruby.org>
# License:: The Ruby License
#
require 'rubygems'
require 'erb'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
load "./lib/bio/version.rb"
BIO_VERSION_RB_LOADED = true
# Version string for tar.gz, tar.bz2, or zip archive.
# If nil, use the value in lib/bio.rb
# Note that gem version is always determined from bioruby.gemspec.erb.
version = ENV['BIORUBY_VERSION'] || Bio::BIORUBY_VERSION.join(".")
version = nil if version.to_s.empty?
extraversion = ENV['BIORUBY_EXTRA_VERSION'] || Bio::BIORUBY_EXTRA_VERSION
extraversion = nil if extraversion.to_s.empty?
BIORUBY_VERSION = version
BIORUBY_EXTRA_VERSION = extraversion
task :default => "test"
Rake::TestTask.new do |t|
t.test_files = FileList["test/{unit,functional}/**/test_*.rb"]
end
# files not included in gem but included in tar archive
tar_additional_files = []
GEM_SPEC_FILE = "bioruby.gemspec"
GEM_SPEC_TEMPLATE_FILE = "bioruby.gemspec.erb"
# gets gem spec string
gem_spec_string = ERB.new(File.read(GEM_SPEC_TEMPLATE_FILE)).result
# gets gem spec object
spec = eval(gem_spec_string)
# adds notice of automatically generated file
gem_spec_string = "# This file is automatically generated from #{GEM_SPEC_TEMPLATE_FILE} and\n# should NOT be edited by hand.\n# \n" + gem_spec_string
# compares current gemspec file and newly generated gemspec string
current_string = File.read(GEM_SPEC_FILE) rescue nil
if current_string and current_string != gem_spec_string then
#Rake::Task[GEM_SPEC_FILE].invoke
flag_update_gemspec = true
else
flag_update_gemspec = false
end
desc "Update gem spec file"
task :gemspec => GEM_SPEC_FILE
desc "Force update gem spec file"
task :regemspec do
#rm GEM_SPEC_FILE, :force => true
Rake::Task[GEM_SPEC_FILE].execute(nil)
end
desc "Update #{GEM_SPEC_FILE}"
file GEM_SPEC_FILE => [ GEM_SPEC_TEMPLATE_FILE, 'Rakefile',
'lib/bio/version.rb' ] do |t|
puts "creates #{GEM_SPEC_FILE}"
File.open(t.name, 'w') do |w|
w.print gem_spec_string
end
end
task :package => [ GEM_SPEC_FILE ] do
Rake::Task[:regemspec].invoke if flag_update_gemspec
end
Rake::PackageTask.new("bioruby") do |pkg|
#pkg.package_dir = "./pkg"
pkg.need_tar_gz = true
pkg.package_files.import(spec.files)
pkg.package_files.include(*tar_additional_files)
pkg.version = (BIORUBY_VERSION || spec.version) + BIORUBY_EXTRA_VERSION.to_s
end
Rake::GemPackageTask.new(spec) do |pkg|
#pkg.package_dir = "./pkg"
end
Rake::RDocTask.new do |r|
r.rdoc_dir = "rdoc"
r.rdoc_files.include(*spec.extra_rdoc_files)
r.rdoc_files.import(spec.files.find_all {|x| /\Alib\/.+\.rb\z/ =~ x})
#r.rdoc_files.exclude /\.yaml\z"
opts = spec.rdoc_options.to_a.dup
if i = opts.index('--main') then
main = opts[i + 1]
opts.delete_at(i)
opts.delete_at(i)
else
main = 'README.rdoc'
end
r.main = main
r.options = opts
end
# Tutorial files
TUTORIAL_RD = 'doc/Tutorial.rd'
TUTORIAL_RD_JA = 'doc/Tutorial.rd.ja'
TUTORIAL_RD_HTML = TUTORIAL_RD + '.html'
TUTORIAL_RD_JA_HTML = TUTORIAL_RD_JA + '.html'
HTMLFILES_TUTORIAL = [ TUTORIAL_RD_HTML, TUTORIAL_RD_JA_HTML ]
# Formatting RD to html.
def rd2html(src, dst)
sh "rd2 -r rd/rd2html-lib.rb --with-css=bioruby.css #{src} > #{dst}"
end
# Tutorial.rd to Tutorial.rd.html
file TUTORIAL_RD_HTML => TUTORIAL_RD do |t|
rd2html(t.prerequisites[0], t.name)
end
# Tutorial.rd.ja to Tutorial.html.ja
file TUTORIAL_RD_JA_HTML => TUTORIAL_RD_JA do |t|
rd2html(t.prerequisites[0], t.name)
end
desc "Update doc/Tutorial*.html"
task :tutorial2html => HTMLFILES_TUTORIAL
desc "Force update doc/Tutorial*.html"
task :retutorial2html do
# safe_unlink HTMLFILES_TUTORIAL
HTMLFILES_TUTORIAL.each do |x|
Rake::Task[x].execute(nil)
end
end