forked from jkraemer/pdf-forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
46 lines (34 loc) · 1.19 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
require "bundler"
Bundler.setup
require 'rake/testtask'
desc 'Test the library.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib' << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
task :default => :test
gemspec = eval(File.read("pdf-forms.gemspec"))
task :build => "#{gemspec.full_name}.gem"
file "#{gemspec.full_name}.gem" => gemspec.files + ["pdf-forms.gemspec"] do
system "gem build pdf-forms.gemspec"
system "gem install pdf-forms-#{PdfForms::VERSION}.gem"
end
desc "Manage the encoding header of Ruby files"
task :utf8_encode_headers do
files = Array.new
["*.rb", "*.rake"].each do |extension|
files.concat(Dir[ File.join(Dir.getwd.split(/\\/), "**", extension) ])
end
files.each do |file|
content = File.read(file)
next if content[0..16] == "# coding: UTF-8\n\n" ||
content[0..22] == "# -*- coding: utf-8 -*-"
["\n\n", "\n"].each do |file_end|
content = content.gsub(/(# encoding: UTF-8#{file_end})|(# coding: UTF-8#{file_end})|(# -*- coding: UTF-8 -*-#{file_end})|(# -*- coding: utf-8 -*-#{file_end})/i, "")
end
new_file = File.open(file, "w")
new_file.write("# coding: UTF-8\n\n"+content)
new_file.close
end
end