#!/usr/bin/env ruby # # Copyright (c) 2013-2014 Masanori Kado # # This program is free software. # You can distribute or modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. # For details of the GNU LGPL, see the file "COPYING". require 'fileutils' def main if ARGV.empty? puts "Usage: #{File.basename($0)} dirname" exit end initdir = File.expand_path(ARGV.shift) @review_dir = File.dirname(File.expand_path(__FILE__ + "./../")) generate_dir(initdir) do |dir| generate_review_setting_files(dir) generate_sample(dir) generate_images_dir(dir) generate_cover_image(dir) generate_layout(dir) generate_texmacro(dir) generate_config(dir) generate_rakefile(dir) end end def generate_dir(dir) if File.exist? dir puts "#{dir} already exists." exit end FileUtils.mkdir_p dir yield dir end def generate_sample(dir) File.open("#{dir}/#{File.basename(dir)}.re", "w") do |file| file.write("= ") end end def generate_layout(dir) Dir.mkdir dir + '/layouts' File.open("#{dir}/layouts/layout.erb", "w") do |file| file.write <<-EOS