Module: BranchDb::TaskHelper
- Defined in:
- lib/branch_db/task_helper.rb
Instance Method Summary collapse
- #current_branch ⇒ Object
- #each_local_config ⇒ Object
- #each_local_database(*args) ⇒ Object
- #environment_options ⇒ Object
- #originating_branch ⇒ Object
- #target_branch ⇒ Object
Instance Method Details
#current_branch ⇒ Object
7 8 9 |
# File 'lib/branch_db/task_helper.rb', line 7 def current_branch BranchDb::current_repo_branch(true) end |
#each_local_config ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/branch_db/task_helper.rb', line 27 def each_local_config ActiveRecord::Base.configurations.each do |rails_env, config| next unless config['database'] case per_branch = config['per_branch'] when true # when Hash else next end local_database?(config) do yield rails_env, config end end end |
#each_local_database(*args) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/branch_db/task_helper.rb', line 42 def each_local_database(*args) = args.last.kind_of?(Hash) ? args.pop : {} = .reverse_merge() branch = args[0] || target_branch each_local_config do |rails_env, config| yield BranchDb::Switcher.create(rails_env, config, branch, ) end end |
#environment_options ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/branch_db/task_helper.rb', line 11 def returning = {} do [:overwrite, :verbose].each do |opt| [opt] = (ENV[opt.to_s.upcase] =~ /\A(true|1)\Z/i) == 0 end end end |
#originating_branch ⇒ Object
23 24 25 |
# File 'lib/branch_db/task_helper.rb', line 23 def originating_branch ENV['ORIG_BRANCH'] || 'master' ### TODO determine originating branch end |
#target_branch ⇒ Object
19 20 21 |
# File 'lib/branch_db/task_helper.rb', line 19 def target_branch ENV['BRANCH'] || current_branch end |