-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
73 lines (69 loc) · 2.54 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
# -*- coding: utf-8 -*-
begin
namespace :naturaldocs do
task :generate do
sh %{mkdir -p docs/.nd && naturaldocs -i . -o html docs -p docs/.nd} do |ok, res|
if ok
puts "Documents generated successfully in docs."
else
puts "Couldn’t generate documentation, have you installed naturaldocs? (sudo apt-get install naturaldocs)."
end
end
end
task :site do
sh "rm -rf /tmp/osw-js"
sh "git clone [email protected]:owengriffin/osw-js.git /tmp/osw-js"
sh "git --git-dir=/tmp/osw-js/.git --work-tree=/tmp/osw-js branch --track gh-pages origin/gh-pages"
sh "git --git-dir=/tmp/osw-js/.git --work-tree=/tmp/osw-js checkout gh-pages"
sh "naturaldocs -i src/ -o html /tmp/osw-js -p /tmp/osw-js"
sh "git --git-dir=/tmp/osw-js/.git --work-tree=/tmp/osw-js add ."
sh "git --git-dir=/tmp/osw-js/.git --work-tree=/tmp/osw-js commit -m 'Automatic site generation.'"
sh "git --git-dir=/tmp/osw-js/.git --work-tree=/tmp/osw-js push origin"
end
end
end
begin
namespace :jslint do
task :install do
if not File.exists? "vendor/rhino.jar"
sh %{wget -q -O vendor/rhino.zip ftp:https://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R2.zip}
sh %{unzip vendor/rhino.zip rhino1_7R2/js.jar}
sh %{mv rhino1_7R2/js.jar vendor/rhino.jar}
sh %{rm -rf rhino1_7R2}
sh %{rm -rf rhino.zip}
end
if not File.exists? "vendor/jslint.js"
sh %{wget -q -O vendor/jslint.js http:https://www.jslint.com/rhino/jslint.js}
end
end
desc "Check the JavaScript source with JSLint - exit with status 1 if any of the files fail."
task :jslint => ["jslint:install"] do
failed_files = []
classpath = File.join("vendor", "rhino.jar")
jslint_path = File.join("vendor", "jslint.js")
Dir['src/**/*.js'].each do |fname|
puts "Running JSLint on #{fname}"
cmd = "java -cp #{classpath} org.mozilla.javascript.tools.shell.Main #{jslint_path} #{fname}"
results = %x{#{cmd}}
unless results =~ /^jslint: No problems found in/
puts "#{fname}:"
puts results
failed_files << fname
end
end
if failed_files.size > 0
exit 1
end
end
end
end
begin
require 'cucumber'
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format pretty"
end
rescue LoadError
puts "Cucumber needs to be installed before any tests can be executed"
end
task :default => ["naturaldocs:generate", "jslint:jslint"]