Skip to content

Instantly share code, notes, and snippets.

@zeroeth
Created May 10, 2010 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeroeth/396136 to your computer and use it in GitHub Desktop.
Save zeroeth/396136 to your computer and use it in GitHub Desktop.
evaluation_branches:
select: ^(evaluations)
courseware:
select: (courseware)
fast_srids:
select: (fast_srids)
unrelated_example
select: wierd
output: lambda { 'usethis' }
other_unrelated
select: other
output: lambda { 'usethis' }
<%
branch_file = "#{RAILS_ROOT}/config/branch_databases.yml"
branches = File.file?(branch_file) ? YAML.load_file(branch_file) : {}
git_branches = `cd "#{RAILS_ROOT}"; git branch --no-color`
output = ''
if $?.to_i == 0
current_branch = git_branches.split("\n").detect { |b| b.match(/\A\*/) }.gsub(/\A\* /, '')
match = branches.detect{|name,branch| current_branch.match branch['select'] }
if match
output = "_#{$&}"
end
end
puts "-- Branch database in use: #{output}" unless output.blank?
%>
development:
database: myapp_development<%= output %>
<<: *defaults
production:
database: myapp<%= output %>
<<: *defaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment