module Golem::DB

Database handling. See {Golem::DB::Pg} and {Golem::DB::Static}.

A db should respond to 4 methods: users, repositories, ssh_keys, setup. The first 3 should take a single hash argument (options) and return an array/hash of results, setup takes no arguments (it may use a block). These options should be supported:

Public Class Methods

db() click to toggle source

Proxy for the used db. @return [Pg, Static] the db currently used.

# File lib/golem/db.rb, line 15
def self.db
    @db ||= case Golem::Config.db
        when /\Apostgres:\/\// then Pg.new(Golem::Config.db)
        when "static" then Static.new
        else abort "Unknown DB (#{Golem::Config.db.to_s})."
        end
end
repositories(opts = {}) click to toggle source

Forwards to proxy’s repositories. @return [Array, Hash] results.

# File lib/golem/db.rb, line 31
def self.repositories(opts = {})
    db.repositories(opts)
end
setup(&block) click to toggle source

Forwards to proxy’s setup. @return [] depends on proxy.

# File lib/golem/db.rb, line 43
def self.setup(&block)
    db.setup(&block)
end
ssh_keys(opts = {}) click to toggle source

Forwards to proxy’s ssh_keys. @return [Array, Hash] results.

# File lib/golem/db.rb, line 37
def self.ssh_keys(opts = {})
    db.ssh_keys(opts)
end
users(opts = {}) click to toggle source

Forwards to proxy’s users. @return [Array, Hash] results.

# File lib/golem/db.rb, line 25
def self.users(opts = {})
    db.users(opts)
end