-
Notifications
You must be signed in to change notification settings - Fork 31
/
Rakefile
53 lines (49 loc) · 1.75 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
require 'bundler/setup'
task default: :test
desc "Test examples in spec files"
task :test do
sh %(bundle exec common/extract-examples.rb index.html)
end
desc "Extract Examples"
task :examples do
sh %(rm -rf examples yaml)
sh %(bundle exec common/extract-examples.rb --example-dir examples --yaml-dir yaml index.html)
end
desc "Check HTML"
task :check_html do
require 'nokogiri'
doc = ::Nokogiri::HTML5(File.open("index.html"), max_parse_errors: 1000)
unless doc.errors.empty?
STDERR.puts "Errors found parsing index.html:"
doc.errors.each {|e| STDERR.puts " #{e}"}
exit(1)
end
end
desc "Create concatenated test manifests for reporting"
file "reports/manifests.nt" do
require 'rdf'
require 'json/ld'
require 'rdf/ntriples'
graph = RDF::Graph.new do |g|
%w( https://w3c.github.io/json-ld-api/tests/compact-manifest.jsonld
https://w3c.github.io/json-ld-api/tests/expand-manifest.jsonld
https://w3c.github.io/json-ld-api/tests/flatten-manifest.jsonld
https://w3c.github.io/json-ld-api/tests/fromRdf-manifest.jsonld
https://w3c.github.io/json-ld-api/tests/html-manifest.jsonld
https://w3c.github.io/json-ld-api/tests/remote-doc-manifest.jsonld
https://w3c.github.io/json-ld-api/tests/toRdf-manifest.jsonld
https://w3c.github.io/json-ld-framing/tests/frame-manifest.jsonld
).each do |man|
puts "load #{man}"
local_man = if man.include?('json-ld-api')
basename = File.basename(man)
File.expand_path("../tests/#{basename}", __FILE__)
else
man
end
g.load(local_man, base_uri: man, unique_bnodes: true)
end
end
puts "write"
RDF::NTriples::Writer.open("reports/manifests.nt", unique_bnodes: true, validate: false) {|w| w << graph}
end