-
Notifications
You must be signed in to change notification settings - Fork 4
/
Rakefile
31 lines (28 loc) · 805 Bytes
/
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
require "bundler/gem_tasks"
require "rake/testtask"
desc "Default: run tests."
task :default => :test
desc "Run unit tests"
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/**/test*.rb']
t.verbose = false
end
ENCODING_HEADER = "# encoding: UTF-8"
desc "Add UTF-8 encoding to source files"
task :encoding do
FileList['test/**/*.rb', 'lib/**/*.rb'].each do |filename|
open(filename, 'r+') do |f|
beginning_of_file = f.pos
first_line = f.readline
f.seek(beginning_of_file)
original_content = f.read
f.seek(beginning_of_file)
unless first_line.strip == ENCODING_HEADER.strip
puts "Adding '#{ENCODING_HEADER}' to #{filename}"
f.write("#{ENCODING_HEADER}\n")
f.write(original_content)
end
end
end
end