forked from rdfa/rdfa-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
65 lines (58 loc) · 1.88 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
require 'bundler'
require 'fileutils'
$:.unshift(File.expand_path('../lib', __FILE__))
task :environment do
Bundler.require(:default)
require File.expand_path("../lib/crazyivan", __FILE__)
end
namespace :assets do
desc 'Precompile assets'
task :precompile => [:environment, :clear] do
CrazyIvan.assets.precompile
end
desc 'Clear precompiled assets'
task :clear do
FileUtils.rm_rf File.expand_path("../manifest.jsonld", __FILE__)
Dir.glob('./public/*/application-*.{js,css}').each do |f|
FileUtils.rm f
end
end
end
desc 'Generate manifest.json'
task :manifest => :environment do
require 'crazyivan/core'
CrazyIvan::StandAlone.new.send(:manifest_json)
end
namespace :earl do
desc 'Collate reports'
task :collate => :environment do
require 'earl'
puts "parse individual results"
earl = EARL.new(Dir.glob(File.expand_path("../public/earl-reports/*-rdfa*.html", __FILE__)))
File.open(File.expand_path("../public/earl-reports/earl.jsonld", __FILE__), "w") do |file|
puts "dump #{earl.graph.count} triples to JSON-LD"
earl.dump(:jsonld, file)
end
File.open(File.expand_path("../public/earl-reports/earl.ttl", __FILE__), "w") do |file|
puts "dump #{earl.graph.count} triples to Turtle"
earl.dump(:ttl, file)
end
end
desc 'Generate comprehensive report'
task :report do
require 'earl'
source_files = Dir.glob(File.expand_path("../public/earl-reports/*-rdfa*.html", __FILE__)).map do |f|
f.split('/').last
end
earl_json = File.read(File.expand_path("../public/earl-reports/earl.jsonld", __FILE__))
File.open(File.expand_path("../public/earl-reports/earl.html", __FILE__), "w") do |file|
EARL.generate(earl_json, source_files, file)
end
end
end
namespace :cache do
desc 'Clear document cache'
task :clear do
FileUtils.rm_rf File.expand_path("../cache", __FILE__)
end
end