require 'bundler' require 'fileutils' $:.push File.expand_path("../lib", __FILE__) require "smock/version" Bundler::GemHelper.install_tasks task :default => :build_version desc "clean up" task :clean do sh "rm -rf tmp versions" end desc "test stuff" task :test do FileUtils.mkdir_p "./tmp/" sh "bundle exec sass -l ./app/assets/stylesheets/smock.sass tmp/output.css" end desc "build a version of smock ready for deploy" task :build_version => :clean do target = "./versions/#{Smock::VERSION}" FileUtils.mkdir_p target sh "ln -s $(pwd)/app/assets/smock.js ./#{target}/smock.js" sh "bundle exec sass --precision 7 ./app/assets/stylesheets/smock.sass #{target}/smock.css" sh "bundle exec sass --precision 7 ./app/assets/stylesheets/smock.sass #{target}/smock.min.css --style compressed" sh "bundle exec sass --precision 7 ./app/assets/stylesheets/svg_images.sass #{target}/svg_images.css" sh "bundle exec sass --precision 7 ./app/assets/stylesheets/svg_images.sass #{target}/svg_images.min.css --style compressed" sh "ln -s $(pwd)/examples #{target}/examples" latest = "./versions/latest" FileUtils.mkdir_p latest sh "cp -R #{target}/* #{latest}/" sh "bundle exec sass ./guide.sass #{latest}/guide.css" sh "ln -s $(pwd)/index.html #{latest}/" sh "ln -s $(pwd)/guide.js #{latest}/" end desc "run a sass watcher" task :sasswatch => :build_version do sh "bundle exec sass --watch --precision 7 app/assets/stylesheets/smock.sass:./versions/smock.css" sh "bundle exec sass --watch --precision 7 app/assets/stylesheets/svg_images.sass:./versions/svg_images.css" end desc "deploy to S3 (Depends on the AWS CLI being available)" task :deploy_to_aws do if ENV["SNAP_BRANCH"] == 'master' sh "aws s3 sync versions/latest s3://smock.io/latest --delete --recursive --cache-control 'max-age=0, must-revalidate'" sh "aws s3 sync versions s3://smock.io/" else puts "Not on master. Refusing to deploy to S3" end end desc "publish ruby gem" task :release_gem do if ENV["SNAP_BRANCH"] == 'master' sh "gem push pkg/*.gem" else puts "Not on master. Refusing to publish a gem" end end