-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
144 lines (118 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
# Copyright (c) 2009, 2010 Yves Adler <yves.adler@googlemail.com>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
require 'rake/gempackagetask'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rcov/rcovtask'
desc "print message"
task :default do
puts "You have run rake without a task - please choose one of the following:\n\n"
puts `rake --tasks`
end
package_specification = Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 1.9'
spec.platform = Gem::Platform::RUBY
spec.name = 'evosynth'
spec.version = '0.2.0'
spec.rubyforge_project = 'evosynth'
spec.homepage = 'http://evosynth.rubyforge.org'
spec.summary = 'EvoSynth (Evolutionary Computation Synthesizer) is a framework for rapid development and prototyping of evolutionary algorithms.'
spec.description = spec.summary
spec.author = 'Yves Adler'
spec.email = 'yves.adler@googlemail.com'
spec.has_rdoc = true
spec.rdoc_options = ["--charset", "UTF-8", "--title", "EvoSynth Documentation", "--main", "README", "--line-numbers"]
spec.extra_rdoc_files = ["README", "LICENSE", "INSTALL", "docs/FEATURES"]
# files and dependencies:
files = FileList['**/*']; files.exclude('.git*'); files.exclude('pkg/*')
spec.files = files.to_a
spec.test_files = FileList['test/ts_*.rb']
spec.require_paths << 'lib'
# should these "requirements" become dependencies?
spec.requirements << 'gnuplot for visualization'
spec.requirements << 'flay, flog, roodi and rcov gems for code quality analysis'
spec.add_development_dependency('shoulda', '>=2.10.3')
spec.add_development_dependency('rake', '>=0.8.7')
end
Rake::GemPackageTask.new(package_specification) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
Rake::RDocTask.new do |rdoc|
rdoc.main = "README"
rdoc.rdoc_dir = "docs/rdoc"
rdoc.title = "EvoSynth Documentation"
rdoc.options = ["--charset", "UTF-8", "--line-numbers"]
rdoc.rdoc_files.include("README", "LICENSE", "INSTALL", "docs/FEATURES", "lib/**/*.rb", "examples/**/*.rb")
end
# Test tasks and code quality stuff:
task :quality => [:test, :flog, :flay, :roodi]
lib_dir = File.expand_path("lib")
examples_dir = File.expand_path("examples")
test_dir = File.expand_path("test")
Rake::TestTask.new do |test|
test.libs = [lib_dir, test_dir]
test.test_files = FileList["test/ts_*.rb"]
test.verbose = true
end
desc "Analyze the code with roodi (Ruby Object Oriented Design Inferometer)"
task :roodi do
roodi_output = `roodi 'lib/**/*.rb' 'examples/**/*.rb'`
puts "ERROR: roodi not found. please install 'gems install roodi'" if $?.exitstatus == 127
puts roodi_output
end
desc "Analyze for code duplication"
task :flay do
flay_output = `flay '#{lib_dir}' '#{examples_dir}'`
puts "ERROR: flay not found. please install 'gems install flay'" if $?.exitstatus != 0
puts flay_output
end
desc "Analyze for code complexity"
task :flog do
flog_output = `find lib -name \*.rb | xargs flog -g`
puts "ERROR: flog not found. please install 'gems install flog'" if $?.exitstatus != 0
puts flog_output
end
# Shortcuts for examples and benchmark
desc "Run all examples"
task :run_examples do
example_files = FileList["examples/**/*.rb"]
$:.unshift File.expand_path("../lib", __FILE__)
example_files.each do |example_file|
puts "\nRunning example : #{example_file}\n\n"
load example_file
end
end
desc "Run all benchmarks"
task :run_benchmarks do
$:.unshift File.expand_path("../lib", __FILE__)
load 'benchmarks/decoder_benchmark.rb'
load 'benchmarks/mutation_benchmark.rb'
load 'benchmarks/recombination_benchmark.rb'
load 'benchmarks/selection_benchmark.rb'
end
Rcov::RcovTask.new do |t|
# t.libs << "test"
t.test_files = FileList['test/ts_*.rb']
t.verbose = true
end