Module: Hydroponics::Setup
- Defined in:
- lib/hydroponics/setup.rb
Instance Method Summary collapse
- #convert_rails_yml_to_sequel_config(yml) ⇒ Object
- #get_db_from_local_rails_project(proj_root) ⇒ Object
- #raise_max_packet_size ⇒ Object
Instance Method Details
#convert_rails_yml_to_sequel_config(yml) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/hydroponics/setup.rb', line 19 def convert_rails_yml_to_sequel_config(yml) { :adapter => yml[Rails.env]['adapter'], :host => yml[Rails.env]['host'], :database => yml[Rails.env]['database'], :user => yml[Rails.env]['username'], :password => yml[Rails.env]['password'] } end |
#get_db_from_local_rails_project(proj_root) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hydroponics/setup.rb', line 29 def get_db_from_local_rails_project(proj_root) yml_path = File.join(proj_root, Rails::YML_PATH) raise "Aborting: no database.yml file found" unless File.exists?(yml_path) Rails.root = proj_root # protopipe has its YML file as an ERB which references Rails.root yml = YAML::load(ERB.new(File.open(yml_path).read).result(binding)) dbconfig = convert_rails_yml_to_sequel_config(yml) Hydroponics.db = Sequel.connect(dbconfig) dbconfig.merge(:password => "---") # output end |
#raise_max_packet_size ⇒ Object
42 43 44 |
# File 'lib/hydroponics/setup.rb', line 42 def raise_max_packet_size Hydroponics.db.execute("set global max_allowed_packet=1048576000;") end |