Sha256: f63016101f5dd3c250513ab78a42570fb4e886cb374d45ac34d0bad1e8f6b110
Contents?: true
Size: 1.71 KB
Versions: 786
Compression:
Stored size: 1.71 KB
Contents
require 'find' require 'digest' require 'date' class CabooseHelper def initialize(vars) @vars = vars @vars['APP_NAME'] = @vars['APP_NAME'].downcase.capitalize @vars['APP_NAME_LOWERCASE'] = @vars['APP_NAME'].downcase @vars['CABOOSE_SALT'] = Digest::SHA1.hexdigest(DateTime.now.to_s) if @vars['CABOOSE_SALT'].nil? @vars['CABOOSE_VERSION'] = Caboose::VERSION if @vars['CABOOSE_VERSION'].nil? end def create_app # Create the rails app puts "Creating the rails app..." `rails _3.2.15_ new #{@vars['APP_NAME'].downcase} -d=postgresql` # Do the caboose init init_skeleton_files remove_public_index end # Copies all the files in the sample directory to the host application def init_skeleton_files puts "Adding files to rails app..." gem_root = Gem::Specification.find_by_name('caboose-cms').gem_dir skeleton_root = File.join(gem_root,'lib','sample_files') Find.find(skeleton_root).each do |file| next if File.directory?(file) file2 = file.gsub(skeleton_root, '') file2 = File.join(File.expand_path(@vars['APP_NAME'].downcase), file2) FileUtils.cp(file, file2) # Replace any variables f = File.open(file2, 'rb') str = f.read f.close @vars.each { |k,v| str.gsub!("|#{k}|",v) } File.open(file2, 'w') { |f| f.write(str) } end end # Removes the public/index.html file from the rails app def remove_public_index puts "Removing the public/index.html file... " filename = File.join(File.expand_path(@vars['APP_NAME'].downcase),'public','index.html') return if !File.exists?(filename) File.delete(filename) end end
Version data entries
786 entries across 786 versions & 1 rubygems