Class: Fir::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/fir/generator.rb

Instance Method Summary collapse

Instance Method Details

#generate!(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fir/generator.rb', line 7

def generate!(args)
	unless args.length >= 1
		raise 'Usage: fir path'
	end
	
	fir_root = args.shift
	
	if File.exists?(fir_root)
		raise "#{fir_root} already exists! Aborting."
	end
	FileUtils.cp_r FIR_SKELETON_ROOT, fir_root
	# What's the deal with .htaccess being renamed, you ask? Rubygems doesn't want to include .htaccess
	# in the package, so we have to distribute it as htaccess and then rename it at the last moment.
	FileUtils.mv File.join(fir_root, 'public', 'htaccess'), File.join(fir_root, 'public', '.htaccess')
	puts "Created new Fir site in #{fir_root}"
	
	[
		['--with-dispatch-cgi', 'public/dispatch.cgi'],
		['--with-htaccess', 'public/.htaccess']
	].each do |option, file|
		unless args.include?(option)
			FileUtils.rm File.join(fir_root, file)
		end
	end
end