trivial/bin/trivialize

30 lines
1.1 KiB
Plaintext
Raw Normal View History

2010-03-21 17:17:04 +00:00
#!/usr/bin/env ruby
require 'fileutils'
if !ARGV[0]
puts "Please specify the name of a new directory to create & trivialize"
exit 1
end
puts "Trivializing #{ARGV[0]}"
FileUtils.mkdir ARGV[0] if (!File.directory? ARGV[0])
%w{content actions views scripts styles lib}.each do |dir|
FileUtils.mkdir File.join(ARGV[0], dir) if (!File.directory? File.join(ARGV[0], dir))
end
2010-03-21 19:10:08 +00:00
[
[ [File.dirname(__FILE__), '..', 'lib', 'trivial.php'], [ARGV[0], 'lib', 'trivial.php'] ],
[ [File.dirname(__FILE__), '..', 'dist', 'htaccess.dist'], [ARGV[0], '.htaccess'] ],
[ [File.dirname(__FILE__), '..', 'views', 'application.inc'], [ARGV[0], 'views', 'application.inc'] ],
[ [File.dirname(__FILE__), '..', 'content', 'index.html'], [ARGV[0], 'content', 'index.html'] ],
[ [File.dirname(__FILE__), '..', 'styles', 'application.css'], [ARGV[0], 'styles', 'application.css'] ]
].each do |src, dest|
2010-03-22 00:16:17 +00:00
if !File.exists? File.join(*dest)
FileUtils.cp(File.join(*src), File.join(*dest))
else
puts "Won't overwrite existing #{File.join(*dest)}!"
end
2010-03-21 17:17:04 +00:00
end
puts "Done! Make sure you can use .htaccess files in your Webserver setup."