activerecord-mimer 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,16 +11,27 @@ begin
11
11
  # Establishes a connection to the database that's used by all Active Record objects
12
12
  def self.mimer_connection(config) # :nodoc:
13
13
  config = config.symbolize_keys
14
+
15
+ username = config[:username] ? config[:username].to_s : nil
16
+ password = config[:password] ? config[:password].to_s : nil
17
+
14
18
  if config.has_key?(:dsn)
15
19
  dsn = config[:dsn]
20
+ conn = ODBC::connect(dsn, username, password)
21
+ conn.autocommit = true
22
+ ConnectionAdapters::MimerAdapter.new(conn, [dsn, username, password],logger)
16
23
  else
17
- raise ActiveRecordError, "No data source name (DSN) specified."
24
+ driver = config[:driver] ? config[:driver].to_s : "mimer_odbc"
25
+ unless config.has_key?(:db)
26
+ raise "No database provided"
27
+ end
28
+ db = config[:db].to_s
29
+ protocol = config[:protocol] ? config[:protocol].to_s : "TCP"
30
+ host = config[:host] ? config[:host].to_s : "localhost"
31
+ conn = ODBC::Database.new.drvconnect("DRIVER=#{driver};DATABASE=#{db};UID=#{username};PWD=#{password};PROTOCOL=#{protocol};NODE=#{host}")
32
+ conn.autocommit = true
33
+ ConnectionAdapters::MimerAdapter.new(conn, [nil, username, password, db, host, driver, protocol],logger)
18
34
  end
19
- username = config[:username] ? config[:username].to_s : nil
20
- password = config[:password] ? config[:password].to_s : nil
21
- conn = ODBC::connect(dsn, username, password)
22
- conn.autocommit = true
23
- ConnectionAdapters::MimerAdapter.new(conn, [dsn, username, password],logger)
24
35
  end
25
36
  end
26
37
 
data/test/basic_test.rb CHANGED
@@ -11,7 +11,6 @@ ActiveRecord::Base.establish_connection(:adapter=>'mimer',
11
11
  :username=>'test_ar',
12
12
  :password=>'test_ar')
13
13
 
14
-
15
14
  ActiveRecord::Schema.define do
16
15
  drop_table :authors rescue nil
17
16
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: activerecord-mimer
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.1
7
- date: 2006-11-08 00:00:00 +01:00
6
+ version: 0.0.2
7
+ date: 2006-11-09 00:00:00 +01:00
8
8
  summary: Mimer support for ActiveRecord.
9
9
  require_paths:
10
10
  - lib