diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rwxr-xr-x | railties/bin/generate | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 490eb004db..993d4a6db3 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added 5-second timeout to WordNet alternatives on creating reserved-word models #501 [Marcel Molina] + * Fixed binding of caller #496 [Alexey] diff --git a/railties/bin/generate b/railties/bin/generate index 55c55724b1..42698f8be7 100755 --- a/railties/bin/generate +++ b/railties/bin/generate @@ -6,14 +6,18 @@ ARGV.shift unless ARGV.empty? or not ['--help', '-h'].include?(ARGV[0]) def find_synonyms(word) require 'open-uri' + require 'timeout' + uri = "http://wordnet.princeton.edu/cgi-bin/webwn2.0?stage=2" + "&word=%s&posnumber=1&searchtypenumber=2&senses=&showglosses=1" - open(uri % word) do |stream| - data = stream.read.gsub(" ", " ").gsub("<BR>", "") - data.scan(/^Sense \d+\n.+?\n\n/m) + timeout(5) do + open(uri % word) do |stream| + data = stream.read.gsub(" ", " ").gsub("<BR>", "") + data.scan(/^Sense \d+\n.+?\n\n/m) + end end -rescue Exception +rescue Timeout::Error, Exception return nil end @@ -66,4 +70,4 @@ end_usage #{$0} login end_usage exit 0 -end
\ No newline at end of file +end |