-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
56 lines (41 loc) · 1009 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
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true
# Build Prince Cooks 4 U site
# Usage: rake build
require 'erb'
require 'json'
# Helper logic for the actual Rake tasks
module Site
module_function
def popups
File.read('popups.json')
.then { |json| JSON.parse(json, symbolize_names: true) }
.map { |popup| Popup.new(**popup) }
end
def template
ERB.new(File.read('index.html.erb'), trim_mode: '-')
end
def output
'index.html'
end
# noinspection RubyUnusedLocalVariable
def erb(popups)
output = Site.template.result(binding)
File.write(Site.output, output)
output
end
Popup = Data.define(:name, :slug, :slogan, :offerings, :extra)
end
desc 'Build site file'
file 'index.html' => %w[index.html.erb popups.json] do
popups = Site.popups
Site.erb(popups)
end
desc 'Build the whole site'
task build: ['index.html']
desc 'Build and push a new version of the site'
task release: :build do
# TODO
end
task dev: ['index.html'] do
sh 'open index.html'
end