Sha256: 6c90abd368c2a32c4d0df601659fc92cfc4c721b923f9e3771a87df80ac290dd

Contents?: true

Size: 996 Bytes

Versions: 1

Compression:

Stored size: 996 Bytes

Contents

require 'utopia/version'
require 'fileutils'
require 'find'
require 'rake'

module Utopia
	module Setup
		ROOT = File.join(File.dirname(__FILE__), "setup", "")
		DIRECTORIES = ["access_log", "cache", "cache/meta", "cache/head", "lib", "pages", "public"]
		
		def self.copy(to, config = {})
			$stderr.puts "Copying files from #{ROOT} to #{to}..."
			Find.find(ROOT) do |src|
				dst = File.join(to, src[ROOT.size..-1])
				
				if File.directory?(src)
					FileUtils.mkdir_p(dst)
				else
					if File.exist? dst
						$stderr.puts "File already exists: #{dst}!"
					else
						$stderr.puts "Copying #{src} to #{dst}..."
						FileUtils.cp(src, dst)
					end
				end
			end
			
			DIRECTORIES.each do |path|
				FileUtils.mkdir_p(File.join(to, path))
			end
			
			$stderr.puts "Updating config.ru..."
			config_ru = File.join(to, "config.ru")
			buf = File.read(config_ru).gsub('$UTOPIA_VERSION', Utopia::VERSION::STRING.dump)
			File.open(config_ru, "w") { |fp| fp.write(buf) }
		end
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
utopia-0.9.32 lib/utopia/setup.rb