Sha256: 138b963f585707b78f31b91bb7426acb84690201e882f9eddd7ccac192f9bcab

Contents?: true

Size: 1.63 KB

Versions: 4

Compression:

Stored size: 1.63 KB

Contents

#!/usr/local/bin/ruby
require 'fileutils'
require 'optparse'
require 'optparse/time'
require 'ostruct'
require 'pp'
require 'erb'

app = ARGV[0]
raise "You must specify a name for this application!" if app.nil?

options = OpenStruct.new
options.orm = false

opts = OptionParser.new do |opts|
  
  opts.on("-o [ORM]") do |v|
    options.orm = v
  end
  
end

opts.parse!(ARGV)

include FileUtils

def create_dir(dir)
  mkdir_p(dir)
  puts "Created: #{dir}"
end

# Create directories:
create_dir(File.join(app, "app", "controllers"))
create_dir(File.join(app, "app", "helpers"))
create_dir(File.join(app, "app", "models"))
create_dir(File.join(app, "app", "views", "default"))
create_dir(File.join(app, "app", "views", "layouts"))
create_dir(File.join(app, "config", "app_config"))
create_dir(File.join(app, "lib", "tasks"))
create_dir(File.join(app, "log"))
create_dir(File.join(app, "public", "images"))
create_dir(File.join(app, "public", "stylesheets"))
create_dir(File.join(app, "public", "javascripts"))
create_dir(File.join(app, "test", "unit"))
create_dir(File.join(app, "test", "functional"))
create_dir(File.join(app, "vendor", "plugins"))

# Copy over templates:
erb_files = Dir.glob(File.join(File.dirname(__FILE__), "templates", "**/*.template"))

erb_files.each do |fl|
  if fl.match("database.yml") && !options.orm
  else
    res = ERB.new(File.open(fl).read).result(binding)
    n = fl.gsub(File.join(File.dirname(__FILE__), "templates"), app).gsub(".template", "")
    File.open(n, "w") {|f| f.puts res}
    puts "Created: #{n}"
  end
end

cp(File.join(File.dirname(__FILE__), "templates", "public", "favicon.ico"), File.join(app, "public", "favicon.ico"))

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mack-0.3.0 bin/mack
mack-0.4.1 bin/mack
mack-0.4.0 bin/mack
mack-0.4.0.1 bin/mack