Last active
October 13, 2015 08:48
-
-
Save noxqsgit/4170142 to your computer and use it in GitHub Desktop.
ruby (rails) app config file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
# CFG { | |
require 'rails' | |
CFG_NAME = (->(; d, b) { | |
d, b = File.split Dir.pwd | |
b == 'app' ? File.basename(d) : b | |
})[] | |
CFG_DIR = "#{ Dir.home }/.apps/#{ CFG_NAME }" | |
require "#{ CFG_DIR }/cfg" | |
CFG['development'] = CFG[:dev] | |
CFG['production'] = CFG[:prod] | |
CFG['test'] = CFG[:test] | |
CFG[Rails.env][:init][] | |
# } CFG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
# CFG { | |
require 'rails' | |
# PLEASE USE A CONFIGURATION FILE FOR DEVELOPMENT AS WELL | |
if Rails.env == 'production' | |
CFG_NAME = (->(; d, b) { | |
d, b = File.split Dir.pwd | |
b == 'app' ? File.basename(d) : b | |
})[] | |
CFG_DIR = "#{ Dir.home }/.apps/#{ CFG_NAME }" | |
require "#{ CFG_DIR }/cfg" | |
CFG['development'] = CFG[:dev] | |
CFG['production'] = CFG[:prod] | |
CFG['test'] = CFG[:test] | |
CFG[Rails.env][:init][] | |
else | |
CFG = { dev: {}, test: {}, prod: {} } | |
end | |
# } CFG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CFG = { | |
test: {}, | |
dev: {}, | |
prod: { | |
db_name: '...', | |
db_user: '...', | |
db_pass: '...', | |
init: ->() { | |
File.symlink '/path/to/uploads', | |
'public/system' unless File.exists? 'public/system' | |
}, | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
development: | |
adapter: postgresql | |
encoding: utf8 | |
database: <%= CFG[:dev][:db_name] %> | |
pool: 5 | |
username: <%= CFG[:dev][:db_user] %> | |
password: <%= CFG[:dev][:db_pass] %> | |
host: <%= CFG[:dev][:db_host] or 'localhost' %> | |
test: | |
adapter: postgresql | |
encoding: utf8 | |
database: <%= CFG[:test][:db_name] %> | |
pool: 5 | |
username: <%= CFG[:test][:db_user] %> | |
password: <%= CFG[:test][:db_pass] %> | |
host: <%= CFG[:test][:db_host] or 'localhost' %> | |
production: | |
adapter: postgresql | |
encoding: utf8 | |
database: <%= CFG[:prod][:db_name] %> | |
pool: 5 | |
username: <%= CFG[:prod][:db_user] %> | |
password: <%= CFG[:prod][:db_pass] %> | |
host: <%= CFG[:prod][:db_host] or 'localhost' %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment