This repository has been archived by the owner on Mar 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
148 lines (127 loc) · 4.79 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# encoding: UTF-8
require 'rake/gempackagetask'
require File.expand_path(File.dirname(__FILE__)) + "/Commands/lib/aphid/rake"
PROJECT_NAME = "Aphid"
ROOT_PATH = File.expand_path(File.dirname(__FILE__))
DEFAULT_TASKS = [ :build, "docs:build" ]
WATCH_TASKS = DEFAULT_TASKS
WATCH_SOURCE_TASKS = [ :build ]
SOURCE_FILES = [ "Library/Aphid.js", "Library/Aphid.Combined.js" ]
DOCUMENTATION_SOURCE = "Library/Aphid.js"
STYLESHEET_FILES = [ "Resources/Stylesheets/Aphid.less",
"Resources/Stylesheets/Aphid.IE.less",
"Resources/Stylesheets/Aphid.IE7.less",
"Resources/Stylesheets/Aphid.IE8.less",
"Resources/Stylesheets/Aphid.IE9.less" ]
# Documentation Tasks --------------------------------------------------------
desc "Generate and launch the Aphid documentation"
task :docs => [ "docs:build", "docs:open" ]
desc "Generate the Aphid documentation"
task "docs:build" => [ :build, "docs:clean" ] do
header "Generating Documentation"
begin
require "#{ROOT_PATH}/Vendor/PDoc/lib/pdoc"
rescue LoadError
puts "\nYou'll need PDoc to build this project. Simply run:\n\n"
puts " $ git submodule init"
puts " $ git submodule update"
puts "\nand you should be all set!\n\n"
exit
end
begin
require "maruku"
rescue LoadError
puts "\nYou'll need Maruku to build this project. Simply run:\n\n"
puts " $ gem install maruku"
puts "\nand you should be all set!\n\n"
exit
end
begin
require "coderay"
rescue LoadError
puts "\nYou'll need CodeRay to build this project. Simply run:\n\n"
puts " $ gem install coderay"
puts "\nand you should be all set!\n\n"
exit
end
begin
# Copy Built Aphid to PDoc Templates Directory
Dir.mkdir "#{ROOT_PATH}/Support/Templates/PDoc/assets/Vendor" rescue ""
Dir.clone! "#{ROOT_PATH}/Build", "#{ROOT_PATH}/Support/Templates/PDoc/assets/Vendor/Aphid"
# Generate Documentation
PDoc.run({
:source_files => [ "Build/Library/#{File.basename(DOCUMENTATION_SOURCE).gsub(/js$/, "Documented.js")}" ],
:destination => File.join(ROOT_PATH, "Documentation"),
:syntax_highlighter => :coderay,
:markdown_parser => :maruku,
:src_code_href => proc { |obj|
"https://github.com/activeprospect/aphid/blob/#{current_head}/#{obj.file}#LID#{obj.line_number}"
},
:pretty_urls => false,
:bust_cache => true,
:name => PROJECT_NAME,
:short_name => 'Aphid',
:home_url => 'http://aphid.activeprospect.com/',
:doc_url => 'http://aphid.activeprospect.com/api',
:version => File.read("#{ROOT_PATH}/VERSION").strip,
:copyright_notice => "Copyright © 2010-#{Time.now.year} ActiveProspect, Inc. All Rights Reserved.",
:templates => "#{ROOT_PATH}/Support/Templates/PDoc"
})
rescue => e
$FAILED = true
if $GROWL
begin
$GROWL.notify "Build Failed", "#{PROJECT_NAME} Build Failed — PDoc",
"An error occurred while compiling documentation with PDoc:\n\n#{e}\n\nReference the console for more information…"
rescue Errno::ECONNREFUSED
puts "ERROR: Connection to Growl was refused. You must enable the options \"Listen for incoming notifications\" and \"Allow remote application registration\" in your Growl settings.\n\n"
end
end
puts e.message
exit unless $WATCHING
end
end
desc "Clean up the generated documentation"
task "docs:clean" do
header "Cleaning Project"
rm_rf "#{ROOT_PATH}/Documentation"
mkdir "#{ROOT_PATH}/Documentation"
puts
end
desc "Open documentation in the default system browser"
task "docs:open" do
header "Opening Documentation"
`open "#{ROOT_PATH}/Documentation/index.html"`
puts "open \"#{ROOT_PATH}/Documentation/index.html\"\n\n"
end
# Test Tasks -----------------------------------------------------------------
begin
require "#{ROOT_PATH}/Vendor/script.aculo.us/src/javascripttest"
rescue LoadError
puts "\nYou'll need script.aculo.us to build this project. Simply run:\n\n"
puts " $ git submodule init"
puts " $ git submodule update"
puts "\nand you should be all set!\n\n"
exit
end
desc "Runs all the JavaScript unit tests and collects the results"
begin
JavaScriptTestTask.new(:test) do |test|
test.mount("/Build")
test.mount("/Tests")
test.mount("/Vendor")
Dir["Tests/**/*Test.html"].each { |test_file| test.run("/#{test_file}") }
test.browser(:safari)
end
rescue => e
puts
puts "Error while initializing test tasks (#{e})"
# Ignore errors
end
# Package Tasks --------------------------------------------------------------
spec = eval(File.read("Aphid.gemspec"))
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
pkg.package_dir = "Distribution"
end