module GClouder::Resources::Storage::Buckets::Remote

Public Class Methods

list() click to toggle source

FIXME: make more robust(!)

# File lib/gclouder/resources/storage/buckets.rb, line 62
def self.list
  gsutil("ls", "-p #{project['project_id']} -L").to_s.split("gs://").delete_if(&:empty?).each_with_object({}) do |data, collection|
    normalized = data.split("\n").map! { |b| b.delete("\t") }
    bucket_name = normalized[0].delete("/ :")
    region = normalized.select { |e| e.match("^Location constraint:") }.last.split(":").last.downcase
    collection[region] ||= []
    collection[region] << { "name" => bucket_name }
  end
end