wordref 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbfa8fd138bc5b2d81e9b40fa8a342182ceca80a
4
- data.tar.gz: 623d1170651c9fc430d6084d7b5f4e7e865ba53d
3
+ metadata.gz: 4b272d973df0d462e03746541f77fd362f450510
4
+ data.tar.gz: 0552660215b36b1ca4b4739db69b7527be818d96
5
5
  SHA512:
6
- metadata.gz: e2b65845fed09c0068a119cbfe034c71303d6224d247482c0f1f21501449d3f4d8ad09855f1ff153fd5f78e155f276007735df3a86bd591cb7357e55ce8ec4ca
7
- data.tar.gz: 3a2f8e7e64fd1d73bb779b6ccdb54d0f768e1f7bec28ed8c5e2aa88010dd63ce5bdb9ea65609b6bcb890657acb2bd28b3b7b6421f7818f6e969f379f22b3af15
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)}").read
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
@@ -1,3 +1,3 @@
1
1
  module Wordref
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordref
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - pcboy