class Ferry::Utilities
Public Instance Methods
check_valid_db(db)
click to toggle source
# File lib/ferry/utilities.rb, line 4 def check_valid_db(db) %w[sqlite3 postgresql mysql2].include?(db) ? true : false end
check_valid_filetype(filepath)
click to toggle source
# File lib/ferry/utilities.rb, line 8 def check_valid_filetype(filepath) %w[csv json sql yml].include?(filepath.split('.').last) ? true : false end
db_connect(environment)
click to toggle source
# File lib/ferry/utilities.rb, line 12 def db_connect(environment) db_config = YAML::load(IO.read("config/database.yml")) if db_config[environment].nil? raise "No database associated with #{environment} environment" end db_type = db_config[environment]["adapter"] if ['sqlite3', 'postgresql', 'mysql2'].include?(db_type) ActiveRecord::Base.establish_connection(adapter: db_type, database: db_config[environment]['database']) puts "operating with "+db_type return db_type else raise "#{db_type} is not supported by ferry at this time" end end
execute(command)
click to toggle source
# File lib/ferry/utilities.rb, line 27 def execute(command) `#{command}` end
print_version()
click to toggle source
# File lib/ferry/utilities.rb, line 31 def print_version puts "Ferry #{Ferry::VERSION}" end