-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathRakefile
70 lines (54 loc) · 1.64 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
require 'rubygems'
require 'rake'
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new
# TODO: simplecov
namespace :parser do
desc "Compile the parser"
task :compile do
require 'treetop'
compiler = Treetop::Compiler::GrammarCompiler.new
treetop_dir = File.expand_path(File.join(File.dirname(__FILE__), "lib", "webidl", "parser"))
Dir[File.join(treetop_dir, "*.{tt,treetop}")].each do |treetop_file_path|
compiler.compile(treetop_file_path)
end
end
end
namespace :webidl do
WEBIDL_URL = "https://heycam.github.io/webidl/"
HTML5_URL = "https://www.w3.org/TR/html/single-page.html"
desc "Download the webidl spec to support/"
task :download do
require 'open-uri'
spec_file = "support/webidl-spec-#{Time.now.strftime "%Y-%m-%d"}.html"
size = 0
File.open(spec_file, "w") do |file|
file << data = open(WEBIDL_URL).read
size = data.bytesize
end
puts "#{WEBIDL_URL} => #{spec_file} (#{size} bytes)"
end
desc "Download and extract HTML5 IDL parts to spec/fixtures"
task :html5 do
require 'open-uri'
require 'nokogiri'
idl_file = "spec/fixtures/html5.idl"
size = 0
File.open(idl_file, "w") do |file|
file << data = Nokogiri.HTML(open(HTML5_URL)).css("pre.idl").map { |e| e.inner_text }.join("\n\n")
size = data.bytesize
end
puts "#{HTML5_URL} => #{idl_file} (#{size} bytes)"
end
end
task :default => :spec
begin
require 'yard'
YARD::Rake::YardocTask.new
rescue LoadError
task :yardoc do
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
end
end