-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
42 lines (37 loc) · 1006 Bytes
/
app.rb
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
require 'rubygems' if RUBY_VERSION < '1.9'
require 'sinatra';
require 'json'
require 'yaml'
require 'capistrano'
# Because every deployment scheme should have an "I Win" button
class App < Sinatra::Base
set :static, true
set :public, File.dirname(__FILE__) + '/public'
get '/' do
erb :index
end
get '/status.json' do
content_type :json
File.open( File.expand_path('../data/build.json', __FILE__) ).read
end
post '/status.json' do
File.open(File.expand_path('../data/build.json', __FILE__), 'w') { |f|
f.write(params.to_json)
}
end
post '/deploy' do
File.open(File.expand_path('../data/build.json', __FILE__), 'w') { |f|
f.write(params.to_json)
}
`cap staging deploy`
File.open(File.expand_path('../data/build.json', __FILE__), 'w') { |f|
f.write(
{
:status => "deployed",
:last_built => DateTime.now.strftime("at %I:%M%p on %m/%d/%Y")
}.to_json
)
}
erb :index
end
end