Newsgroups: comp.lang.ruby
From: James Edward Gray II <ja...@grayproductions.net>
Date: Wed, 1 Feb 2006 02:18:27 +0900
Local: Tues, Jan 31 2006 12:18 pm
Subject: Re: [QUIZ] Port a Library (#64)
On Jan 29, 2006, at 10:23 AM, James Edward Gray II wrote:
> This is my port of File::ReadBackwards. I haven't had time to document it yet, but here is the other port of WWW::RobotRules. You use it something like this: #!/usr/local/bin/ruby -w require "robot_rules" rules = RobotRules.new("RubyQuizBrowser 1.0") open(robots_url) do |url| puts "/robots.txt:" rules.parse(robots_url, data) puts "URL tests:" __END__ Which prints: /robots.txt: URL tests: James Edward Gray II #!/usr/local/bin/ruby -w # robot_rules.rb require "uri" # Based on Perl's WWW::RobotRules module, by Gisle Aas. def parse( text_uri, robots_data ) rules = robots_data.split(/[\015\012]+/). current = if $1 == "*" if $1.empty? next unless disallow.scheme.nil? or disallow.scheme == disallow = disallow.path current << disallow @rules[location] = if my_rules.empty? def allowed?( text_uri ) return true unless %w{http https}.include?(uri.scheme) not @rules[location].any? { |rule| path.index(rule) == 0 } You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||