Module: LandscapeTurner::Helpers
Instance Method Summary collapse
Instance Method Details
#get_landscape_databases ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/landscape-turner/helpers.rb', line 9 def get_landscape_databases() landscape_databases = Array.new() list = Open3.capture3("cd /tmp && sudo -u postgres psql -qlA")[0].split("\n") #This is to remove irrelevant information generated from this command at the first and last line. list.shift() list.pop() landscape_list = Array.new() list.each { |item| db_name = item.split("|")[0] if db_name.start_with?("landscape") landscape_list.push(db_name) end } return landscape_list end |
#safe_system(cmd) ⇒ Object
5 6 7 8 |
# File 'lib/landscape-turner/helpers.rb', line 5 def safe_system(cmd) e = system(cmd) raise "Failure in command: #{cmd.inspect}!" unless e end |