-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
53 lines (48 loc) · 1.48 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
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'markdown_helper'
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/*_test.rb']
end
namespace :build do
desc 'Build README.md file from README.template.md'
task :readme do
readme_dir_path = File.join(
File.dirname(__FILE__),
'readme_files',
)
source_dir_path = File.join(
readme_dir_path,
'scripts',
)
target_dir_path = File.join(
readme_dir_path,
'logs',
)
source_file_paths = Dir.glob("#{source_dir_path}/*.rb")
# Run the scripts in the logs directory,
# because (e.g.) in array.rb, the :file_path
# to the output log file is the simple 'array.xml',
# which keeps the file more readable.
chdir(target_dir_path) do
source_file_paths.each do |source_file_path|
command = "ruby #{source_file_path}"
system(command)
end
end
git_top_dir_path = `git rev-parse --show-toplevel`.chomp
log_file_paths = Dir.glob("#{target_dir_path}/*.xml")
log_file_paths.each do |log_file_path|
text = File.read(log_file_path)
# Obfuscate user file path.
text.gsub!(git_top_dir_path, "C:/#{File.basename(git_top_dir_path)}")
File.write(log_file_path, text)
end
markdown_helper = MarkdownHelper.new
# noinspection RubyResolve
markdown_helper.include('readme_files/README.template.md', 'README.md')
end
end
task :default => :test