Last Updated: February 25, 2016
· kgrz


Fork the gist here

~/.rake is your global rake directory. Rake knows the tasks you write there.
Create a rake file, say, sinatra.rake

desc "Create a directory structure for Sinatra classic app"
task :create_sinatra do
  sh "mkdir public"
  sh "touch app.rb"
  sh "mkdir public/js"
  sh "mkdir public/css"
  sh "mkdir public/images"

The description is mandatory for global rake tasks. And then, "cd" into your app directory and run:

rake -g create_sinatra 


rake --system create_sinatra

Optionally, you can specify a directory name. The script would be:


desc "Create a directory structure for Sinatra classic app in a specified directory"
task :create_sinatra_in do
  dir = ARGV.count > 2 ? ARGV.last : "."
  sh "mkdir #{dir}" unless dir == "."
  sh "mkdir #{dir}/public"
  sh "touch #{dir}/app.rb"
  sh "mkdir #{dir}/public/js"
  sh "mkdir #{dir}/public/css"
  sh "mkdir #{dir}/public/images"

and run it with

rake -g create_sinatra 

which creates a dir structure in the current directory. Or,

rake -g create_sinatra 'myapp/appfolder'

which will create the structure under 'myapp/appfolder' dir