summaryrefslogtreecommitdiff
path: root/lib/leap/server.rb
blob: 05d76e3fe01735e8ba1d5a5f4e37d7a7fc156c36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'couchrest'

module LEAP
  class Server < CouchRest::Server

    def initialize
      netrc = File.read('/root/.netrc').split(' ')
      auth = "%{username}:%{password}@" % {username: netrc[3], password: netrc[5]}
      super("http://#{auth}localhost:5984")
    end

    #
    # returns an array of the names of all the per-user storage
    # databases.
    #
    def storage_dbs
      self.databases.select { |db_name|
        db_name =~ /^user-[a-f0-9]{32}$/
      }
    end

  end
end