-
Notifications
You must be signed in to change notification settings - Fork 1
/
exclude_database_yaml.rb
32 lines (27 loc) · 1.06 KB
/
exclude_database_yaml.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
say_recipe 'Exclude database.yml from version control'
create_file 'lib/tasks/init_database_yaml.rake' do
<<-'RAKE'.gsub(/^ {4}/, '')
namespace :init do
task 'database_yaml' do
unless File.exists?(File.join('config', 'database.yml'))
cp(File.join('config', 'database.sample.yml'),
File.join('config', 'database.yml'), :verbose => true)
end
end
end
unless Rake::Task.task_defined?("init")
desc "Initializes the rails environment for development"
task :init do ; end
end
# Add namespaced tasks to default :init task
Rake::Task["init"].enhance ["init:database_yaml"]
RAKE
end
# wait until all generators have had a chance to touch config/database.yml
after_bundler do
say_wizard "Adding Java platform detection in database.yml"
gsub_file "config/database.yml", /^(\s*adapter:) (.+)$/,
%q{\1 <%= RUBY_PLATFORM =~ /java/ ? 'jdbc\2' : '\2' %>}
say_wizard "Creating config/database.sample.yml for version control"
FileUtils.cp "config/database.yml", "config/database.sample.yml"
end