lib/bio-ucsc/ci2.rb in bio-ucsc-api-0.4.0 vs lib/bio-ucsc/ci2.rb in bio-ucsc-api-0.5.0

- old
+ new

@@ -4,22 +4,60 @@ # MISHIMA, Hiroyuki # <missy at be.to / hmishima at nagasaki-u.ac.jp> # License:: The Ruby licence (Ryby's / GPLv2 dual) # -require "#{::File.dirname(__FILE__)}/db_connector" require "#{::File.dirname(__FILE__)}/table_class_detector" module Bio module Ucsc module Ci2 CHROMS = %w(chr01p chr01q chr02q chr03p chr03q chr04q chr05q chr06q chr07q chr08q chr09p chr09q chr10p chr10q chr12p chr12q chr13q chr14p chr14q) extend TableClassDetector - include DBConnector - DBConnection.database "ci2" + def self.default + DBConnection.default + end + + def self.connect(param = Hash.new) + DBConnection.db_adapter = param[:db_adapter] if param[:db_adapter] + DBConnection.db_host = param[:db_host] if param[:db_host] + DBConnection.db_username = param[:db_username] if param[:db_username] + DBConnection.password = param[:password] if param[:password] + DBConnection.connect + end + + class DBConnection < ActiveRecord::Base + include SafeAttributes + self.inheritance_column = 'dummy_not_to_use' + + @@db_adapter ||= 'mysql' + @@db_host ||= 'genome-mysql.cse.ucsc.edu' + @@db_username ||= 'genome' + @@db_password ||= '' + @@db_name ||= 'ci2' + + cattr_accessor :db_adapter, :db_host, :db_username, :db_password + + self.abstract_class = true + + def self.default + @@db_adapter = 'mysql' + @@db_host = 'genome-mysql.cse.ucsc.edu' + @@db_username = 'genome' + @@db_password = '' + end + + def self.connect + establish_connection({ :adapter => @@db_adapter, + :host => @@db_host, + :database => @@db_name, + :username => @@db_username, + :password => @@db_password, }) + end + end # class DBConnection base = "#{::File.dirname(__FILE__)}/ci2" end end end