-
Notifications
You must be signed in to change notification settings - Fork 34
/
Rakefile
52 lines (40 loc) · 1.2 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
#!/usr/bin/env rake
require 'rake'
require 'rake/testtask'
require 'rdoc/task'
require 'rubygems/package_task'
require File.join(File.dirname(__FILE__), 'lib/kml', 'version')
spec = Gem::Specification.load('ruby_kml.gemspec')
Gem::PackageTask.new(spec) {}
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the library.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'KMLr'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('lib/**/*.rb')
end
desc "Generate code statistics"
task :lines do
lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
for file_name in FileList["lib/**/*.rb"]
next if file_name =~ /vendor/
f = File.open(file_name)
while line = f.gets
lines += 1
next if line =~ /^\s*$/
next if line =~ /^\s*#/
codelines += 1
end
puts "L: #{sprintf("%4d", lines)}, LOC #{sprintf("%4d", codelines)} | #{file_name}"
total_lines += lines
total_codelines += codelines
lines, codelines = 0, 0
end
puts "Total: Lines #{total_lines}, LOC #{total_codelines}"
end
task :default => :test