Module: TbBranchDb::RakeHelper
- Defined in:
- lib/tb_branch_db/rake_helper.rb
Instance Method Summary collapse
- #current_branch ⇒ Object
- #load_database_config ⇒ Object
- #master_database ⇒ Object
- #run(cmd) ⇒ Object
Instance Method Details
#current_branch ⇒ Object
10 11 12 |
# File 'lib/tb_branch_db/rake_helper.rb', line 10 def current_branch `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '') end |
#load_database_config ⇒ Object
4 5 6 7 8 |
# File 'lib/tb_branch_db/rake_helper.rb', line 4 def load_database_config config = File.read("config/database.yml") config = ERB.new(config).result YAML.load(config) end |
#master_database ⇒ Object
14 15 16 17 18 19 |
# File 'lib/tb_branch_db/rake_helper.rb', line 14 def master_database branch = current_branch database = load_database_config[Rails.env]['database'] database.sub!("_#{branch}", '') database end |
#run(cmd) ⇒ Object
21 22 23 |
# File 'lib/tb_branch_db/rake_helper.rb', line 21 def run(cmd) sh cmd end |