Sha256: 1a05a1a807a44061f2e691dfce8d3663606be61c334389fd9f967d42446b07c4

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

require "rivendell/db/version"

require 'dm-core'
require 'dm-mysql-adapter'
require 'dm-serializer'
require 'dm-types'
require 'dm-validations'

module Rivendell
  # DataMapper::Logger.new(STDOUT, :debug)
  # DataMapper::Model.raise_on_save_failure = true

  module DB

    def self.mysql_conf
      @mysql_conf ||= IniFile.load("/etc/rd.conf")['mySQL'] if File.exists?("/etc/rc.conf")
    end

    def self.default_url
      if mysql_conf
        # If we can, pull the config from Rivendell's own configuration.
        "mysql://#{mysql_conf['Loginname']}:#{mysql_conf['Password']}@#{mysql_conf['Hostname']}/#{mysql_conf['Database']}"
      else
        'mysql://rduser:letmein@localhost/Rivendell'
      end
    end

    def self.establish_connection(url = default_url)
      # Rivendell's default for most setups
      DataMapper.setup :default, url

      DataMapper.repository(:default).adapter.field_naming_convention = 
        DataMapper::NamingConventions::Field::Underscored 

      true
    end
  end

end

# require 'rivendell/log_item'
# require 'rivendell/log'
require 'rivendell/db/cut'
require 'rivendell/db/cart'
require 'rivendell/db/dropbox'
require 'rivendell/db/group'
# require 'rivendell/task'
# require 'rivendell/tools'

DataMapper.finalize

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rivendell-db-0.3 lib/rivendell/db.rb
rivendell-db-0.2 lib/rivendell/db.rb
rivendell-db-0.0.1 lib/rivendell/db.rb