-
Notifications
You must be signed in to change notification settings - Fork 59
/
Rakefile
91 lines (72 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
80
81
82
83
84
85
86
87
88
89
90
91
# -*- ruby -*-
require 'bundler/setup'
require 'rake/testtask'
require 'rake/clean'
require 'yard'
$:.unshift File.join(File.dirname(__FILE__), 'lib')
require 'rgl/version' # defines RGL::VERSION
SOURCES = FileList['lib/**/*.rb']
# The default task is run if rake is given no explicit arguments.
desc 'Default Task'
task :default => :test
# Define a test task.
Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = 'test/*_test.rb'
t.verbose = true
end
# Test bfs_search_tree_from in isolation, to ensure that adjacency is not loaded by other tests.
Rake::TestTask.new do |t|
t.libs << 'test'
t.pattern = 'test/traversal_bfs_require.rb'
t.verbose = true
end
# Git tagging
desc 'Commit all changes as a new version commit. Tag the commit with v<version> tag'
task :tag do
puts "Committing and tagging version #{RGL::VERSION}"
`git commit -am 'Version #{RGL::VERSION}'`
`git tag 'v#{RGL::VERSION}'`
end
YARD::Rake::YardocTask.new
# Tasks for building and installing RGL gem.
Bundler::GemHelper.install_tasks
# TAGS ---------------------------------------------------------------
file 'tags' => SOURCES do
print 'Running ctags...'
sh %(ctags #{SOURCES.join(' ')}) # vi tags
puts 'done.'
end
file 'TAGS' => SOURCES do
sh %(etags #{SOURCES.join(' ')}) # emacs TAGS
end
# Misc tasks =========================================================
def count_lines(filename)
lines = 0
codelines = 0
open(filename) { |f|
f.each do |line|
lines += 1
next if line =~ /^\s*$/
next if line =~ /^\s*#/
codelines += 1
end
}
[lines, codelines]
end
def show_line(msg, lines, loc)
printf "%6s %6s %s\n", lines.to_s, loc.to_s, msg
end
desc 'Count lines in the main files'
task :lines do
total_lines = 0
total_code = 0
show_line('File Name', 'LINES', 'LOC')
SOURCES.each do |fn|
lines, codelines = count_lines(fn)
show_line(fn, lines, codelines)
total_lines += lines
total_code += codelines
end
show_line('TOTAL', total_lines, total_code)
end