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
|
# File 'lib/generators/web_git/install_generator.rb', line 3
def generate_server
filename = Rails.root.join("config.ru")
log :insert, "Updating config.ru to run apps in parallel."
if File.exists?(filename) && already_installed?
log :identical, "Skipping overrides."
else
contents = <<~RUBY
if Rails.env.development?
map '/git' do
run WebGit::Server
end
end
map '/' do
RUBY
filename = "config.ru"
match_text = "run Rails.application"
insert_into_file filename, contents, before: match_text
insert_into_file filename, "\nend", after: match_text, force: true
gsub_file filename, match_text, "\t#{match_text}"
end
expect_installed = run("which expect")
unless expect_installed
log :insert, "Installing expect."
run "sudo apt install -y expect"
else
log :identical, "expect already installed."
end
end
|