public
Clone URL: git://github.com/robbyrussell/rubyurl.git
Search Repo:
Robby Russell (author)
Sun Mar 02 17:35:33 -0800 2008
commit  6dee0c8bd29661da3c489df1f54b94afcd632494
tree    01199eb0b75fbc509a7e27a5a5b9a2c76d581c1f
parent  b366a0721d1d9dc6506f516a180293d3bafa763c parent  67c4eee5d876537380832c0da03babb768dee8eb
rubyurl / script / generate_robots_file
100755 18 lines (12 sloc) 0.394 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'
 
@links = Link.find(:all)
 
robot_file_path = File.dirname(__FILE__) + "/../public/robots.txt"
 
if File.exist?(robot_file_path)
  File.delete(robot_file_path)
end
 
robots_file = File.new(robot_file_path, "w+")
 
robots_file.puts "User-agent: *"
 
@links.each do |link|
  robots_file.puts "Disallow: /#{link.token}"
end