-
Notifications
You must be signed in to change notification settings - Fork 63
/
config.ru
103 lines (78 loc) · 2.24 KB
/
config.ru
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
require 'sinatra'
require 'sass'
require 'haml'
require 'sprockets'
require 'compass'
require 'sprockets-sass'
require 'bootstrap-sass'
require 'coffee-script'
require 'ap'
require './setup'
map '/assets' do
environment = Sprockets::Environment.new
environment.append_path 'assets/javascripts'
environment.append_path 'assets/stylesheets'
environment.append_path 'assets/images'
environment.append_path Compass::Frameworks['bootstrap'].templates_directory + '/../vendor/assets/javascripts'
environment.append_path Compass::Frameworks['bootstrap'].templates_directory + '/../vendor/assets/images'
environment.context_class.class_eval do
def asset_path(path, options={})
"/assets/#{path}"
end
end
run environment
end
get '/' do
@pattern = Rove::Pattern[params[:pattern]] if params[:pattern]
@build = @pattern.try(:build)
@build ||= Rove::Builder[params[:id].try(:strip)].try(:build)
@build ||= {}
haml :index
end
get '/install' do
File.read(File.join('binscripts', 'install'))
end
get '/:id' do
build = Rove::Builder[params[:id]]
if build
send_file build.zip, disposition: :attachment, filename: "rove-#{params[:id]}.zip"
else
redirect '/'
end
end
post '/' do
if !params['packages']
return ''
end
build = {}
params['packages'].each do |package, _|
build[package] = {}
if params['selects'] && params['selects'][package]
params['selects'][package].each do |_, option|
build[package][option] = true
end
end
if params['options'] && params['options'][package]
params['options'][package].each do |option, value|
build[package][option] = value.blank? ? true : value
end
end
end
if params['vagrant_setting']
params['vagrant_setting'].each do |setting, _|
build[setting] = {}
if params['selects'] && params['selects'][setting]
params['selects'][setting].each do |_, option|
build[setting][option] = true
end
end
if params['options'] && params['options'][setting]
params['options'][setting].each do |option, value|
build[setting][option] = value.blank? ? true : value
end
end
end
end
Rove::Builder << build
end
run Sinatra::Application