/
Rakefile
50 lines (44 loc) · 1.27 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
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
require 'rdf'
require 'linkeddata'
require 'rdf/cli/vocab-loader'
desc 'Default: run specs.'
task :default => :spec
task :specs => :spec
# Derived from https://raw.githubusercontent.com/ruby-rdf/rdf/develop/Rakefile
desc "Generate Vocabularies"
vocab_sources = {
#oa: {
# uri: 'http://www.w3.org/ns/oa#',
# source: 'http://www.openannotation.org/spec/core/20130208/oa.owl',
# strict: true
#},
Content: {
uri: 'http://www.w3.org/2011/content#',
source: 'http://www.w3.org/2011/content',
strict: true
},
}
task :gen_vocabs => vocab_sources.keys.map {|v| "lib/rdf/vocab/#{v}.rb"}
vocab_sources.each do |id, v|
file "lib/rdf/vocab/#{id}.rb" => :do_build do
puts "Generate lib/rdf/vocab/#{id}.rb"
begin
out = StringIO.new
loader = RDF::VocabularyLoader.new(id.to_s.upcase)
loader.uri = v[:uri]
loader.source = v[:source] if v[:source]
loader.extra = v[:extra] if v[:extra]
loader.strict = v.fetch(:strict, true)
loader.output = out
loader.run
out.rewind
File.open("lib/rdf/vocab/#{id}.rb", "w") {|f| f.write out.read}
rescue
puts "Failed to load #{id}: #{$!.message}"
end
end
end
task :do_build