+
+ if params[:mapquest_key]
+ line.gsub!(/^( *)#mapquest_key:.*$/, "\\1mapquest_key: \"#{params[:mapquest_key]}\"")
+ end
+
+ if params[:mapzen_valhalla_key]
+ line.gsub!(/^( *)#mapzen_valhalla_key:.*$/, "\\1mapzen_valhalla_key: \"#{params[:mapzen_valhalla_key]}\"")
+ end
+
+ if params[:thunderforest_key]
+ line.gsub!(/^( *)#thunderforest_key:.*$/, "\\1thunderforest_key: \"#{params[:thunderforest_key]}\"")
+ end
+
+ if params[:totp_key]
+ line.gsub!(/^( *)#totp_key:.*$/, "\\1totp_key: \"#{params[:totp_key]}\"")
+ end
+
+ line.gsub!(/^( *)require_terms_seen:.*$/, "\\1require_terms_seen: true")
+ line.gsub!(/^( *)require_terms_agreed:.*$/, "\\1require_terms_agreed: true")
+
+ line
+ end
+
+ file "#{rails_directory}/config/application.yml" do
+ owner rails_user
+ group rails_group
+ mode 0o664
+ content application_yml
+ notifies :run, "execute[#{rails_directory}/public/assets]"
+ end
+
+ if params[:piwik_configuration]
+ file "#{rails_directory}/config/piwik.yml" do
+ owner rails_user
+ group rails_group
+ mode 0o664
+ content YAML.dump(params[:piwik_configuration])
+ notifies :run, "execute[#{rails_directory}/public/assets]"
+ end
+ else
+ file "#{rails_directory}/config/piwik.yml" do
+ action :delete
+ notifies :run, "execute[#{rails_directory}/public/assets]"
+ end
+ end
+
+ execute "#{rails_directory}/Gemfile" do
+ action :nothing
+ command "bundle#{ruby_version} install"
+ cwd rails_directory
+ user "root"
+ group "root"
+ environment "NOKOGIRI_USE_SYSTEM_LIBRARIES" => "yes"
+ subscribes :run, "gem_package[bundler#{ruby_version}]"
+ notifies :run, "execute[#{rails_directory}]"
+ end
+
+ execute "#{rails_directory}/db/migrate" do
+ action :nothing
+ command "bundle#{ruby_version} exec rake db:migrate"
+ cwd rails_directory
+ user rails_user
+ group rails_group
+ subscribes :run, "git[#{rails_directory}]"
+ notifies :run, "execute[#{rails_directory}]"
+ only_if { run_migrations }
+ end
+
+ execute "#{rails_directory}/public/assets" do
+ action :nothing
+ command "bundle#{ruby_version} exec rake assets:precompile"
+ environment "RAILS_ENV" => "production"
+ cwd rails_directory
+ user rails_user
+ group rails_group
+ notifies :run, "execute[#{rails_directory}]"
+ end
+
+ file "#{rails_directory}/public/export/embed.html" do
+ action :nothing