mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Fix default arguments in method definitions for ruby 2.2
This commit is contained in:
parent
05db934a19
commit
c38119c6f9
5 changed files with 26 additions and 26 deletions
|
@ -8,18 +8,18 @@ module MySQL2Helper
|
|||
# require 'logger'
|
||||
# ActiveRecord::Base.logger = Logger.new(STDERR)
|
||||
|
||||
def config
|
||||
def default_config
|
||||
db_config['mysql2']
|
||||
end
|
||||
|
||||
def create_db
|
||||
establish_connection(config.merge(:database => nil))
|
||||
establish_connection(default_config.merge(:database => nil))
|
||||
|
||||
ActiveRecord::Base.connection.drop_database config['database'] rescue nil
|
||||
ActiveRecord::Base.connection.create_database config['database']
|
||||
ActiveRecord::Base.connection.drop_database default_config['database'] rescue nil
|
||||
ActiveRecord::Base.connection.create_database default_config['database']
|
||||
end
|
||||
|
||||
def establish_connection config = config
|
||||
def establish_connection(config = default_config)
|
||||
ActiveRecord::Base.establish_connection config
|
||||
end
|
||||
|
||||
|
|
|
@ -7,18 +7,18 @@ module MySQLHelper
|
|||
# require 'logger'
|
||||
# ActiveRecord::Base.logger = Logger.new(STDERR)
|
||||
|
||||
def config
|
||||
def default_config
|
||||
db_config['mysql']
|
||||
end
|
||||
|
||||
def create_db
|
||||
establish_connection(config.merge(:database => nil))
|
||||
establish_connection(default_config.merge(:database => nil))
|
||||
|
||||
ActiveRecord::Base.connection.drop_database config['database'] rescue nil
|
||||
ActiveRecord::Base.connection.create_database config['database']
|
||||
ActiveRecord::Base.connection.drop_database default_config['database'] rescue nil
|
||||
ActiveRecord::Base.connection.create_database default_config['database']
|
||||
end
|
||||
|
||||
def establish_connection config = config
|
||||
def establish_connection(config = default_config)
|
||||
ActiveRecord::Base.establish_connection config
|
||||
end
|
||||
|
||||
|
|
|
@ -6,22 +6,22 @@ module PostgreSQLHelper
|
|||
|
||||
# ActiveRecord::Base.logger = Logger.new(STDERR)
|
||||
|
||||
def config
|
||||
def default_config
|
||||
db_config['postgres']
|
||||
end
|
||||
|
||||
def create_db
|
||||
@encoding = config['encoding'] || ENV['CHARSET'] || 'utf8'
|
||||
@encoding = default_config['encoding'] || ENV['CHARSET'] || 'utf8'
|
||||
begin
|
||||
establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
|
||||
ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding))
|
||||
establish_connection(default_config.merge('database' => 'postgres', 'schema_search_path' => 'public'))
|
||||
ActiveRecord::Base.connection.create_database(default_config['database'], default_config.merge('encoding' => @encoding))
|
||||
rescue Exception => e
|
||||
$stderr.puts e, *(e.backtrace)
|
||||
$stderr.puts "Couldn't create database for #{config.inspect}"
|
||||
$stderr.puts "Couldn't create database for #{default_config.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
def establish_connection config = config
|
||||
def establish_connection(config = default_config)
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
end
|
||||
|
||||
|
|
|
@ -6,21 +6,21 @@ module SQLite3Helper
|
|||
|
||||
# ActiveRecord::Base.logger = Logger.new(STDERR)
|
||||
|
||||
def config
|
||||
def default_config
|
||||
db_config['sqlite3']
|
||||
end
|
||||
|
||||
def create_db
|
||||
@encoding = config['encoding'] || ENV['CHARSET'] || 'utf8'
|
||||
@encoding = default_config['encoding'] || ENV['CHARSET'] || 'utf8'
|
||||
begin
|
||||
establish_connection(config.merge('database' => 'sqlite3', 'schema_search_path' => 'public'))
|
||||
establish_connection(default_config.merge('database' => 'sqlite3', 'schema_search_path' => 'public'))
|
||||
rescue Exception => e
|
||||
$stderr.puts e, *(e.backtrace)
|
||||
$stderr.puts "Couldn't create database for #{config.inspect}"
|
||||
$stderr.puts "Couldn't create database for #{default_config.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
def establish_connection config = config
|
||||
def establish_connection(config = default_config)
|
||||
ActiveRecord::Base.establish_connection(config)
|
||||
end
|
||||
|
||||
|
|
|
@ -5,21 +5,21 @@ module DataMapperSQLite3Helper
|
|||
|
||||
puts "DataMapper #{DataMapper::VERSION}, sqlite3"
|
||||
|
||||
def config
|
||||
def default_config
|
||||
db_config['sqlite3']
|
||||
end
|
||||
|
||||
def create_db
|
||||
@encoding = config['encoding'] || ENV['CHARSET'] || 'utf8'
|
||||
@encoding = default_config['encoding'] || ENV['CHARSET'] || 'utf8'
|
||||
begin
|
||||
establish_connection(config.merge('database' => 'sqlite3', 'schema_search_path' => 'public'))
|
||||
establish_connection(default_config.merge('database' => 'sqlite3', 'schema_search_path' => 'public'))
|
||||
rescue Exception => e
|
||||
$stderr.puts e, *(e.backtrace)
|
||||
$stderr.puts "Couldn't create database for #{config.inspect}"
|
||||
$stderr.puts "Couldn't create database for #{default_config.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
def establish_connection(config = config)
|
||||
def establish_connection(config = default_config)
|
||||
DataMapper.setup(:default, config)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue