Skip to content

Commit

Permalink
Dynamic dependency on mysql or postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
delitescere committed Jun 23, 2010
1 parent 0ebec57 commit f3a37e4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'rake'
require 'spec/rake/spectask'
require 'rake/rdoctask'
require 'metric_fu'

begin
require 'jeweler'
Expand All @@ -24,9 +25,7 @@ begin

# export DBMS
gemspec.add_dependency('data_objects', '>= 0.10.2')
gemspec.add_dependency('mysql', '>= 2.8.1')
gemspec.add_dependency('do_mysql', '>= 0.10.2')
gemspec.add_dependency('pg', '>= 0.9.0')
gemspec.add_dependency('do_postgres', '>= 0.10.2')

gemspec.add_development_dependency('rspec', '>= 1.3.0')
Expand Down
7 changes: 3 additions & 4 deletions lib/squealer/database.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
require 'mongo'
require 'data_objects'
require 'mysql'
require 'do_mysql'
require 'do_postgres'

require 'singleton'

Expand All @@ -16,6 +13,8 @@ def import_from(host, port, name)
end

def export_to(adapter, host, username, password, name)
require "do_#{adapter}"

@@all_export_connections ||= []
@export_do.dispose if @export_do

Expand All @@ -32,7 +31,7 @@ def export
end

def upsertable?
@export_do.is_a? DataObjects::Mysql::Connection
defined?(DataObjects::Mysql) && @export_do.is_a?(DataObjects::Mysql::Connection)
end

class Connection
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper_dbms_mysql.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
def create_export_db(name)
require 'do_mysql'
$db_adapter = 'mysql'
dbc = DataObjects::Connection.new("mysql://root@localhost/mysql")
dbc.create_command("DROP DATABASE IF EXISTS #{name}").execute_non_query
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper_dbms_postgres.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
def create_export_db(name)
require 'do_postgres'
$db_adapter = 'postgres'
dbc = DataObjects::Connection.new("postgres://localhost/postgres")
dbc.create_command("DROP DATABASE IF EXISTS #{name}").execute_non_query
Expand Down

0 comments on commit f3a37e4

Please sign in to comment.