-
Notifications
You must be signed in to change notification settings - Fork 25
/
Rakefile
118 lines (104 loc) · 3.41 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# frozen_string_literal: true
require 'rubygems'
task default: [:spec]
namespace :gem do
desc "Build the json-ld-#{File.read('VERSION').chomp}.gem file"
task :build do
sh "gem build json-ld.gemspec && mv json-ld-#{File.read('VERSION').chomp}.gem pkg/"
end
desc "Release the json-ld-#{File.read('VERSION').chomp}.gem file"
task :release do
sh "gem push pkg/json-ld-#{File.read('VERSION').chomp}.gem"
end
end
require 'rspec/core/rake_task'
desc 'Run specifications'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.rspec_opts = %w[--options spec/spec.opts] if File.exist?('spec/spec.opts')
end
desc "Generate schema.org context"
task :schema_context do
`
script/gen_context https://schema.org/docs/schema_org_rdfa.html \
--vocab http://schema.org/ \
--prefix 'schema http://schema.org/' \
--body --hier \
--o etc/schema.org.jsonld
`
end
desc "Create concatenated test manifests"
file "etc/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}"
g.load(man, unique_bnodes: true)
end
end
puts "write"
RDF::NTriples::Writer.open("etc/manifests.nt", unique_bnodes: true, validate: false) { |w| w << graph }
end
# Presentation building
namespace :presentation do
desc "Clean presentation files"
task :clean do
FileUtils.rm %w[compacted expanded framed].map { |f| "presentation/dbpedia/#{f}.jsonld" }
end
desc "Build presentation files"
task build: %w[
presentation/dbpedia/expanded.jsonld
presentation/dbpedia/compacted.jsonld
presentation/dbpedia/framed.jsonld
]
desc "Build expanded example"
file "presentation/dbpedia/expanded.jsonld" => %w[
presentation/dbpedia/orig.jsonld
presentation/dbpedia/expanded-context.jsonld
] do
system(%w[
script/parse
--expand presentation/dbpedia/orig.jsonld
--context presentation/dbpedia/expanded-context.jsonld
-o presentation/dbpedia/expanded.jsonld
].join(" "))
end
desc "Build compacted example"
file "presentation/dbpedia/compacted.jsonld" => %w[
presentation/dbpedia/expanded.jsonld
presentation/dbpedia/compact-context.jsonld
] do
system(%w[
script/parse
--compact presentation/dbpedia/expanded.jsonld
--context presentation/dbpedia/compact-context.jsonld
-o presentation/dbpedia/compacted.jsonld
].join(" "))
end
desc "Build framed example"
file "presentation/dbpedia/framed.jsonld" => %w[
presentation/dbpedia/expanded.jsonld
presentation/dbpedia/frame.jsonld
] do
system(%w[
script/parse
--frame presentation/dbpedia/frame.jsonld
presentation/dbpedia/expanded.jsonld
-o presentation/dbpedia/framed.jsonld
].join(" "))
end
end
require 'yard'
namespace :doc do
YARD::Rake::YardocTask.new
end
task default: :spec
task specs: :spec