-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
73 lines (62 loc) · 1.72 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
#!/usr/bin/env ruby
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib')))
require 'rubygems'
require 'yard'
require 'rspec/core/rake_task'
namespace :gem do
desc "Build the shex-#{File.read('VERSION').chomp}.gem file"
task :build do
sh "gem build shex.gemspec && mv shex-#{File.read('VERSION').chomp}.gem pkg/"
end
desc "Release the shex-#{File.read('VERSION').chomp}.gem file"
task :release do
sh "gem push pkg/shex-#{File.read('VERSION').chomp}.gem"
end
end
desc 'Default: run specs.'
task default: :spec
RSpec::Core::RakeTask.new(:spec)
desc 'Create versions of ebnf files in etc'
task etc: %w{etc/shex.sxp etc/shex.html etc/shex.peg.sxp}
desc 'Build first, follow and branch tables'
task meta: "lib/shex/meta.rb"
file "lib/shex/meta.rb" => "etc/shex.ebnf" do |t|
sh %{
ebnf --peg --format rb \
--input-format native \
--mod-name ShEx::Meta \
--output lib/shex/meta.rb \
etc/shex.ebnf
}
end
file "etc/shex.peg.sxp" => "etc/shex.ebnf" do |t|
sh %{
ebnf --peg --format sxp \
--input-format native \
--output etc/shex.peg.sxp \
etc/shex.ebnf
}
end
file "etc/shex.sxp" => "etc/shex.ebnf" do |t|
sh %{
ebnf --input-format native --format sxp \
--output etc/shex.sxp \
etc/shex.ebnf
}
end
file "etc/shex.html" => "etc/shex.ebnf" do |t|
sh %{
ebnf --input-format native --format html \
--output etc/shex.html \
etc/shex.ebnf
}
end
desc "Build shex JSON-LD context cache"
task context: "lib/shex/shex_context.rb"
file "lib/shex/shex_context.rb" do
require 'json/ld'
File.open("lib/shex/shex_context.rb", "w") do |f|
c = JSON::LD::Context.new().parse("http://www.w3.org/ns/shex.jsonld")
f.write c.to_rb
end
end