Sha256: 039c2cccc643f092085fa4b231ee383859ff34389a744acfbc812a9c495e6cfb

Contents?: true

Size: 710 Bytes

Versions: 1

Compression:

Stored size: 710 Bytes

Contents

require 'data_mapper'
require 'json'

module Alvid
  def self.init
    db_uri = if ENV['VCAP_SERVICES'].nil? || JSON.parse(ENV['VCAP_SERVICES']).empty?
                require 'dm-sqlite-adapter'
               'sqlite::memory:'
             else
               require 'dm-mysql-adapter'
               product_name, service = JSON.parse(ENV['VCAP_SERVICES']).first
               case product_name
                 when /mysql/
                   service.first.first[1]['uri']
                 when /cleardb/
                   service.first['credentials']['uri']
               end
             end
    DataMapper.setup(:default, db_uri)
  end
end

Alvid.init

require "alvid/version"
require "alvid/retro"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alvid-0.2.1 lib/alvid.rb