wordref 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wordref.rb +3 -1
- data/lib/wordref/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b272d973df0d462e03746541f77fd362f450510
|
4
|
+
data.tar.gz: 0552660215b36b1ca4b4739db69b7527be818d96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33ff3a00abfe4a47479198a70f7a3c1096f17ff1ff1c2aff6367779740efa632c5920f2801119c22952e8f25c8f1f534b91b4ac1ff3d3c115cc5dd5db89342a0
|
7
|
+
data.tar.gz: 9b68f651e1a4a59c58341b86da4da8c71adbf02974ac8633f13604a9272397417581a622629c365f21d21805fcbf1e5a624ee1ef33e95ea7ecdc3c50effd7313
|
data/lib/wordref.rb
CHANGED
@@ -30,10 +30,12 @@ module Wordref
|
|
30
30
|
word = params[:word]
|
31
31
|
|
32
32
|
response = attempt(3, 3) {
|
33
|
-
open("http://www.wordreference.com/#{dic}/#{URI::encode(word)}"
|
33
|
+
open("http://www.wordreference.com/#{dic}/#{URI::encode(word)}",
|
34
|
+
'User-Agent' => 'Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20100101 Firefox/10.0').read
|
34
35
|
}
|
35
36
|
doc = Nokogiri::HTML(response)
|
36
37
|
first_trans = doc.css("tr[id^='#{dic}:']").first
|
38
|
+
return nil if first_trans.nil?
|
37
39
|
first_trans.css('td[class="ToWrd"] > text()').to_s.strip
|
38
40
|
end
|
39
41
|
end
|
data/lib/wordref/version.rb
CHANGED