-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
81 lines (63 loc) · 1.89 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require "rubygems"
require 'rake'
# template file used to generate test.html
# this file is generated by **rake test**
TPL = "_site/test-template/index.html"
# test file generated by :test task
TST = "tests.html"
# test building helper
module Py
class Test
def self.get_template
puts "Reads #{TPL} content"
File.read(TPL)
end
def self.build_jekyll
puts "Building Jekyll"
system "bundle exec jekyll build --config _config.yml,_config_dev.yml --trace"
end
end
end
task :default => :test
# Usage: rake test
desc "Generates test page"
task :test do
# delete target file (TST) if exist
if File.exist?(TST)
puts "#{TST} exists deleting it"
rm TST
end
# build jekyll site for first time
# this will generate our template file TPL
Py::Test.build_jekyll
# liquid comment for DO NOT EDIT
warning = []
warning << '{% comment %}**************************'
warning << 'DO NOT Edit this file !'
warning << 'It has been generated by rake task'
warning << 'Edit must be done in test-template.html or in Rakefile'
warning << '**************************{% endcomment %}'
warning.join("\n")
# Read TPL content
template = Py::Test.get_template
# create new target file (TST)
puts "Creating #{TST} file"
open(TST, 'w') do |post|
post.puts "---"
post.puts "layout: default"
post.puts "menu: main"
post.puts "title: Tags and Filters"
post.puts "weight: 30"
post.puts "---"
post.puts warning
post.puts template
end
# build jekyll again
Py::Test.build_jekyll
puts "task :test END ------------"
end # task :post
desc "Build Jekyll with development configuration"
task :dev do |t|
puts "Building with dev parameters"
sh 'jekyll build --config _config.yml,_config_dev.yml --trace'
end