git :init run "echo 'TODO add readme content' > README" run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" run "cp config/database.yml config/database.example.yml" run "rm public/index.html" file ".gitignore", <<-END log/*.log tmp/**/* config/database.yml END # gem 'mislav-will_paginate' # rake("gems:install", :sudo => true) run "mkdir lib/extensions" initializer 'extensions.rb', <<-CODE # require 'extensions/#' CODE run "rm config/environments/development.rb" file 'config/environments/development.rb', %q{ # Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.cache_classes = true # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Show full error reports and disable caching config.action_controller.consider_all_requests_local = true config.action_view.debug_rjs = true config.action_controller.perform_caching = true config.action_controller.session_store = :mem_cache_store config.action_controller.cache_store = :mem_cache_store config.cache_store = :mem_cache_store # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false } file 'lib/tasks/memcached.rake', %q{ require 'yaml' require 'erb' namespace :memcached do desc "Start memcached locally" task :start do if memcached_installed? puts "starting memcached" cmd = "/usr/bin/env memcached #{config_args} > log/memcached-#{Rails.env}.log" puts cmd `#{cmd}` end end desc "Restart memcached locally" task :restart do Rake::Task['memcached:stop'].invoke Rake::Task['memcached:start'].invoke end desc "Stop memcached locally" task :stop do pidfile = File.join(RAILS_ROOT,'tmp','pids','memcached-' + Rails.env + '.pid') `kill \`cat #{pidfile}\`` `rm #{pidfile}` puts "memcached killed" end desc "flush memcached store locally" task :flush_all do `echo 'flush_all' | nc localhost 11211` puts "memcached flushed" end end def memcached_installed? location = `which memcached` if location.strip.empty? puts 'memcached is not installed' puts 'sudo port install memcached' false else true end end def config return @config if @config if File.exists?(File.join(Rails.root, 'config','memcached.yml')) config = YAML.load(ERB.new(IO.read(File.join(Rails.root, 'config','memcached.yml'))).result) @config = config['defaults'].merge(config[Rails.env]) else @config = { 'veryverbose' => true } end end def config_args args = { } args['-p'] = config['port'] if config['port'] args['-c'] = config['c_threshold'] if config['c_threshold'] args['-m'] = config['memory'] if config['memory'] args['-d'] = '' args['-P'] = "#{File.join(RAILS_ROOT,'tmp','pids','memcached-' + Rails.env + '.pid')}" args['-v'] = '' if config['verbose'] == true args['-vv'] = '' if config['veryverbose'] == true args.to_a * ' ' end } git :add => ".", :commit => "-m 'initial commit'"