forked from ruby-conferences/ruby-conferences.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
40 lines (33 loc) · 1.08 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
#!/usr/bin/env rake
require 'yaml'
require './data_file_validator'
desc "Build Jekyll site"
task :build do
exit 1 unless system "bundle exec jekyll build"
end
desc "Verify generated HTML"
task :verify_html do
exit 2 unless system "bundle exec htmlproofer ./_site"
end
desc "Verify event data"
task :verify_data do
data_files = [
{
filename: :past,
allowed_keys: ["name", "location", "dates", "url", "twitter", "video_link"]
}, {
filename: :current,
allowed_keys: ["name", "location", "dates", "url", "twitter", "reg_phrase", "reg_date", "cfp_phrase", "cfp_date"]
}
]
validators = data_files.map do |data_file|
data = YAML.load File.read "_data/#{data_file[:filename]}.yml"
DataFileValidator.validate(data, data_file[:allowed_keys])
end
exit 3 if validators.any? &:missing_keys?
exit 4 if validators.any? &:bonus_keys?
events = validators.map(&:events).flatten
dates = events.map { |event| Date.parse event["dates"].gsub(/[-&][^,]+/, '') }
exit 5 unless dates.sort == dates
end
task default: [:build, :verify_data, :verify_html]