-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
59 lines (51 loc) · 1.56 KB
/
Rakefile
File metadata and controls
59 lines (51 loc) · 1.56 KB
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
BASE_PATH = File.expand_path(File.dirname(__FILE__))
SRC_PATH = File.join(BASE_PATH, 'src')
SERVER_HOST = '0.0.0.0'
SERVER_PORT = 3000
DEPLOY_SERVER = ENV['DEPLOY_SERVER']
namespace :compile do
desc 'compiles peg files and rewrites to be CommonJS friendly'
task :peg do
Dir.glob(File.join(SRC_PATH, '**', '*.pegjs')).each do |input_path|
IO.popen('pegjs', 'w+') do |pipe|
File.open(input_path) { |input| pipe.puts(input.read) }
pipe.close_write
out_path = File.join(File.dirname(input_path), File.basename(input_path, '.pegjs') + '.js')
out_str = pipe.read
out_str.gsub!(/^module\.exports = \(function\(\)\{$/, '(function(){')
out_str.gsub!(/^ return result;$/, ' jQuery.extend(exports, result);')
File.open(out_path, 'w') { |out| out.puts out_str }
end
end
end
end
desc 'starts thin web server'
task :server do
require 'rack'
require 'rack-cache'
require 'thin'
app = Rack::Builder.new do
use Rack::ShowExceptions
use Rack::Cache,
:verbose => false,
:allow_reload => true,
:default_ttl => 0
run Rack::Directory.new(SRC_PATH)
end
Rack::Handler::Thin.run(app, { :Host => SERVER_HOST, :Port => SERVER_PORT })
end
desc 'Deploys to the remote server'
task :deploy do
raise "Please specify a DEPLOY_SERVER env var." unless DEPLOY_SERVER
chdir(BUILD_PATH) do
args = []
args << "rsync"
args << "-avz"
args << "--stats"
args << "--progress"
args << "--delete"
args << "."
args << DEPLOY_SERVER
system(*args)
end
end