test/connection.rb in ruote-sequel-2.3.0 vs test/connection.rb in ruote-sequel-2.3.0.2
- old
+ new
@@ -9,34 +9,40 @@
require 'ruote-sequel'
unless $sequel
- $sequel = case ENV['RUOTE_STORAGE_DB'] || 'postgres'
- when 'pg', 'postgres'
- Sequel.connect('postgres://localhost/ruote_test')
- when 'my', 'mysql'
- #Sequel.connect('mysql://root:root@localhost/ruote_test')
- Sequel.connect('mysql://root@localhost/ruote_test')
- when 'mysql2'
- Sequel.connect('mysql2://root@localhost/ruote_test')
- when /:/
- Sequel.connect(ENV['RUOTE_STORAGE_DB'])
- else
- raise ArgumentError.new("unknown DB: #{ENV['RUOTE_STORAGE_DB'].inspect}")
- end
+ $sequel =
+ case ENV['RUOTE_STORAGE_DB'] || 'postgres'
+ when 'pg', 'postgres'
+ Sequel.connect('postgres://localhost/ruote_test')
+ when 'my', 'mysql'
+ #Sequel.connect('mysql://root:root@localhost/ruote_test')
+ Sequel.connect('mysql://root@localhost/ruote_test')
+ when 'mysql2'
+ Sequel.connect(
+ 'mysql2://root@localhost/ruote_test',
+ :after_connect => proc { |c| c.send(:reconnect=, true) })
+ when /:/
+ Sequel.connect(ENV['RUOTE_STORAGE_DB'])
+ else
+ raise ArgumentError.new("unknown DB: #{ENV['RUOTE_STORAGE_DB'].inspect}")
+ end
require 'logger'
- logger = case ENV['RUOTE_STORAGE_DEBUG']
- when 'log'
- FileUtils.rm('debug.log') rescue nil
- Logger.new('debug.log')
- when 'stdout'
- Logger.new($stdout)
- else
- nil
- end
+ logger =
+ case dbg = ENV['RUOTE_STORAGE_DEBUG']
+ when 'log'
+ FileUtils.rm("debug_#{$$}.log") rescue nil
+ Logger.new("debug_#{$$}.log")
+ when 'stdout'
+ Logger.new($stdout)
+ when /\.(log|txt)$/
+ Logger.new(dbg)
+ else
+ nil
+ end
if logger
logger.level = Logger::DEBUG
$sequel.loggers << logger
end