forked from JetBrains/kotlin-web-site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
47 lines (35 loc) · 905 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'rubygems'
require 'bundler/setup'
require 'yaml'
CONFIG = {
:source_dir => __dir__,
:tmp_dir => "#{__dir__}/__tmp",
:build_destination => "_site",
:preview_host => "localhost",
:preview_port => 4000,
:pdf_filename => "kotlin-docs.pdf"
}
Dir['_rake/*.rake'].each { |r| load r }
Dir['_rake/lib/*.rb'].each { |r| load r }
task :default do
system('rake -T')
end
def ask(message, valid_options)
if valid_options
answer = get_stdin("#{message} #{valid_options.to_s.gsub(/"/, '').gsub(/, /,'/')} ") while !valid_options.include?(answer)
else
answer = get_stdin(message)
end
answer
end
def get_stdin(message)
print message
STDIN.gets.chomp
end
def render_erb(template, data = {})
vars = ErbBinding.new(data)
template_contents = File.read(template)
erb = ERB.new(template_contents)
vars_binding = vars.send(:get_binding)
erb.result(vars_binding)
end