generated from Quang7hong81/acceptbitcoincash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
85 lines (72 loc) · 1.81 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
82
83
84
85
# frozen_string_literal: true
Rake.add_rakelib 'scripts/tasks'
require 'rubocop/rake_task'
require 'jekyll'
require 'safe_yaml/load'
require 'jsonlint/rake_task'
task default: %w[verify rubocop proof jsonlint]
task external: %w[verify rubocop proof_external]
task :build do
config = Jekyll.configuration(
'source' => './',
'destination' => './_site'
)
site = Jekyll::Site.new(config)
Jekyll::Commands::Build.build site, config
end
task proof: 'build' do
check_site(
check_html: true,
disable_external: true,
hydra: { max_concurrency: 50 }
)
end
task proof_external: 'build' do
check_site(
external_only: true,
http_status_ignore: [0, 301, 302, 403, 503],
hydra: { max_concurrency: 20 }
)
end
JsonLint::RakeTask.new do |t|
t.paths = %w[_site/data.json _site/stats.json]
end
task :verify do
ruby './verify.rb'
end
task :clean do
rm_rf './_site'
end
RuboCop::RakeTask.new
# rubocop:disable Metrics/MethodLength
def check_site(options = {})
require 'html-proofer'
dir = jekyll_site_dir
defaults = {
assume_extension: true,
check_favicon: true,
check_opengraph: true,
file_ignore: ["#{dir}/google75bd212ec246ba4f.html"],
url_ignore: ['/add',
'https://fonts.gstatic.com/',
'https://abs.twimg.com',
'https://cdn.syndication.twimg.com',
'https://fonts.googleapis.com/',
'https://pbs.twimg.com',
'https://syndication.twitter.com'],
cache: { timeframe: '1w' }
}
HTMLProofer.check_directory(dir, defaults.merge(options)).run
end
# rubocop:enable Metrics/MethodLength
def jekyll_site_dir
dir = './_site'
if File.exist?('_config.yml')
config = SafeYAML.load_file('_config.yml')
dir = config['destination'] || dir
end
dir
end
def base_dir
__dir__
end