-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
116 lines (103 loc) · 3.46 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
require 'rake/rdoctask'
require 'cucumber'
require 'cucumber/rake/task'
require 'rake'
require 'spec/rake/spectask'
$stderr.reopen("stderr.out", "w")
Rake::RDocTask.new do |rd|
rd.main = "README"
rd.rdoc_files.include("README", "lib/**/*.rb")
end
task :default => :features
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "-fprogress features " unless File.exist?("cucumber.yml")
end
desc "Run specs in long report format"
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_opts = ['--format' , 'specdoc', '-c']
t.spec_files = FileList['spec/**/*_spec.rb']
end
desc "Run Examples"
Spec::Rake::SpecTask.new('examples') do |t|
t.spec_opts = ['--format' , 'p' ]
t.spec_files = FileList['spec/**/*_spec.rb']
end
desc "Run all examples with RCov"
Spec::Rake::SpecTask.new('examples_with_rcov') do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.rcov = true
t.rcov_opts = ['--exclude', 'spec',
'--exclude', '.rvm/',
'--exclude', 'lib/R1.8',
'--exclude', 'lib/ruby_utilities.rb',
'--exclude', 'plugins/Trash',
'--exclude', 'plugins/trash',
'--exclude', 'plugins/TestPlug']
end
desc "Run Specs, Stories, and Unit Tests"
task :test => [:features, :examples, :testunit]
desc 'Run unit tests only'
task :testunit do
require 'rake/runtest'
Rake.run_tests
end
task :preflight_check_dev => :preflight_check do
if not ThreeSegmentNumericVersion.new(RUBY_VERSION) == \
ThreeSegmentNumericVersion.new("1.9.1") then
puts "F.Y.I: This program was developed using Ruby 1.9.1, " \
"not #{RUBY_VERSION}."
end
# cucumber was already required, so rake will fail if cucumber is not installed
puts "Checking for required development gems"
[:cucumber, :rake, :rspec, :rcov].each do |gemi|
unless (system("gem list | grep #{gemi}")) then
puts "*** Missing gem #{gemi}"
end
end
end
task :preflight_check do
require 'lib/ruby_utilities.rb'
# make sure we are running at least 1.9.1
if not ThreeSegmentNumericVersion.new(RUBY_VERSION).between? \
ThreeSegmentNumericVersion.new("1.9.0"),
ThreeSegmentNumericVersion.new("1.9.9") then
puts "This program was developed for Ruby 1.9, so it might not work."
end
puts "Checking for required runtime gems"
[:isaac].each do |gemi|
unless (system("gem list | grep #{gemi}")) then
puts "*** Missing gem #{gemi}"
end
end
end
desc "Generate TODO file"
task :TODO do
# remove old TODO file
todo_file = Dir['TODO']
main_file_heading = "TODO Generated on #{Time.now} by #{ENV["USER"]}"
# Search all .rb files
search_files = Dir['**/*.rb']
File.open('TODO', 'w') do |todo_file|
search_files.each do |search_file|
File.open(search_file, 'r') do |fh|
search_file_heading = "\nTODO in #{search_file}"
fh.each_with_index do |line_txt, line_num|
if (line_txt =~ /#.*TODO:?(.*)/i) then
# Output main_file_heading only once, if there's a match
if main_file_heading then
todo_file.puts main_file_heading
main_file_heading = nil
end
# Output search_file heading once, only if there's a match
if search_file_heading then
todo_file.puts search_file_heading
search_file_heading = nil
end
# Output matching line:
todo_file.puts "#{line_num.to_s.rjust(3, "0")}: #{$1.strip!}"
end
end
end
end
end
end