Created
May 10, 2010 14:53
-
-
Save zeroeth/396136 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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' } |
This file contains hidden or 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
<% | |
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 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment