-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
103 lines (83 loc) · 2.38 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
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
#
# Gem specification
#
def gemspec
data = File.read('external.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
desc 'Prints the gemspec manifest.'
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|rubyspec|test)/ || 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
#
# Documentation tasks
#
desc 'Generate documentation.'
Rake::RDocTask.new(:rdoc) do |rdoc|
spec = gemspec
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'external'
rdoc.main = 'README'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include( spec.extra_rdoc_files )
rdoc.rdoc_files.include( spec.files.select {|file| file =~ /^lib.*\.rb$/} )
end
task :copy_docs do
FileUtils.cp_r('docs', 'rdoc/docs')
end
desc "Publish RDoc to RubyForge"
task :publish_rdoc => [:rdoc, :copy_docs] do
require 'yaml'
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/external"
local_dir = "rdoc"
sh %{rsync #{rsync_args} #{local_dir}/ #{host}:#{remote_dir}}
end
#
# Test tasks
#
desc 'Default: Run tests.'
task :default => :test
desc 'Run tests.'
Rake::TestTask.new(:test) do |t|
t.test_files = Dir.glob( File.join('test', ENV['pattern'] || '**/*_test.rb') )
t.verbose = true
t.warning = true
end
desc 'Run specs (should be run w/wo ARRAY=true).'
task :spec do
ARGV.clear
ARGV.concat Dir.glob("#{File.dirname(__FILE__)}/test/rubyspec/**/#{ENV['pattern'] || '*'}_spec.rb")
gem 'mspec'
load 'mspec'
end