Skip to content

Instantly share code, notes, and snippets.

@chikadance
Created April 9, 2013 09:21
Show Gist options
  • Save chikadance/5344295 to your computer and use it in GitHub Desktop.
Save chikadance/5344295 to your computer and use it in GitHub Desktop.
rakefile for web ex
require "fileutils"
task :default => [:new_web_proj]
task :new_web_proj => [:precheck, :clear, :js, :img, :css, :create_index,
:open_scss_watch]
task :precheck do
if Dir.glob("**") != ["Rakefile"]
puts "This Proj is not empty, Are you sure to delete all and rebuild a new
proj?"
puts "please choose yes or no"
@prompt = ">>"
def get_choice
print @prompt; choice = STDIN.gets.chomp
["yes", "no"].include?(choice.downcase) ?
(choice.downcase == "yes" ? puts("buiding a new proj") : exit
) : get_choice
end
get_choice
end
end
task :clear do
rm_rf(Dir.glob("**") - ["Rakefile"])
end
directory "js"
directory "img"
directory "css"
task :create_index do
f = File.open("index.html", "w+")
f.puts"<html>"
f.puts"<head>"
f.puts" <title></title>"
f.puts" <meta charset=\"utf-8\" />"
f.puts"</head>"
f.puts"<body>"
f.puts" "
f.puts"</body>"
f.puts"</html>"
f.close
end
task :open_scss_watch do
File.open("./css/style.scss", "w+").close
sh "sass -w ./css/style.scss:./css/style.css"
end
task :rerun_sass => [:open_scss_watch]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment