namespace :aptana do RAILS_APPDIR = RAILS_ROOT.sub("/config/..","") LIBS = %w{rails activerecord actionmailer actionpack actionwebservice activesupport} def project_name Pathname.new(RAILS_APPDIR).basename.to_s end def project_file(name) < #{name} Project #{name} with ruby on rails org.rubypeople.rdt.core.rubybuilder org.rubypeople.rdt.core.rubynature org.radrails.rails.core.railsnature END end def loadpath_file(excludes, libs) content = "\n\n" content << "\t' content << "\n\t" content << '' content << "\n" pathentry = proc {|l| "\t\n"} libs.each {|lib| content << pathentry.call(lib)} content << '' end task :aptana => :environment do FileUtils.chdir(RAILS_APPDIR) File.open(".loadpath", 'w+') do |f| FileUtils.cd(Gem.path[0]); FileUtils.cd('gems') gems = Pathname.new('.') includes = [] LIBS.each do |lib| gems.entries.each {|e| includes << File.basename(e) if File.basename(e).index(lib) == 0 } end FileUtils.cd(RAILS_APPDIR); FileUtils.cd('vendor') vendors = Pathname.new('.') excludes = [] for e in vendors.entries name = File.basename(e) if e.symlink? and name.index('rails') == 0 FileUtils.rm(e) else unless name.index('plugin') == 0 || name.index('.') == 0 excludes << 'vendor' + File::SEPARATOR + name end end end f.write loadpath_file(excludes, includes) end FileUtils.chdir(RAILS_APPDIR) File.open(".project", 'w+') do |f| f.write project_file(project_name) end end end