Method: Waxx::Init#install_waxx
- Defined in:
- lib/waxx/init.rb
#install_waxx(x, input, opts) ⇒ Object
Install Waxx in the target folder. Copy skel and update the config file
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/waxx/init.rb', line 210 def install_waxx(x, input, opts) skel_folder = "#{File.dirname(__FILE__)}/../../skel/" install_folder = opts/:sub_command puts "" puts "Copying files from #{skel_folder} to #{install_folder}" FileUtils.cp_r(skel_folder, install_folder, verbose: false) if input/:init/:db puts "" puts "Setup Database" create_waxx_table(x, input) end if not (input/:databases).empty? # Require the correct db lib in app/app.rb db_libs = {pg: 'pg', postgresql: 'pg', mysql: 'mysql2', mysql2: 'mysql2', sqlite: 'sqlite3', sqlite3: 'sqlite3', mongo: 'mongodb', mongodb: 'mongodb'} db_lib = db_libs[(input/:databases/:app).split(":").first.to_sym] puts "Requiring lib '#{db_lib}' in app/app.rb" app_rb = File.read("#{install_folder}/app/app.rb") File.open("#{install_folder}/app/app.rb","w"){|f| f.puts app_rb.sub("# require '#{db_lib}'","require '#{db_lib}'") } end puts "" puts "Installing dev config" input.delete "init" File.open("#{install_folder}/opt/dev/config.yaml","w"){|f| f << input.to_yaml} puts "" puts "Waxx installed successfully." puts "cd into #{install_folder} and run `waxx on` to get your waxx on" puts "Optionally run `waxx gen app TABLE_NAME` where TABLE_NAME is the name of a table in your database." end |