carlosbrando / poignant-br

Tradução do livro Why's (Poignant) Guide to Ruby para português.

This URL has Read+Write access

nelsonmhjr (author)
Sat May 23 09:34:29 -0700 2009
carlosbrando (committer)
Mon May 25 06:26:53 -0700 2009
poignant-br / scripts / traduz.rb
100755 36 lines (30 sloc) 0.893 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env ruby
require 'net/http'
require 'rubygems'
require 'hpricot'
require 'open-uri'
 
puts '# #
# URBAN DICTONARY
# # # # # # # # # # # # # # # # # # # # ###'
begin
  u = Hpricot(open("http://www.urbandictionary.com/define.php?term=#{ARGV[0]}"))
  puts u.at('#entries').inner_text.gsub(/(\n\n)|(comments)/,'')
rescue => e
  nil
end
 
puts '
 
# #
# GOOGLE
# # # # # # # # # # # # # # # # # # # # ###'
# http://www.wagnerandrade.com/blog/2008/05/ruby-snapshot-1
html = Net::HTTP.new('translate.google.com').post('/translate_t', "langpair=en|pt&text=#{ARGV[0]}").body
puts Hpricot(html).at('#result_box').inner_text
 
puts '
 
# #
# BABYLON
# # # # # # # # # # # # # # # # # # # # ###'
b = Hpricot(open("http://www.babylon.com/definition/#{ARGV[0]}/Portuguese")).at('#results-col').inner_text
puts b.gsub(/(\n\n)|(Erros Nunca Mais)|(Abaixe este dicionário)/, '')
# #
# BABEL FISH
# TODO