Fix default arguments in method definitions for ruby 2.2

This commit is contained in:
Kostas Karachalios 2015-01-13 11:10:46 +01:00
parent 05db934a19
commit c38119c6f9
5 changed files with 26 additions and 26 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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