Created
November 27, 2012 00:44
-
-
Save dyoder/4151666 to your computer and use it in GitHub Desktop.
Using do to create a rich function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# None of the various "private" functions or data structures used by our robot function are exposed. | |
# The function just magically returns a robot for the given host. | |
robot = do -> | |
_makeRobot = require "robotstxt" | |
_userAgent = "Mozilla/5.0 (compatible; Googlebot/2.1)" | |
robots = {} | |
(host) -> robots[host] ?= _makeRobot "http://#{host}/robots.txt", _userAgent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment