require 'dotenv/load' require 'sassc' require_relative './db/migrate' require_relative './db/scrape' task 'migrate' do migrate end task 'scrape' do should_log = ENV['APP_ENV'] == 'development' || ARGV.include?('--log') scraper = Scraper.new(log: should_log) scraper.scrape end task 'build' do scss = File.read('./web/assets/style.scss') css = SassC::Engine.new(scss, style: :compressed).render puts 'Writing web/public/style.css' File.write('./web/public/style.css', css) js = File.read('./web/assets/script.js') puts 'Writing web/public/script.js' File.write('./web/public/script.js', js) end task 'deploy' do username = ENV['PROD_USERNAME'] hostname = ENV['PROD_HOSTNAME'] puts `rsync -rv ./db/*.rb #{username}@#{hostname}:/var/www/vlv-search/` puts `rsync -rv ./lib #{username}@#{hostname}:/var/www/vlv-search/` puts `rsync -rv ./web #{username}@#{hostname}:/var/www/vlv-search/` puts `rsync -rv ./Rakefile #{username}@#{hostname}:/var/www/vlv-search/` puts `rsync -rv ./Gemfile #{username}@#{hostname}:/var/www/vlv-search/` puts `rsync -rv ./Gemfile.lock #{username}@#{hostname}:/var/www/vlv-search/` puts `ssh -t #{username}@#{hostname} 'bash -ic ". .profile; cd /var/www/vlv-search; rake build;"'` puts `ssh -t #{username}@#{hostname} 'bash -ic ". .profile; ~/restart-unicorn"'` end